-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Store Build relative information in LazyPath #19313
Comments
I would be in favor of this. Were this to be accepted, another bonus is that we can get rid of the |
This is closely related to #16067 and #18450. I've been thinking about this and I believe these could be solved if LazyPath looked like: const LazyPath = struct {
/// The owner builder object.
build: *std.Build,
/// A path relative to `root`.
path: []const u8,
///
root: union(enum) {
/// Indicates the path is evaluated relative to the build root directory.
build_relative,
/// Indicates the path is evaluated relative to the current working directory.
cwd_relative,
/// Indicates the path is evaluated relative to the generated cache path.
generated: *const std.Build.GeneratedFile,
},
}; Firstly, this eliminates the For #16067, implementing For this issue (#19313), the For #18450 (partly), checking the |
This looks like a really fine solution to the problem space! A regular generated file source has I really like this! |
This is a pretty important change, and I think it's worth making one more API break before tagging 0.12. |
This adds the *std.Build owner to LazyPath so that lazy paths returned from a dependency can be used in the application without friction or footguns. closes #19313
This adds the *std.Build owner to LazyPath so that lazy paths returned from a dependency can be used in the application without friction or footguns. closes #19313
Right now,
.{ .path = "xyz" }
is both (a bit) clunky and is missing information about thestd.Build
it is meant to be relative to.I often use
cwd_relative
now and just store an absolute path computed with@src()
, but i don't think this is the right solution here.Thus, i propose to change
zig/lib/std/Build.zig
Line 2051 in d565c5d
to
and to make the usage easier, to introduce
Which would replace
.{ .path = "xyz" }
withb.path("xyz")
which is even shorter than before, but packs more information (which is sometimes required in builds when handling LazyPaths over several build scripts)The text was updated successfully, but these errors were encountered: