ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.38k stars 2.51k forks source link

use case: ability to declare dependency on single file #17895

Open Techatrix opened 11 months ago

Techatrix commented 11 months ago

ZLS depends on Zig's langref.html.in file to extract the set of a builtin function. Right now, this file is being manually downloaded during the build phase which does not integrate well with Zig's package manager and caching system. GitHub can't provide that file as a compressed tarball and fetching the entire repository source code is too wasteful.

It would be nice if there was a way to declare it as dependency to build.zig.zon:

    .dependencies = .{
        .langref = .{
            .url = "https://raw.githubusercontent.com/ziglang/zig/5b2ee5eacc177873ce674a307a1bebdfffeeae10/doc/langref.html.in",
            // have some option here to tell Zig that the url points to a single file and does not need to be decompressed
            .hash = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        },
    },
marler8997 commented 3 months ago

Here's another use case I discovered today. I'm adding a build.zig file to build VVVVVV, and it has a data.zip you can download with free assets and levels. I added the data.zip to build.zig.zon, but the game actually needs the zip file, not the extracted contents. To solve this I "re-zip" the contents and install them to the bin directory for the game to load, however, if there was a way to instead download the zip file as just a "file", this would remove some unnecessary steps.

andrewrk commented 1 month ago

This seems like it would be fully solved with .unpack = false, yeah?