| ... | ... | @@ -138,7 +138,7 @@ pub const StdIo = union(enum) { |
| 138 | 138 | pub const Arg = union(enum) { |
| 139 | 139 | artifact: PrefixedArtifact, |
| 140 | 140 | lazy_path: PrefixedLazyPath, |
| 141 | | directory_source: PrefixedLazyPath, |
| 141 | decorated_directory: DecoratedLazyPath, |
| 142 | 142 | bytes: []u8, |
| 143 | 143 | output_file: *Output, |
| 144 | 144 | output_directory: *Output, |
| ... | ... | @@ -154,6 +154,12 @@ pub const PrefixedLazyPath = struct { |
| 154 | 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 | 163 | pub const Output = struct { |
| 158 | 164 | generated_file: std.Build.GeneratedFile, |
| 159 | 165 | prefix: []const u8, |
| ... | ... | @@ -360,19 +366,33 @@ pub fn addPrefixedOutputDirectoryArg( |
| 360 | 366 | return .{ .generated = .{ .file = &output.generated_file } }; |
| 361 | 367 | } |
| 362 | 368 | |
| 363 | | pub fn addDirectoryArg(run: *Run, directory_source: std.Build.LazyPath) void { |
| 364 | | run.addPrefixedDirectoryArg("", directory_source); |
| 369 | pub fn addDirectoryArg(run: *Run, lazy_directory: std.Build.LazyPath) void { |
| 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 | 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 | 391 | .prefix = b.dupe(prefix), |
| 372 | | .lazy_path = directory_source.dupe(b), |
| 373 | | }; |
| 374 | | run.argv.append(b.allocator, .{ .directory_source = prefixed_directory_source }) catch @panic("OOM"); |
| 375 | | directory_source.addStepDependencies(&run.step); |
| 392 | .lazy_path = lazy_directory.dupe(b), |
| 393 | .suffix = b.dupe(suffix), |
| 394 | } }) catch @panic("OOM"); |
| 395 | lazy_directory.addStepDependencies(&run.step); |
| 376 | 396 | } |
| 377 | 397 | |
| 378 | 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 | 681 | man.hash.addBytes(file.prefix); |
| 662 | 682 | _ = try man.addFile(file_path, null); |
| 663 | 683 | }, |
| 664 | | .directory_source => |file| { |
| 665 | | const file_path = file.lazy_path.getPath2(b, step); |
| 666 | | try argv_list.append(b.fmt("{s}{s}", .{ file.prefix, file_path })); |
| 667 | | man.hash.addBytes(file.prefix); |
| 668 | | man.hash.addBytes(file_path); |
| 684 | .decorated_directory => |dd| { |
| 685 | const file_path = dd.lazy_path.getPath3(b, step); |
| 686 | const resolved_arg = b.fmt("{s}{}{s}", .{ dd.prefix, file_path, dd.suffix }); |
| 687 | try argv_list.append(resolved_arg); |
| 688 | man.hash.addBytes(resolved_arg); |
| 669 | 689 | }, |
| 670 | 690 | .artifact => |pa| { |
| 671 | 691 | const artifact = pa.artifact; |
| ... | ... | @@ -882,9 +902,9 @@ pub fn rerunInFuzzMode( |
| 882 | 902 | const file_path = file.lazy_path.getPath2(b, step); |
| 883 | 903 | try argv_list.append(arena, b.fmt("{s}{s}", .{ file.prefix, file_path })); |
| 884 | 904 | }, |
| 885 | | .directory_source => |file| { |
| 886 | | const file_path = file.lazy_path.getPath2(b, step); |
| 887 | | try argv_list.append(arena, b.fmt("{s}{s}", .{ file.prefix, file_path })); |
| 905 | .decorated_directory => |dd| { |
| 906 | const file_path = dd.lazy_path.getPath3(b, step); |
| 907 | try argv_list.append(arena, b.fmt("{s}{}{s}", .{ dd.prefix, file_path, dd.suffix })); |
| 888 | 908 | }, |
| 889 | 909 | .artifact => |pa| { |
| 890 | 910 | const artifact = pa.artifact; |