aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAbhinav Gupta <mail@abhinavg.net>2024-01-04 15:47:28 -0800
committerGitHub <noreply@github.com>2024-01-04 18:47:28 -0500
commitd3a163f86845bcc7d20e5fd54174e480d1a8ac33 (patch)
tree4e4085a2798bffeee7a7ef6167bd9c833c12d06d /src
parent501a2350ab804f3e5d4253826bcdfb7a3f5d92fb (diff)
downloadzig-d3a163f86845bcc7d20e5fd54174e480d1a8ac33.tar.gz
zig-d3a163f86845bcc7d20e5fd54174e480d1a8ac33.zip
build/LazyPath: Add dirname (#18371)
Adds a variant to the LazyPath union representing a parent directory of a generated path. ```zig const LazyPath = union(enum) { generated_dirname: struct { generated: *const GeneratedFile, up: usize, }, // ... } ``` These can be constructed with the new method: ```zig pub fn dirname(self: LazyPath) LazyPath ``` For the cases where the LazyPath is already known (`.path`, `.cwd_relative`, and `dependency`) this is evaluated right away. For dirnames of generated files and their dirnames, this is evaluated at getPath time. dirname calls can be chained, but for safety, they are not allowed to escape outside a root defined for each case: - path: This is relative to the build root, so dirname can't escape outside the build root. - generated: Can't escape the zig-cache. - cwd_relative: This can be a relative or absolute path. If relative, can't escape the current directory, and if absolute, can't go beyond root (/). - dependency: Can't escape the dependency's root directory. Testing: I've included a standalone case for many of the happy cases. I couldn't find an easy way to test the negatives, though, because tests cannot yet expect panics.
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions