Open andrewrk opened 9 months ago
Some general comment from what i've figured:
LazyPath
is missing a crucial component now that the package manger is there: The path
field is relative to some build.zig
, but we do not store the relevant builder.
I think we should add some api like fn path(b: *Build, rel: []const u8) LazyPath
which constructs a path that is guaranteed to be relative to the given builder.
This way we can safely transport LazyPaths between dependency edges without confusing the build root
Absolute paths are generally problematic:
For general improvement in robustness as well as progress towards #14286, this issue is to eliminate all absolute paths from the zig build system. Here are some example violations:
https://github.com/ziglang/zig/blob/501a2350ab804f3e5d4253826bcdfb7a3f5d92fb/lib/std/Build/Step/Run.zig#L572-L573
https://github.com/ziglang/zig/blob/501a2350ab804f3e5d4253826bcdfb7a3f5d92fb/lib/std/Build/Step/Run.zig#L642-L656
https://github.com/ziglang/zig/blob/501a2350ab804f3e5d4253826bcdfb7a3f5d92fb/lib/std/Build/Step/WriteFile.zig#L216-L218
There are plenty more.
Instead, this API should be moved from the compiler implementation (
Package.Path
) tostd.Cache.Path
:https://github.com/ziglang/zig/blob/501a2350ab804f3e5d4253826bcdfb7a3f5d92fb/src/Package.zig#L6-L10
Then, Path objects should be passed around rather than strings. This will improve the correctness of a bunch of stuff as well as reduce the amount of unnecessary string manipulation that is happening, and make it easier to implement detection of going outside a directory root.