@@ -141,6 +141,9 @@ pub const StdIo = union(enum) {
141
141
pub const Arg = union (enum ) {
142
142
artifact : PrefixedArtifact ,
143
143
lazy_path : PrefixedLazyPath ,
144
+ // Needed for `enableTestRunnerMode` for example, as you need to pass
145
+ // the cache directory without caching it.
146
+ uncached_decorated_lazy_path : DecoratedLazyPath ,
144
147
decorated_directory : DecoratedLazyPath ,
145
148
file_content : PrefixedLazyPath ,
146
149
bytes : []u8 ,
@@ -229,7 +232,7 @@ pub fn setName(run: *Run, name: []const u8) void {
229
232
pub fn enableTestRunnerMode (run : * Run ) void {
230
233
const b = run .step .owner ;
231
234
run .stdio = .zig_test ;
232
- run .addPrefixedDirectoryArg ("--cache-dir=" , .{ .cwd_relative = b .cache_root .path orelse "." });
235
+ run .addPrefixedPathArg ("--cache-dir=" , .{ .cwd_relative = b .cache_root .path orelse "." });
233
236
run .addArgs (&.{
234
237
b .fmt ("--seed=0x{x}" , .{b .graph .random_seed }),
235
238
"--listen=-" ,
@@ -472,6 +475,29 @@ pub fn addDecoratedDirectoryArg(
472
475
lazy_directory .addStepDependencies (& run .step );
473
476
}
474
477
478
+ pub fn addPathArg (run : * Run , lazy_path : std.Build.LazyPath ) void {
479
+ run .addPrefixedPathArg ("" , lazy_path );
480
+ }
481
+
482
+ pub fn addPrefixedPathArg (run : * Run , prefix : []const u8 , lazy_path : std.Build.LazyPath ) void {
483
+ run .addDecoratedPathArg (prefix , lazy_path , "" );
484
+ }
485
+
486
+ pub fn addDecoratedPathArg (
487
+ run : * Run ,
488
+ prefix : []const u8 ,
489
+ lazy_path : std.Build.LazyPath ,
490
+ suffix : []const u8 ,
491
+ ) void {
492
+ const b = run .step .owner ;
493
+ run .argv .append (b .allocator , .{ .uncached_decorated_lazy_path = .{
494
+ .prefix = b .dupe (prefix ),
495
+ .lazy_path = lazy_path .dupe (b ),
496
+ .suffix = b .dupe (suffix ),
497
+ } }) catch @panic ("OOM" );
498
+ lazy_path .addStepDependencies (& run .step );
499
+ }
500
+
475
501
/// Add a path argument to a dep file (.d) for the child process to write its
476
502
/// discovered additional dependencies.
477
503
/// Only one dep file argument is allowed by instance.
@@ -542,7 +568,7 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
542
568
}
543
569
break :use_wine std .mem .endsWith (u8 , p .lazy_path .basename (b , & run .step ), ".exe" );
544
570
},
545
- .decorated_directory = > false ,
571
+ .uncached_decorated_lazy_path , . decorated_directory = > false ,
546
572
.file_content = > unreachable , // not allowed as first arg
547
573
.bytes = > | bytes | std .mem .endsWith (u8 , bytes , ".exe" ),
548
574
.output_file , .output_directory = > false ,
@@ -809,11 +835,42 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
809
835
man .hash .addBytes (file .prefix );
810
836
_ = try man .addFilePath (file_path , null );
811
837
},
838
+ .uncached_decorated_lazy_path = > | dd | {
839
+ const src_lazy_path = dd .lazy_path .getPath3 (b , step );
840
+ try argv_list .append (b .fmt ("{s}{s}{s}" , .{ dd .prefix , run .convertPathArg (src_lazy_path ), dd .suffix }));
841
+ },
812
842
.decorated_directory = > | dd | {
813
- const file_path = dd .lazy_path .getPath3 (b , step );
814
- const resolved_arg = b .fmt ("{s}{s}{s}" , .{ dd .prefix , run .convertPathArg (file_path ), dd .suffix });
815
- try argv_list .append (resolved_arg );
816
- man .hash .addBytes (resolved_arg );
843
+ const src_dir_path = dd .lazy_path .getPath3 (b , step );
844
+ try argv_list .append (b .fmt ("{s}{s}{s}" , .{ dd .prefix , run .convertPathArg (src_dir_path ), dd .suffix }));
845
+ man .hash .addBytes (dd .prefix );
846
+ man .hash .addBytes (dd .suffix );
847
+
848
+ const need_derived_inputs = try step .addDirectoryWatchInput (dd .lazy_path );
849
+
850
+ var src_dir = src_dir_path .root_dir .handle .openDir (src_dir_path .subPathOrDot (), .{ .iterate = true }) catch | err | {
851
+ return step .fail ("unable to open source directory '{f}': {s}" , .{
852
+ src_dir_path , @errorName (err ),
853
+ });
854
+ };
855
+
856
+ var it = try src_dir .walk (arena );
857
+ defer it .deinit ();
858
+
859
+ while (try it .next ()) | entry | {
860
+ switch (entry .kind ) {
861
+ .directory = > {
862
+ if (need_derived_inputs ) {
863
+ const entry_path = try src_dir_path .join (arena , entry .path );
864
+ try step .addDirectoryWatchInputFromPath (entry_path );
865
+ }
866
+ },
867
+ .file = > {
868
+ const entry_path = try src_dir_path .join (arena , entry .path );
869
+ _ = try man .addFilePath (entry_path , null );
870
+ },
871
+ else = > continue ,
872
+ }
873
+ }
817
874
},
818
875
.file_content = > | file_plp | {
819
876
const file_path = file_plp .lazy_path .getPath3 (b , step );
@@ -1075,7 +1132,7 @@ pub fn rerunInFuzzMode(
1075
1132
const file_path = file .lazy_path .getPath3 (b , step );
1076
1133
try argv_list .append (arena , b .fmt ("{s}{s}" , .{ file .prefix , run .convertPathArg (file_path ) }));
1077
1134
},
1078
- .decorated_directory = > | dd | {
1135
+ .uncached_decorated_lazy_path , . decorated_directory = > | dd | {
1079
1136
const file_path = dd .lazy_path .getPath3 (b , step );
1080
1137
try argv_list .append (arena , b .fmt ("{s}{s}{s}" , .{ dd .prefix , run .convertPathArg (file_path ), dd .suffix }));
1081
1138
},
0 commit comments