Skip to content

std.Build.LazyPath: store Build relative information#19589

Closed
lacc97 wants to merge 14 commits intoziglang:masterfrom
lacc97:lazy-path-ng
Closed

std.Build.LazyPath: store Build relative information#19589
lacc97 wants to merge 14 commits intoziglang:masterfrom
lacc97:lazy-path-ng

Conversation

@lacc97
Copy link
Contributor

@lacc97 lacc97 commented Apr 8, 2024

Implements #19313.

@lacc97
Copy link
Contributor Author

lacc97 commented Apr 9, 2024

Not sure why the CI tests failed, the test suite on my linux dev machine passes.

@nektro
Copy link
Contributor

nektro commented Apr 9, 2024

might to to rebase/merge main to get the changes from #19485

lacc97 added 14 commits April 9, 2024 20:12
This frees up the `path` identifier for a container-scope function.
These functions let a std.Build construct a LazyPath. At the moment
this is mostly pointless relative to the old way of doing things
but once the internal structure of LazyPath changes it will make it
significantly easier to make local changes without having to rewrite
them everywhere else that uses a LazyPath.
This adds a `root` field to LazyPath which contains the actual union
data. This means the LazyPath is now a struct instead of a union itself.
This function won't be possible to implement once LazyPath requires
a pointer to std.Build that owns it.
I couldn't find any other place where Dependency.path() was being used,
so I added a standalone test that uses it, in addition to some of the
other Dependency functions for a somewhat more thorough test of how
dependencies might be used.
The use case is subsumed by the `path` union field.
This commit also renames the union fields `path` -> `build` and
`cwd_relative` -> `cwd`. Now, the struct field `root` represents
from whence the `path` field should be evaluated.

At the moment, I haven't touched the `generated` and `generated_dirname`
fields so LazyPath looks a bit awkward at the moment. The other fields
will likely need a bit more work so they will go as a separate commit.
This slightly simplifies the implementation.
/// system API, it was allowed to be absolute. Absolute paths should use `cwd_relative`.
path: []const u8,
pub const LazyPath = struct {
owner: *std.Build,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Should not be stored for a GeneratedFile since it is already accessible via generated_file.step.owner
  • Should not be stored for cwd_relative, since those are not associated with any *std.Build instance.

};

pub fn path(b: *Build, p: []const u8) LazyPath {
// TODO(lacc97): absolute paths
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewrk
Copy link
Member

Too much breaking. Please see #19597

@andrewrk andrewrk closed this Apr 10, 2024
@lacc97
Copy link
Contributor Author

lacc97 commented Apr 11, 2024

Too much breaking. Please see #19597

Sorry about that 😅, got a bit carried away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants