Description
Extracted from #14265.
Zig will have built-in support for fetching dependencies from some protocols, such as http, https, gzip, tar, and some others. But there will always be new or exotic protocols. One such example would be ipfs. Not really ubiquitous enough to support directly, but could be interesting for some people to use.
For this I propose a "fetch plugin" system.
Fetch plugins would be specified in build.zig.zon like this:
.{
// ...
.fetch_plugins = .{
.ipfs = .{
.url = "git+ssh://git@example.com/foo.tar.gz#6f987aba83414319c3afba57a9f49a71f6e13c8e",
.hash = "sha256=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae",
},
.@"git+ssh" = .{
.url = "http://example.com/bar.tar.gz",
.hash = "sha256=9ba4f49895b174a3f918d489238acbc146bd393575062b2e3be33488b688e36f",
},
},
// ...
}
The url fields within fetch_plugins
must use a built-in URI scheme or a different fetch plugin from the same manifest.
Implementing this proposal will lift out this code from the zig compiler:
Lines 4080 to 4126 in 7cb2f92
...and move it to a new file lib/fetch_runner.zig
. This is similar to build_runner.zig
and test_runner.zig
and has the responsibility to fetch the full dependency tree. It will deal with fetch plugins by fetching them, and then rebuilding the fetch runner itself, multiple times if necessary, until everything is fetched.
Once everything is fetched, build_runner.zig proceeds as usual. Note that in the case when everything is already fetched, the fetch_runner will not be executed because the open() syscalls on the first-level dependencies based on their hashes all succeeded.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status