-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Closed
Copy link
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package managementstd.Build, the build runner, `zig build` subcommand, package management
Milestone
Description
The idea here is that you can put an arbitrary file contents in your build.zig.zon, like this:
.{
.dependencies = .{
.foo = .{
.url = "https://example.com/foobar.tar.gz",
.hash = "12209e851f7e2c6ba2f01de3e11b1771f03e49666065320abd8414aac152bfa75fae",
},
},
}
Normally, at this point, one would activate the build.zig
script of the dependency like this:
const foo_dep = b.dependency("foo", .{
.target = target,
.optimize = optimize,
// ...other options...
});
However, this issue is about the use case where the dependency is not a zig package, but a bundle of arbitrary files.
The idea is that you can access arbitrary files as std.Build.LazyPath
objects, like this:
pub fn build(b: *std.Build) !void {
// ...
const lazy_path = b.dependencyPath("foo", "path/inside/dependency.txt");
// now you can pass it anywhere a lazy path is accepted:
run_step.addFileArg(lazy_path);
// or you can access the file directly from build script logic:
const contents = try std.fs.readFileAlloc(lazy_path.resolve());
// ...
}
Using it via the LazyPath API would help with #14597, because resolution of the path would force the package to be downloaded.
matu3ba, davidgmbb, der-teufel-programming, sagehane, nektro and 2 moreikskuh, mlarouche, davidgmbb, ianprime0509, der-teufel-programming and 1 more
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package managementstd.Build, the build runner, `zig build` subcommand, package management