Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #8
Techatrix opened this issue Nov 6, 2023 · 4 comments · May be fixed by #22042
Open
Tracked by #8

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

Techatrix opened this issue Nov 6, 2023 · 4 comments · May be fixed by #22042
Labels
accepted This proposal is planned. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@Techatrix
Copy link
Contributor

Techatrix commented Nov 6, 2023

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",
        },
    },
@Vexu Vexu added proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. zig build system std.Build, the build runner, `zig build` subcommand, package management use case Describes a real use case that is difficult or impossible, but does not propose a solution. labels Nov 6, 2023
@Vexu Vexu added this to the 0.13.0 milestone Nov 6, 2023
@marler8997
Copy link
Contributor

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 andrewrk added accepted This proposal is planned. and removed use case Describes a real use case that is difficult or impossible, but does not propose a solution. labels Sep 15, 2024
@andrewrk
Copy link
Member

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

@andrewrk andrewrk modified the milestones: 0.14.0, 0.15.0 Sep 15, 2024
@andrewrk andrewrk added the contributor friendly This issue is limited in scope and/or knowledge of Zig internals. label Sep 15, 2024
@marler8997
Copy link
Contributor

marler8997 commented Nov 20, 2024

I think I'll put together a PR for this imminently as I now have a real need for it, unsupported archive formats. With the ability to disable unpacking an archive, this unlocks the ability to download an archive in any format. It can then be extracted via another dependency.

More specifically, I'm converting my win32metdata to JSON converter from C# to zig and the metadata itself is a nuget package. With this "unpack" option I can just download the nupkg file and extract it with my own extraction tool.

marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
marler8997 added a commit to marler8997/zig that referenced this issue Nov 21, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
@castholm
Copy link
Contributor

castholm commented Nov 21, 2024

Many programs make assumptions about how to process the file based on filename extension and just inferring the filename from the URL or using it a random name or a hash might confuse such programs. It would be useful if the user could override the filename the single-file dependency is saved as. For example (continuing with the .unpack idea):

.dependencies = .{
    .template = .{
        .url = "https://example.com/headers/api-1.2.3",
        .hash = "...",
        .unpack = false,
        .filename = "api.h",
    },
},

marler8997 added a commit to marler8997/zig that referenced this issue Nov 22, 2024
closes ziglang#17895

Enhances zig with the ability to fetch a dependency of any file type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants