| author | |
| committer | |
| log | d95dcb2a6238787e18c60f4ae4bfcf8fd757bd0c |
| tree | 3d675be046988c9f65047fb7ed834e839dba1b8d |
| parent | a078d55a25ec503158b1b1dfbdfdec2d0fec86aa |
This function can be used to prepend a list of arguments when running a
test step. Instead, the additional arguments should be manually added to
the run step which can handle a broader set of use cases.5 files changed, 2 insertions(+), 41 deletions(-)
lib/compiler/Maker/Step/Compile.zig-12| ... | ... | @@ -769,18 +769,6 @@ fn lowerZigArgs( |
| 769 | 769 | try zig_args.append(gpa, if (enabled) "--enable-new-dtags" else "--disable-new-dtags"); |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | if (conf_comp.flags3.kind == .@"test" and conf_comp.exec_cmd_args.slice.len != 0) { | |
| 773 | for (conf_comp.exec_cmd_args.slice) |cmd_arg| { | |
| 774 | try zig_args.ensureUnusedCapacity(gpa, 2); | |
| 775 | if (cmd_arg.slice(conf)) |arg| { | |
| 776 | zig_args.appendAssumeCapacity("--test-cmd"); | |
| 777 | zig_args.appendAssumeCapacity(arg); | |
| 778 | } else { | |
| 779 | zig_args.appendAssumeCapacity("--test-cmd-bin"); | |
| 780 | } | |
| 781 | } | |
| 782 | } | |
| 783 | ||
| 784 | 772 | if (graph.sysroot) |sysroot| try zig_args.appendSlice(gpa, &.{ "--sysroot", sysroot }); |
| 785 | 773 | |
| 786 | 774 | // -I and -L arguments that appear after the last --mod argument apply to all modules. |
lib/compiler/configurer.zig-3| ... | ... | @@ -676,7 +676,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void { |
| 676 | 676 | }, |
| 677 | 677 | .compile => e: { |
| 678 | 678 | const c: *Step.Compile = @fieldParentPtr("step", step); |
| 679 | const exec_cmd_args: []const ?[]const u8 = c.exec_cmd_args orelse &.{}; | |
| 680 | 679 | const installed_headers: []u32 = try arena.alloc(u32, c.installed_headers.items.len); |
| 681 | 680 | for (installed_headers, c.installed_headers.items) |*dst, src| switch (src) { |
| 682 | 681 | .file => |file| { |
| ... | ... | @@ -703,7 +702,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void { |
| 703 | 702 | break :e try wc.addExtraErased(Configuration.Step.Compile, .{ |
| 704 | 703 | .flags = .{ |
| 705 | 704 | .filters_len = c.filters.len != 0, |
| 706 | .exec_cmd_args_len = exec_cmd_args.len != 0, | |
| 707 | 705 | .installed_headers_len = installed_headers.len != 0, |
| 708 | 706 | .force_undefined_symbols_len = c.force_undefined_symbols.entries.len != 0, |
| 709 | 707 | |
| ... | ... | @@ -837,7 +835,6 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void { |
| 837 | 835 | .none, .fast, .uuid, .sha1, .md5 => null, |
| 838 | 836 | } else null }, |
| 839 | 837 | .filters = .{ .slice = try s.initStringList(c.filters) }, |
| 840 | .exec_cmd_args = .{ .slice = try s.initOptionalStringList(exec_cmd_args) }, | |
| 841 | 838 | .installed_headers = .initErased(installed_headers), |
| 842 | 839 | .force_undefined_symbols = .{ .slice = try s.initStringList(c.force_undefined_symbols.keys()) }, |
| 843 | 840 | .expect_errors = .{ .u = if (c.expect_errors) |x| switch (x) { |
lib/std/Build.zig+1-11| ... | ... | @@ -898,17 +898,7 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run { |
| 898 | 898 | const run_step = Step.Run.create(b, step_name); |
| 899 | 899 | run_step.producer = exe; |
| 900 | 900 | if (exe.kind == .@"test") { |
| 901 | if (exe.exec_cmd_args) |exec_cmd_args| { | |
| 902 | for (exec_cmd_args) |cmd_arg| { | |
| 903 | if (cmd_arg) |arg| { | |
| 904 | run_step.addArg(arg); | |
| 905 | } else { | |
| 906 | run_step.addArtifactArg(exe); | |
| 907 | } | |
| 908 | } | |
| 909 | } else { | |
| 910 | run_step.addArtifactArg(exe); | |
| 911 | } | |
| 901 | run_step.addArtifactArg(exe); | |
| 912 | 902 | |
| 913 | 903 | const test_server_mode: bool = s: { |
| 914 | 904 | if (exe.test_runner) |r| break :s r.mode == .server; |
lib/std/Build/Configuration.zig+1-2| ... | ... | @@ -698,7 +698,6 @@ pub const Step = extern struct { |
| 698 | 698 | root_name: String, |
| 699 | 699 | |
| 700 | 700 | filters: Storage.FlagLengthPrefixedList(.flags, .filters_len, String), |
| 701 | exec_cmd_args: Storage.FlagLengthPrefixedList(.flags, .exec_cmd_args_len, OptionalString), | |
| 702 | 701 | installed_headers: Storage.FlagLengthPrefixedList(.flags, .installed_headers_len, Storage.Extended(InstalledHeader.Flags, InstalledHeader)), |
| 703 | 702 | force_undefined_symbols: Storage.FlagLengthPrefixedList(.flags, .force_undefined_symbols_len, String), |
| 704 | 703 | expect_errors: Storage.FlagUnion(.flags4, .expect_errors, ExpectErrors), |
| ... | ... | @@ -927,7 +926,6 @@ pub const Step = extern struct { |
| 927 | 926 | tag: Tag = .compile, |
| 928 | 927 | |
| 929 | 928 | filters_len: bool, |
| 930 | exec_cmd_args_len: bool, | |
| 931 | 929 | installed_headers_len: bool, |
| 932 | 930 | force_undefined_symbols_len: bool, |
| 933 | 931 | |
| ... | ... | @@ -954,6 +952,7 @@ pub const Step = extern struct { |
| 954 | 952 | force_load_objc: bool, |
| 955 | 953 | discard_local_symbols: bool, |
| 956 | 954 | mingw_unicode_entry_point: bool, |
| 955 | _: u1 = 0, | |
| 957 | 956 | }; |
| 958 | 957 | |
| 959 | 958 | pub const Flags2 = packed struct(u32) { |
lib/std/Build/Step/Compile.zig-13| ... | ... | @@ -51,7 +51,6 @@ shared_memory: bool = false, |
| 51 | 51 | global_base: ?u64 = null, |
| 52 | 52 | /// Set via options; intended to be read-only after that. |
| 53 | 53 | zig_lib_dir: ?LazyPath, |
| 54 | exec_cmd_args: ?[]const ?[]const u8, | |
| 55 | 54 | filters: []const []const u8, |
| 56 | 55 | test_runner: ?TestRunner, |
| 57 | 56 | wasi_exec_model: ?std.builtin.WasiExecModel = null, |
| ... | ... | @@ -419,7 +418,6 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 419 | 418 | .out_filename = out_filename, |
| 420 | 419 | .installed_headers = .empty, |
| 421 | 420 | .zig_lib_dir = null, |
| 422 | .exec_cmd_args = null, | |
| 423 | 421 | .filters = options.filters, |
| 424 | 422 | .test_runner = null, // set below |
| 425 | 423 | .rdynamic = false, |
| ... | ... | @@ -736,17 +734,6 @@ pub fn getEmittedLlvmBc(compile: *Compile) LazyPath { |
| 736 | 734 | return compile.getEmittedFileGeneric(&compile.generated_llvm_bc); |
| 737 | 735 | } |
| 738 | 736 | |
| 739 | pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void { | |
| 740 | const graph = compile.step.owner.graph; | |
| 741 | const arena = graph.arena; | |
| 742 | assert(compile.kind == .@"test"); | |
| 743 | const duped_args = arena.alloc(?[]const u8, args.len) catch @panic("OOM"); | |
| 744 | for (args, 0..) |arg, i| { | |
| 745 | duped_args[i] = if (arg) |a| graph.dupeString(a) else null; | |
| 746 | } | |
| 747 | compile.exec_cmd_args = duped_args; | |
| 748 | } | |
| 749 | ||
| 750 | 737 | pub fn rootModuleTarget(c: *Compile) std.Target { |
| 751 | 738 | // The root module is always given a target, so we know this to be non-null. |
| 752 | 739 | return c.root_module.resolved_target.?.result; |