@@ -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` as you need to pass the cache directory
145
+ // without caching it.
146
+ uncached_decorated_directory : 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 .addUncachedPrefixedDirectoryArg ("--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,25 @@ pub fn addDecoratedDirectoryArg(
472
475
lazy_directory .addStepDependencies (& run .step );
473
476
}
474
477
478
+ fn addUncachedPrefixedDirectoryArg (run : * Run , prefix : []const u8 , lazy_directory : std.Build.LazyPath ) void {
479
+ run .addUncachedDecoratedDirectoryArg (prefix , lazy_directory , "" );
480
+ }
481
+
482
+ fn addUncachedDecoratedDirectoryArg (
483
+ run : * Run ,
484
+ prefix : []const u8 ,
485
+ lazy_directory : std.Build.LazyPath ,
486
+ suffix : []const u8 ,
487
+ ) void {
488
+ const b = run .step .owner ;
489
+ run .argv .append (b .allocator , .{ .uncached_decorated_directory = .{
490
+ .prefix = b .dupe (prefix ),
491
+ .lazy_path = lazy_directory .dupe (b ),
492
+ .suffix = b .dupe (suffix ),
493
+ } }) catch @panic ("OOM" );
494
+ lazy_directory .addStepDependencies (& run .step );
495
+ }
496
+
475
497
/// Add a path argument to a dep file (.d) for the child process to write its
476
498
/// discovered additional dependencies.
477
499
/// Only one dep file argument is allowed by instance.
@@ -542,7 +564,7 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
542
564
}
543
565
break :use_wine std .mem .endsWith (u8 , p .lazy_path .basename (b , & run .step ), ".exe" );
544
566
},
545
- .decorated_directory = > false ,
567
+ .uncached_decorated_directory , . decorated_directory = > false ,
546
568
.file_content = > unreachable , // not allowed as first arg
547
569
.bytes = > | bytes | std .mem .endsWith (u8 , bytes , ".exe" ),
548
570
.output_file , .output_directory = > false ,
@@ -809,11 +831,42 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
809
831
man .hash .addBytes (file .prefix );
810
832
_ = try man .addFilePath (file_path , null );
811
833
},
834
+ .uncached_decorated_directory = > | dd | {
835
+ const src_dir_path = dd .lazy_path .getPath3 (b , step );
836
+ try argv_list .append (b .fmt ("{s}{s}{s}" , .{ dd .prefix , run .convertPathArg (src_dir_path ), dd .suffix }));
837
+ },
812
838
.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 );
839
+ const src_dir_path = dd .lazy_path .getPath3 (b , step );
840
+ try argv_list .append (b .fmt ("{s}{s}{s}" , .{ dd .prefix , run .convertPathArg (src_dir_path ), dd .suffix }));
841
+ man .hash .addBytes (dd .prefix );
842
+ man .hash .addBytes (dd .suffix );
843
+
844
+ const need_derived_inputs = try step .addDirectoryWatchInput (dd .lazy_path );
845
+
846
+ var src_dir = src_dir_path .root_dir .handle .openDir (src_dir_path .subPathOrDot (), .{ .iterate = true }) catch | err | {
847
+ return step .fail ("unable to open source directory '{f}': {s}" , .{
848
+ src_dir_path , @errorName (err ),
849
+ });
850
+ };
851
+
852
+ var it = try src_dir .walk (arena );
853
+ defer it .deinit ();
854
+
855
+ while (try it .next ()) | entry | {
856
+ switch (entry .kind ) {
857
+ .directory = > {
858
+ if (need_derived_inputs ) {
859
+ const entry_path = try src_dir_path .join (arena , entry .path );
860
+ try step .addDirectoryWatchInputFromPath (entry_path );
861
+ }
862
+ },
863
+ .file = > {
864
+ const entry_path = try src_dir_path .join (arena , entry .path );
865
+ _ = try man .addFilePath (entry_path , null );
866
+ },
867
+ else = > continue ,
868
+ }
869
+ }
817
870
},
818
871
.file_content = > | file_plp | {
819
872
const file_path = file_plp .lazy_path .getPath3 (b , step );
@@ -1075,7 +1128,7 @@ pub fn rerunInFuzzMode(
1075
1128
const file_path = file .lazy_path .getPath3 (b , step );
1076
1129
try argv_list .append (arena , b .fmt ("{s}{s}" , .{ file .prefix , run .convertPathArg (file_path ) }));
1077
1130
},
1078
- .decorated_directory = > | dd | {
1131
+ .uncached_decorated_directory , . decorated_directory = > | dd | {
1079
1132
const file_path = dd .lazy_path .getPath3 (b , step );
1080
1133
try argv_list .append (arena , b .fmt ("{s}{s}{s}" , .{ dd .prefix , run .convertPathArg (file_path ), dd .suffix }));
1081
1134
},
0 commit comments