From 860d5ab9c41fd64c5150bd7d9f5b87cbcda9f281 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 May 2026 14:22:28 -0700 Subject: [PATCH] Maker: implement relativePath with non-empty subpath for zig_exe --- lib/compiler/Maker.zig | 10 ++++++---- lib/compiler/Maker/Step.zig | 14 ++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 643df6b68fa576c3cd75e46ff570e1c5920ebc85..4420b98eca6255901fb4c060592a01dab3df0958 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -1706,7 +1706,7 @@ pub fn resolveLazyPath( const c = &maker.scanned_config.configuration; return switch (lazy_path) { .source_path => |sp| try packagePath(maker, arena, sp.owner, sp.sub_path.slice(c)), - .relative => |relative| relativePath(maker, relative), + .relative => |relative| relativePath(maker, arena, relative), .generated => |gen| { const base = generatedPath(maker, gen.index).*; var file_path = base; @@ -1785,11 +1785,10 @@ pub fn packagePath( }; } -pub fn relativePath(maker: *const Maker, relative: Configuration.LazyPath.Relative) Path { +pub fn relativePath(maker: *const Maker, arena: Allocator, relative: Configuration.LazyPath.Relative) Allocator.Error!Path { const graph = maker.graph; const c = &maker.scanned_config.configuration; const sub_path = relative.sub_path.slice(c); - if (relative.flags.base == .zig_exe and sub_path.len != 0) @panic("TODO relativePath zig_exe"); return switch (relative.flags.base) { .cwd => .{ .root_dir = .cwd(), @@ -1809,7 +1808,10 @@ pub fn relativePath(maker: *const Maker, relative: Configuration.LazyPath.Relati }, .zig_exe => .{ .root_dir = .cwd(), - .sub_path = graph.zig_exe, + .sub_path = if (sub_path.len == 0) + graph.zig_exe + else + try Io.Dir.path.join(arena, &.{ graph.zig_exe, sub_path }), }, .zig_lib => .{ .root_dir = graph.zig_lib_directory, diff --git a/lib/compiler/Maker/Step.zig b/lib/compiler/Maker/Step.zig index b4fd26fe66c7ab94dba29b35bafec882fd2b8723..2a42dd6959dd0510c0d6ff3887ef6e2b5eb5b411 100644 --- a/lib/compiler/Maker/Step.zig +++ b/lib/compiler/Maker/Step.zig @@ -785,7 +785,10 @@ pub fn addWatchInput(step: *Step, maker: *Maker, arena: Allocator, lazy_file: La const pkg_path = try maker.packagePath(arena, source_path.owner, sub_path); try addWatchInputPath(step, maker, pkg_path); }, - .relative => |relative| try addWatchInputPath(step, maker, maker.relativePath(relative)), + .relative => |relative| { + const resolved_path = try maker.relativePath(arena, relative); + try addWatchInputPath(step, maker, resolved_path); + }, // Nothing to watch because this dependency edge is modeled instead via `dependants`. .generated => {}, } @@ -799,16 +802,19 @@ pub fn addWatchInput(step: *Step, maker: *Maker, arena: Allocator, lazy_file: La /// `addDirectoryWatchInputFromPath` if and only if this function returns /// `true`. pub fn addDirectoryWatchInput(step: *Step, maker: *Maker, lazy_directory: LazyPath) Allocator.Error!bool { + const graph = maker.graph; + const arena = graph.arena; // TODO don't leak into the process arena switch (lazy_directory) { .source_path => |source_path| { const conf = &maker.scanned_config.configuration; - const graph = maker.graph; - const arena = graph.arena; // TODO don't leak into the process arena const sub_path = source_path.sub_path.slice(conf); const pkg_path = try maker.packagePath(arena, source_path.owner, sub_path); try addDirectoryWatchInputFromPath(step, maker, pkg_path); }, - .relative => |relative| try addDirectoryWatchInputFromPath(step, maker, maker.relativePath(relative)), + .relative => |relative| { + const resolved_path = try maker.relativePath(arena, relative); + try addDirectoryWatchInputFromPath(step, maker, resolved_path); + }, // Nothing to watch because this dependency edge is modeled instead via `dependants`. .generated => return false, } -- 2.54.0