Skip to content

make build.zig.zon contain all urls, including mirrors, and hashes of entire dependency tree #14309

@andrewrk

Description

@andrewrk

Extracted from #14265.

The motivation for this is faster dependency fetching, avoiding round-trips from the network.

The idea here is that, after fetching all dependencies, recursively, zig would edit the user's build.zig.zon file and automatically add a section that contains all urls & hashes (including mirrors) for the entire dependency tree. It might look something like this:

.{
    // ...
    .mirrors = .{
        .@"sha256=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae" = .{
            "https://example.com/1.tar.gz",
            "https://example.com/2.tar.gz",
        },
    },
}

In this case it matches exactly with #14292 which could be nice, or, on the other hand, it might be important to make a distinction between automatically added ones (which should also be removed automatically) or manually added ones (which should always be preserved).

Depending on how #14288 is resolved with regards to conflict resolution, this section would perhaps be combined with more tooling-managed data about each dependency, such as dependency overrides:

.{
    // ...
    .config = .{
        .@"sha256=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae" = .{
            .url = .{
                "https://example.com/1.tar.gz",
                "https://example.com/2.tar.gz",
            },
            .overrides = .{
                .libz = "sha256=9ba4f49895b174a3f918d489238acbc146bd393575062b2e3be33488b688e36f",
            },
        },
    },
}

When combined with #14294, this may additionally need to float the fetch plugins to the top along with mirrors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    Status

    Proposals

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions