| author | |
| committer | |
| log | 127e2d8088a37b439ce087f2d58f544b9248dc02 |
| tree | e97fe7d8c0f2233e5681ad0af352be523b839812 |
| parent | 5228c8902fe178834f678cb5bec12a5a32d5df2f |
This provides a way to forward, e.g. the `-fqemu` argument from
`zig build` to a child process during Maker execution without providing
the information to the configuration logic.5 files changed, 193 insertions(+), 4 deletions(-)
lib/compiler/Maker/Step/Run.zig+33| ... | @@ -187,6 +187,11 @@ pub fn make( | ... | @@ -187,6 +187,11 @@ pub fn make( |
| 187 | man.hash.addListOfBytes(run_args); | 187 | man.hash.addListOfBytes(run_args); |
| 188 | } | 188 | } |
| 189 | }, | 189 | }, |
| 190 | .enable_darling => thirdPartyToggle(&man.hash, &argv_list, conf, graph.enable_darling, arg.prefix.value, arg.suffix.value), | ||
| 191 | .enable_qemu => thirdPartyToggle(&man.hash, &argv_list, conf, graph.enable_qemu, arg.prefix.value, arg.suffix.value), | ||
| 192 | .enable_rosetta => thirdPartyToggle(&man.hash, &argv_list, conf, graph.enable_rosetta, arg.prefix.value, arg.suffix.value), | ||
| 193 | .enable_wasmtime => thirdPartyToggle(&man.hash, &argv_list, conf, graph.enable_wasmtime, arg.prefix.value, arg.suffix.value), | ||
| 194 | .enable_wine => thirdPartyToggle(&man.hash, &argv_list, conf, graph.enable_wine, arg.prefix.value, arg.suffix.value), | ||
| 190 | } | 195 | } |
| 191 | } | 196 | } |
| 192 | 197 | ||
| ... | @@ -351,6 +356,29 @@ pub fn make( | ... | @@ -351,6 +356,29 @@ pub fn make( |
| 351 | step.clearFailedCommand(gpa); | 356 | step.clearFailedCommand(gpa); |
| 352 | } | 357 | } |
| 353 | 358 | ||
| 359 | fn thirdPartyToggle( | ||
| 360 | man_hash: ?*Cache.HashHelper, | ||
| 361 | argv_list: *std.ArrayList([]const u8), | ||
| 362 | conf: *const Configuration, | ||
| 363 | setting: bool, | ||
| 364 | enable: ?Configuration.String, | ||
| 365 | disable: ?Configuration.String, | ||
| 366 | ) void { | ||
| 367 | if (setting) { | ||
| 368 | if (enable) |string| { | ||
| 369 | const slice = string.slice(conf); | ||
| 370 | if (man_hash) |h| h.addBytesZ(slice); | ||
| 371 | argv_list.appendAssumeCapacity(slice); | ||
| 372 | } | ||
| 373 | } else { | ||
| 374 | if (disable) |string| { | ||
| 375 | const slice = string.slice(conf); | ||
| 376 | if (man_hash) |h| h.addBytesZ(slice); | ||
| 377 | argv_list.appendAssumeCapacity(slice); | ||
| 378 | } | ||
| 379 | } | ||
| 380 | } | ||
| 381 | |||
| 354 | /// Reads stdout of a Zig test process until a termination condition is reached: | 382 | /// Reads stdout of a Zig test process until a termination condition is reached: |
| 355 | /// * A write fails, indicating the child unexpectedly closed stdin | 383 | /// * A write fails, indicating the child unexpectedly closed stdin |
| 356 | /// * A test (or a response from the test runner) times out | 384 | /// * A test (or a response from the test runner) times out |
| ... | @@ -1535,6 +1563,11 @@ pub fn rerunInFuzzMode( | ... | @@ -1535,6 +1563,11 @@ pub fn rerunInFuzzMode( |
| 1535 | .output_file => unreachable, | 1563 | .output_file => unreachable, |
| 1536 | .output_directory => unreachable, | 1564 | .output_directory => unreachable, |
| 1537 | .passthru => unreachable, | 1565 | .passthru => unreachable, |
| 1566 | .enable_darling => thirdPartyToggle(null, &argv_list, conf, graph.enable_darling, arg.prefix.value, arg.suffix.value), | ||
| 1567 | .enable_qemu => thirdPartyToggle(null, &argv_list, conf, graph.enable_qemu, arg.prefix.value, arg.suffix.value), | ||
| 1568 | .enable_rosetta => thirdPartyToggle(null, &argv_list, conf, graph.enable_rosetta, arg.prefix.value, arg.suffix.value), | ||
| 1569 | .enable_wasmtime => thirdPartyToggle(null, &argv_list, conf, graph.enable_wasmtime, arg.prefix.value, arg.suffix.value), | ||
| 1570 | .enable_wine => thirdPartyToggle(null, &argv_list, conf, graph.enable_wine, arg.prefix.value, arg.suffix.value), | ||
| 1538 | } | 1571 | } |
| 1539 | } | 1572 | } |
| 1540 | 1573 |
lib/std/Build/Configuration.zig+7| ... | @@ -626,6 +626,13 @@ pub const Step = extern struct { | ... | @@ -626,6 +626,13 @@ pub const Step = extern struct { |
| 626 | output_file, | 626 | output_file, |
| 627 | output_directory, | 627 | output_directory, |
| 628 | passthru, | 628 | passthru, |
| 629 | /// `prefix` contains the enabled string. | ||
| 630 | /// `suffix` contains the disabled string. | ||
| 631 | enable_darling, | ||
| 632 | enable_qemu, | ||
| 633 | enable_rosetta, | ||
| 634 | enable_wasmtime, | ||
| 635 | enable_wine, | ||
| 629 | }; | 636 | }; |
| 630 | 637 | ||
| 631 | pub const Index = IndexType(@This()); | 638 | pub const Index = IndexType(@This()); |
lib/std/Build/Serialize.zig+95| ... | @@ -1017,6 +1017,101 @@ fn initArgsList(s: *Serialize, args: []const Step.Run.Arg) ![]const Configuratio | ... | @@ -1017,6 +1017,101 @@ fn initArgsList(s: *Serialize, args: []const Step.Run.Arg) ![]const Configuratio |
| 1017 | .producer = .{ .value = null }, | 1017 | .producer = .{ .value = null }, |
| 1018 | .generated = .{ .value = null }, | 1018 | .generated = .{ .value = null }, |
| 1019 | }, | 1019 | }, |
| 1020 | .enable_darling => |a| .{ | ||
| 1021 | .flags = .{ | ||
| 1022 | .tag = .enable_darling, | ||
| 1023 | .prefix = a.enabled != null, | ||
| 1024 | .suffix = a.disabled != null, | ||
| 1025 | .basename = false, | ||
| 1026 | .path = false, | ||
| 1027 | .producer = false, | ||
| 1028 | .generated = false, | ||
| 1029 | .dep_file = false, | ||
| 1030 | .make_absolute = false, | ||
| 1031 | }, | ||
| 1032 | .prefix = .{ .value = try s.addOptionalString(a.enabled) }, | ||
| 1033 | .suffix = .{ .value = try s.addOptionalString(a.disabled) }, | ||
| 1034 | .basename = .{ .value = null }, | ||
| 1035 | .path = .{ .value = null }, | ||
| 1036 | .producer = .{ .value = null }, | ||
| 1037 | .generated = .{ .value = null }, | ||
| 1038 | }, | ||
| 1039 | .enable_qemu => |a| .{ | ||
| 1040 | .flags = .{ | ||
| 1041 | .tag = .enable_qemu, | ||
| 1042 | .prefix = a.enabled != null, | ||
| 1043 | .suffix = a.disabled != null, | ||
| 1044 | .basename = false, | ||
| 1045 | .path = false, | ||
| 1046 | .producer = false, | ||
| 1047 | .generated = false, | ||
| 1048 | .dep_file = false, | ||
| 1049 | .make_absolute = false, | ||
| 1050 | }, | ||
| 1051 | .prefix = .{ .value = try s.addOptionalString(a.enabled) }, | ||
| 1052 | .suffix = .{ .value = try s.addOptionalString(a.disabled) }, | ||
| 1053 | .basename = .{ .value = null }, | ||
| 1054 | .path = .{ .value = null }, | ||
| 1055 | .producer = .{ .value = null }, | ||
| 1056 | .generated = .{ .value = null }, | ||
| 1057 | }, | ||
| 1058 | .enable_rosetta => |a| .{ | ||
| 1059 | .flags = .{ | ||
| 1060 | .tag = .enable_rosetta, | ||
| 1061 | .prefix = a.enabled != null, | ||
| 1062 | .suffix = a.disabled != null, | ||
| 1063 | .basename = false, | ||
| 1064 | .path = false, | ||
| 1065 | .producer = false, | ||
| 1066 | .generated = false, | ||
| 1067 | .dep_file = false, | ||
| 1068 | .make_absolute = false, | ||
| 1069 | }, | ||
| 1070 | .prefix = .{ .value = try s.addOptionalString(a.enabled) }, | ||
| 1071 | .suffix = .{ .value = try s.addOptionalString(a.disabled) }, | ||
| 1072 | .basename = .{ .value = null }, | ||
| 1073 | .path = .{ .value = null }, | ||
| 1074 | .producer = .{ .value = null }, | ||
| 1075 | .generated = .{ .value = null }, | ||
| 1076 | }, | ||
| 1077 | .enable_wasmtime => |a| .{ | ||
| 1078 | .flags = .{ | ||
| 1079 | .tag = .enable_wasmtime, | ||
| 1080 | .prefix = a.enabled != null, | ||
| 1081 | .suffix = a.disabled != null, | ||
| 1082 | .basename = false, | ||
| 1083 | .path = false, | ||
| 1084 | .producer = false, | ||
| 1085 | .generated = false, | ||
| 1086 | .dep_file = false, | ||
| 1087 | .make_absolute = false, | ||
| 1088 | }, | ||
| 1089 | .prefix = .{ .value = try s.addOptionalString(a.enabled) }, | ||
| 1090 | .suffix = .{ .value = try s.addOptionalString(a.disabled) }, | ||
| 1091 | .basename = .{ .value = null }, | ||
| 1092 | .path = .{ .value = null }, | ||
| 1093 | .producer = .{ .value = null }, | ||
| 1094 | .generated = .{ .value = null }, | ||
| 1095 | }, | ||
| 1096 | .enable_wine => |a| .{ | ||
| 1097 | .flags = .{ | ||
| 1098 | .tag = .enable_wine, | ||
| 1099 | .prefix = a.enabled != null, | ||
| 1100 | .suffix = a.disabled != null, | ||
| 1101 | .basename = false, | ||
| 1102 | .path = false, | ||
| 1103 | .producer = false, | ||
| 1104 | .generated = false, | ||
| 1105 | .dep_file = false, | ||
| 1106 | .make_absolute = false, | ||
| 1107 | }, | ||
| 1108 | .prefix = .{ .value = try s.addOptionalString(a.enabled) }, | ||
| 1109 | .suffix = .{ .value = try s.addOptionalString(a.disabled) }, | ||
| 1110 | .basename = .{ .value = null }, | ||
| 1111 | .path = .{ .value = null }, | ||
| 1112 | .producer = .{ .value = null }, | ||
| 1113 | .generated = .{ .value = null }, | ||
| 1114 | }, | ||
| 1020 | }); | 1115 | }); |
| 1021 | } | 1116 | } |
| 1022 | return result; | 1117 | return result; |
lib/std/Build/Step/Run.zig+53| ... | @@ -151,6 +151,19 @@ pub const Arg = union(enum) { | ... | @@ -151,6 +151,19 @@ pub const Arg = union(enum) { |
| 151 | output_directory: *Output, | 151 | output_directory: *Output, |
| 152 | /// The arguments passed after "--" on the "zig build" CLI. | 152 | /// The arguments passed after "--" on the "zig build" CLI. |
| 153 | passthru, | 153 | passthru, |
| 154 | |||
| 155 | enable_darling: ToggleFlags, | ||
| 156 | enable_qemu: ToggleFlags, | ||
| 157 | enable_rosetta: ToggleFlags, | ||
| 158 | enable_wasmtime: ToggleFlags, | ||
| 159 | enable_wine: ToggleFlags, | ||
| 160 | }; | ||
| 161 | |||
| 162 | pub const ToggleFlags = struct { | ||
| 163 | /// The string to pass when enabled, or null to omit the arg. | ||
| 164 | enabled: ?[]const u8 = null, | ||
| 165 | /// The string to pass when disabled, or null to omit the arg. | ||
| 166 | disabled: ?[]const u8 = null, | ||
| 154 | }; | 167 | }; |
| 155 | 168 | ||
| 156 | pub const DecoratedArtifact = struct { | 169 | pub const DecoratedArtifact = struct { |
| ... | @@ -578,6 +591,46 @@ pub fn addPassthruArgs(run: *Run) void { | ... | @@ -578,6 +591,46 @@ pub fn addPassthruArgs(run: *Run) void { |
| 578 | run.argv.append(arena, .passthru) catch @panic("OOM"); | 591 | run.argv.append(arena, .passthru) catch @panic("OOM"); |
| 579 | } | 592 | } |
| 580 | 593 | ||
| 594 | /// Appends a custom string to the command line depending on the `-fdarling` | ||
| 595 | /// value passed to `zig build`. | ||
| 596 | pub fn addThirdPartyEnabledArgDarling(run: *Run, toggle_flags: ToggleFlags) void { | ||
| 597 | const graph = run.step.owner.graph; | ||
| 598 | const arena = graph.arena; | ||
| 599 | run.argv.append(arena, .{ .enable_darling = toggle_flags }) catch @panic("OOM"); | ||
| 600 | } | ||
| 601 | |||
| 602 | /// Appends a custom string to the command line depending on the `-fqemu` | ||
| 603 | /// value passed to `zig build`. | ||
| 604 | pub fn addThirdPartyEnabledArgQemu(run: *Run, toggle_flags: ToggleFlags) void { | ||
| 605 | const graph = run.step.owner.graph; | ||
| 606 | const arena = graph.arena; | ||
| 607 | run.argv.append(arena, .{ .enable_qemu = toggle_flags }) catch @panic("OOM"); | ||
| 608 | } | ||
| 609 | |||
| 610 | /// Appends a custom string to the command line depending on the `-frosetta` | ||
| 611 | /// value passed to `zig build`. | ||
| 612 | pub fn addThirdPartyEnabledArgRosetta(run: *Run, toggle_flags: ToggleFlags) void { | ||
| 613 | const graph = run.step.owner.graph; | ||
| 614 | const arena = graph.arena; | ||
| 615 | run.argv.append(arena, .{ .enable_rosetta = toggle_flags }) catch @panic("OOM"); | ||
| 616 | } | ||
| 617 | |||
| 618 | /// Appends a custom string to the command line depending on the `-fwasmtime` | ||
| 619 | /// value passed to `zig build`. | ||
| 620 | pub fn addThirdPartyEnabledArgWasmtime(run: *Run, toggle_flags: ToggleFlags) void { | ||
| 621 | const graph = run.step.owner.graph; | ||
| 622 | const arena = graph.arena; | ||
| 623 | run.argv.append(arena, .{ .enable_wasmtime = toggle_flags }) catch @panic("OOM"); | ||
| 624 | } | ||
| 625 | |||
| 626 | /// Appends a custom string to the command line depending on the `-fwine` | ||
| 627 | /// value passed to `zig build`. | ||
| 628 | pub fn addThirdPartyEnabledArgWine(run: *Run, toggle_flags: ToggleFlags) void { | ||
| 629 | const graph = run.step.owner.graph; | ||
| 630 | const arena = graph.arena; | ||
| 631 | run.argv.append(arena, .{ .enable_wine = toggle_flags }) catch @panic("OOM"); | ||
| 632 | } | ||
| 633 | |||
| 581 | pub fn setStdIn(run: *Run, stdin: StdIn) void { | 634 | pub fn setStdIn(run: *Run, stdin: StdIn) void { |
| 582 | switch (stdin) { | 635 | switch (stdin) { |
| 583 | .lazy_path => |lazy_path| lazy_path.addStepDependencies(&run.step), | 636 | .lazy_path => |lazy_path| lazy_path.addStepDependencies(&run.step), |
test/tests.zig+5-4| ... | @@ -3409,10 +3409,11 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons | ... | @@ -3409,10 +3409,11 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons |
| 3409 | 3409 | ||
| 3410 | run.addArg("--quiet"); // don't fill stderr telling us about skipped tests etc | 3410 | run.addArg("--quiet"); // don't fill stderr telling us about skipped tests etc |
| 3411 | 3411 | ||
| 3412 | if (b.enable_qemu) run.addArg("-fqemu"); | 3412 | run.addThirdPartyEnabledArgDarling(.{ .enabled = "-fdarling" }); |
| 3413 | if (b.enable_wine) run.addArg("-fwine"); | 3413 | run.addThirdPartyEnabledArgQemu(.{ .enabled = "-fqemu" }); |
| 3414 | if (b.enable_wasmtime) run.addArg("-fwasmtime"); | 3414 | run.addThirdPartyEnabledArgRosetta(.{ .enabled = "-frosetta" }); |
| 3415 | if (b.enable_darling) run.addArg("-fdarling"); | 3415 | run.addThirdPartyEnabledArgWasmtime(.{ .enabled = "-fwasmtime" }); |
| 3416 | run.addThirdPartyEnabledArgWine(.{ .enabled = "-fwine" }); | ||
| 3416 | 3417 | ||
| 3417 | run.addCheck(.{ .expect_term = .{ .exited = 0 } }); | 3418 | run.addCheck(.{ .expect_term = .{ .exited = 0 } }); |
| 3418 | test_step.dependOn(&run.step); | 3419 | test_step.dependOn(&run.step); |