authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 14:22:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:36-07:00
log860d5ab9c41fd64c5150bd7d9f5b87cbcda9f281
treee812eef3624f133b8bfd5b0d5848e8290638a393
parent35ee3747ebe344b619c66b23053d3f2495956423

Maker: implement relativePath with non-empty subpath for zig_exe


2 files changed, 16 insertions(+), 8 deletions(-)

lib/compiler/Maker.zig+6-4
......@@ -1706,7 +1706,7 @@ pub fn resolveLazyPath(
17061706 const c = &maker.scanned_config.configuration;
17071707 return switch (lazy_path) {
17081708 .source_path => |sp| try packagePath(maker, arena, sp.owner, sp.sub_path.slice(c)),
1709 .relative => |relative| relativePath(maker, relative),
1709 .relative => |relative| relativePath(maker, arena, relative),
17101710 .generated => |gen| {
17111711 const base = generatedPath(maker, gen.index).*;
17121712 var file_path = base;
......@@ -1785,11 +1785,10 @@ pub fn packagePath(
17851785 };
17861786}
17871787
1788pub fn relativePath(maker: *const Maker, relative: Configuration.LazyPath.Relative) Path {
1788pub fn relativePath(maker: *const Maker, arena: Allocator, relative: Configuration.LazyPath.Relative) Allocator.Error!Path {
17891789 const graph = maker.graph;
17901790 const c = &maker.scanned_config.configuration;
17911791 const sub_path = relative.sub_path.slice(c);
1792 if (relative.flags.base == .zig_exe and sub_path.len != 0) @panic("TODO relativePath zig_exe");
17931792 return switch (relative.flags.base) {
17941793 .cwd => .{
17951794 .root_dir = .cwd(),
......@@ -1809,7 +1808,10 @@ pub fn relativePath(maker: *const Maker, relative: Configuration.LazyPath.Relati
18091808 },
18101809 .zig_exe => .{
18111810 .root_dir = .cwd(),
1812 .sub_path = graph.zig_exe,
1811 .sub_path = if (sub_path.len == 0)
1812 graph.zig_exe
1813 else
1814 try Io.Dir.path.join(arena, &.{ graph.zig_exe, sub_path }),
18131815 },
18141816 .zig_lib => .{
18151817 .root_dir = graph.zig_lib_directory,
lib/compiler/Maker/Step.zig+10-4
......@@ -785,7 +785,10 @@ pub fn addWatchInput(step: *Step, maker: *Maker, arena: Allocator, lazy_file: La
785785 const pkg_path = try maker.packagePath(arena, source_path.owner, sub_path);
786786 try addWatchInputPath(step, maker, pkg_path);
787787 },
788 .relative => |relative| try addWatchInputPath(step, maker, maker.relativePath(relative)),
788 .relative => |relative| {
789 const resolved_path = try maker.relativePath(arena, relative);
790 try addWatchInputPath(step, maker, resolved_path);
791 },
789792 // Nothing to watch because this dependency edge is modeled instead via `dependants`.
790793 .generated => {},
791794 }
......@@ -799,16 +802,19 @@ pub fn addWatchInput(step: *Step, maker: *Maker, arena: Allocator, lazy_file: La
799802/// `addDirectoryWatchInputFromPath` if and only if this function returns
800803/// `true`.
801804pub fn addDirectoryWatchInput(step: *Step, maker: *Maker, lazy_directory: LazyPath) Allocator.Error!bool {
805 const graph = maker.graph;
806 const arena = graph.arena; // TODO don't leak into the process arena
802807 switch (lazy_directory) {
803808 .source_path => |source_path| {
804809 const conf = &maker.scanned_config.configuration;
805 const graph = maker.graph;
806 const arena = graph.arena; // TODO don't leak into the process arena
807810 const sub_path = source_path.sub_path.slice(conf);
808811 const pkg_path = try maker.packagePath(arena, source_path.owner, sub_path);
809812 try addDirectoryWatchInputFromPath(step, maker, pkg_path);
810813 },
811 .relative => |relative| try addDirectoryWatchInputFromPath(step, maker, maker.relativePath(relative)),
814 .relative => |relative| {
815 const resolved_path = try maker.relativePath(arena, relative);
816 try addDirectoryWatchInputFromPath(step, maker, resolved_path);
817 },
812818 // Nothing to watch because this dependency edge is modeled instead via `dependants`.
813819 .generated => return false,
814820 }