zig/lib/std/Build/Step
Abhinav Gupta d3a163f868
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.
2024-01-04 18:47:28 -05:00
..
CheckFile.zig Build.zig rename orgy (aka: #16353). Renames FileSource to LazyPath and removes functions that take literal paths instead of LazyPath. 2023-07-30 11:18:50 -07:00
CheckObject.zig zig build system: change target, compilation, and module APIs 2024-01-01 17:51:18 -07:00
Compile.zig std.Build.Step.Compile: fix passing wrong Builder to getPath 2024-01-02 18:22:11 -07:00
ConfigHeader.zig build/LazyPath: Add dirname (#18371) 2024-01-04 18:47:28 -05:00
Fmt.zig std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
InstallArtifact.zig zig build system: change target, compilation, and module APIs 2024-01-01 17:51:18 -07:00
InstallDir.zig update for the std.fs.Dir changes 2023-11-22 15:24:57 -07:00
InstallFile.zig Build.zig rename orgy (aka: #16353). Renames FileSource to LazyPath and removes functions that take literal paths instead of LazyPath. 2023-07-30 11:18:50 -07:00
ObjCopy.zig build/ObjCopy: strip debug info to a separate elf file. 2023-08-12 09:54:35 +02:00
Options.zig std.Build.Step.Options: update unit test to new API 2024-01-01 17:51:20 -07:00
RemoveDir.zig std.Build: use create() instead of init() for Step.RemoveDir 2023-10-21 17:48:25 +03:00
Run.zig Merge pull request #18262 from ziglang/fix-18259 2024-01-03 13:23:40 -08:00
TranslateC.zig zig build system: change target, compilation, and module APIs 2024-01-01 17:51:18 -07:00
WriteFile.zig zig build system: change target, compilation, and module APIs 2024-01-01 17:51:18 -07:00