| ... | @@ -138,7 +138,7 @@ pub const StdIo = union(enum) { | ... | @@ -138,7 +138,7 @@ pub const StdIo = union(enum) { |
| 138 | pub const Arg = union(enum) { | 138 | pub const Arg = union(enum) { |
| 139 | artifact: PrefixedArtifact, | 139 | artifact: PrefixedArtifact, |
| 140 | lazy_path: PrefixedLazyPath, | 140 | lazy_path: PrefixedLazyPath, |
| 141 | directory_source: PrefixedLazyPath, | 141 | decorated_directory: DecoratedLazyPath, |
| 142 | bytes: []u8, | 142 | bytes: []u8, |
| 143 | output_file: *Output, | 143 | output_file: *Output, |
| 144 | output_directory: *Output, | 144 | output_directory: *Output, |
| ... | @@ -154,6 +154,12 @@ pub const PrefixedLazyPath = struct { | ... | @@ -154,6 +154,12 @@ pub const PrefixedLazyPath = struct { |
| 154 | lazy_path: std.Build.LazyPath, | 154 | lazy_path: std.Build.LazyPath, |
| 155 | }; | 155 | }; |
| 156 | | 156 | |
| | 157 | pub const DecoratedLazyPath = struct { |
| | 158 | prefix: []const u8, |
| | 159 | lazy_path: std.Build.LazyPath, |
| | 160 | suffix: []const u8, |
| | 161 | }; |
| | 162 | |
| 157 | pub const Output = struct { | 163 | pub const Output = struct { |
| 158 | generated_file: std.Build.GeneratedFile, | 164 | generated_file: std.Build.GeneratedFile, |
| 159 | prefix: []const u8, | 165 | prefix: []const u8, |
| ... | @@ -360,19 +366,33 @@ pub fn addPrefixedOutputDirectoryArg( | ... | @@ -360,19 +366,33 @@ pub fn addPrefixedOutputDirectoryArg( |
| 360 | return .{ .generated = .{ .file = &output.generated_file } }; | 366 | return .{ .generated = .{ .file = &output.generated_file } }; |
| 361 | } | 367 | } |
| 362 | | 368 | |
| 363 | pub fn addDirectoryArg(run: *Run, directory_source: std.Build.LazyPath) void { | 369 | pub fn addDirectoryArg(run: *Run, lazy_directory: std.Build.LazyPath) void { |
| 364 | run.addPrefixedDirectoryArg("", directory_source); | 370 | run.addDecoratedDirectoryArg("", lazy_directory, ""); |
| 365 | } | 371 | } |
| 366 | | 372 | |
| 367 | pub fn addPrefixedDirectoryArg(run: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void { | 373 | pub fn addPrefixedDirectoryArg(run: *Run, prefix: []const u8, lazy_directory: std.Build.LazyPath) void { |
| 368 | const b = run.step.owner; | 374 | const b = run.step.owner; |
| | 375 | run.argv.append(b.allocator, .{ .decorated_directory = .{ |
| | 376 | .prefix = b.dupe(prefix), |
| | 377 | .lazy_path = lazy_directory.dupe(b), |
| | 378 | .suffix = "", |
| | 379 | } }) catch @panic("OOM"); |
| | 380 | lazy_directory.addStepDependencies(&run.step); |
| | 381 | } |
| 369 | | 382 | |
| 370 | const prefixed_directory_source: PrefixedLazyPath = .{ | 383 | pub fn addDecoratedDirectoryArg( |
| | 384 | run: *Run, |
| | 385 | prefix: []const u8, |
| | 386 | lazy_directory: std.Build.LazyPath, |
| | 387 | suffix: []const u8, |
| | 388 | ) void { |
| | 389 | const b = run.step.owner; |
| | 390 | run.argv.append(b.allocator, .{ .decorated_directory = .{ |
| 371 | .prefix = b.dupe(prefix), | 391 | .prefix = b.dupe(prefix), |
| 372 | .lazy_path = directory_source.dupe(b), | 392 | .lazy_path = lazy_directory.dupe(b), |
| 373 | }; | 393 | .suffix = b.dupe(suffix), |
| 374 | run.argv.append(b.allocator, .{ .directory_source = prefixed_directory_source }) catch @panic("OOM"); | 394 | } }) catch @panic("OOM"); |
| 375 | directory_source.addStepDependencies(&run.step); | 395 | lazy_directory.addStepDependencies(&run.step); |
| 376 | } | 396 | } |
| 377 | | 397 | |
| 378 | /// Add a path argument to a dep file (.d) for the child process to write its | 398 | /// Add a path argument to a dep file (.d) for the child process to write its |
| ... | @@ -661,11 +681,11 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -661,11 +681,11 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 661 | man.hash.addBytes(file.prefix); | 681 | man.hash.addBytes(file.prefix); |
| 662 | _ = try man.addFile(file_path, null); | 682 | _ = try man.addFile(file_path, null); |
| 663 | }, | 683 | }, |
| 664 | .directory_source => |file| { | 684 | .decorated_directory => |dd| { |
| 665 | const file_path = file.lazy_path.getPath2(b, step); | 685 | const file_path = dd.lazy_path.getPath3(b, step); |
| 666 | try argv_list.append(b.fmt("{s}{s}", .{ file.prefix, file_path })); | 686 | const resolved_arg = b.fmt("{s}{}{s}", .{ dd.prefix, file_path, dd.suffix }); |
| 667 | man.hash.addBytes(file.prefix); | 687 | try argv_list.append(resolved_arg); |
| 668 | man.hash.addBytes(file_path); | 688 | man.hash.addBytes(resolved_arg); |
| 669 | }, | 689 | }, |
| 670 | .artifact => |pa| { | 690 | .artifact => |pa| { |
| 671 | const artifact = pa.artifact; | 691 | const artifact = pa.artifact; |
| ... | @@ -882,9 +902,9 @@ pub fn rerunInFuzzMode( | ... | @@ -882,9 +902,9 @@ pub fn rerunInFuzzMode( |
| 882 | const file_path = file.lazy_path.getPath2(b, step); | 902 | const file_path = file.lazy_path.getPath2(b, step); |
| 883 | try argv_list.append(arena, b.fmt("{s}{s}", .{ file.prefix, file_path })); | 903 | try argv_list.append(arena, b.fmt("{s}{s}", .{ file.prefix, file_path })); |
| 884 | }, | 904 | }, |
| 885 | .directory_source => |file| { | 905 | .decorated_directory => |dd| { |
| 886 | const file_path = file.lazy_path.getPath2(b, step); | 906 | const file_path = dd.lazy_path.getPath3(b, step); |
| 887 | try argv_list.append(arena, b.fmt("{s}{s}", .{ file.prefix, file_path })); | 907 | try argv_list.append(arena, b.fmt("{s}{}{s}", .{ dd.prefix, file_path, dd.suffix })); |
| 888 | }, | 908 | }, |
| 889 | .artifact => |pa| { | 909 | .artifact => |pa| { |
| 890 | const artifact = pa.artifact; | 910 | const artifact = pa.artifact; |