authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-11 11:40:53-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-11 11:40:53-04:00
log1728d92f60d4e9aa10d878e3235fc63764d3909b
treebe15ce4abc4ffe78efd0b5aaa522124741923ad1
parent23d7921758524f76f2157e6f8a5823da2511396a
parent406706fe6b5e969028a7c70247ebd1cb2b93102d
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #15245 from ziglang/zig-build-install-artifact

fix broken and confusing artifact installation logic

46 files changed, 76 insertions(+), 89 deletions(-)

build.zig+1-1
...@@ -181,7 +181,7 @@ pub fn build(b: *std.Build) !void {...@@ -181,7 +181,7 @@ pub fn build(b: *std.Build) !void {
181 exe.sanitize_thread = sanitize_thread;181 exe.sanitize_thread = sanitize_thread;
182 exe.build_id = b.option(bool, "build-id", "Include a build id note") orelse false;182 exe.build_id = b.option(bool, "build-id", "Include a build id note") orelse false;
183 exe.entitlements = entitlements;183 exe.entitlements = entitlements;
184 exe.install();184 b.installArtifact(exe);
185185
186 const compile_step = b.step("compile", "Build the self-hosted compiler");186 const compile_step = b.step("compile", "Build the self-hosted compiler");
187 compile_step.dependOn(&exe.step);187 compile_step.dependOn(&exe.step);
lib/init-exe/build.zig+8-5
...@@ -27,12 +27,12 @@ pub fn build(b: *std.Build) void {...@@ -27,12 +27,12 @@ pub fn build(b: *std.Build) void {
27 // This declares intent for the executable to be installed into the27 // This declares intent for the executable to be installed into the
28 // standard location when the user invokes the "install" step (the default28 // standard location when the user invokes the "install" step (the default
29 // step when running `zig build`).29 // step when running `zig build`).
30 exe.install();30 b.installArtifact(exe);
3131
32 // This *creates* a RunStep in the build graph, to be executed when another32 // This *creates* a RunStep in the build graph, to be executed when another
33 // step is evaluated that depends on it. The next line below will establish33 // step is evaluated that depends on it. The next line below will establish
34 // such a dependency.34 // such a dependency.
35 const run_cmd = exe.run();35 const run_cmd = b.addRunArtifact(exe);
3636
37 // By making the run step depend on the install step, it will be run from the37 // By making the run step depend on the install step, it will be run from the
38 // installation directory rather than directly from within the cache directory.38 // installation directory rather than directly from within the cache directory.
...@@ -52,16 +52,19 @@ pub fn build(b: *std.Build) void {...@@ -52,16 +52,19 @@ pub fn build(b: *std.Build) void {
52 const run_step = b.step("run", "Run the app");52 const run_step = b.step("run", "Run the app");
53 run_step.dependOn(&run_cmd.step);53 run_step.dependOn(&run_cmd.step);
5454
55 // Creates a step for unit testing.55 // Creates a step for unit testing. This only builds the test executable
56 const exe_tests = b.addTest(.{56 // but does not run it.
57 const unit_tests = b.addTest(.{
57 .root_source_file = .{ .path = "src/main.zig" },58 .root_source_file = .{ .path = "src/main.zig" },
58 .target = target,59 .target = target,
59 .optimize = optimize,60 .optimize = optimize,
60 });61 });
6162
63 const run_unit_tests = b.addRunArtifact(unit_tests);
64
62 // Similar to creating the run step earlier, this exposes a `test` step to65 // Similar to creating the run step earlier, this exposes a `test` step to
63 // the `zig build --help` menu, providing a way for the user to request66 // the `zig build --help` menu, providing a way for the user to request
64 // running the unit tests.67 // running the unit tests.
65 const test_step = b.step("test", "Run unit tests");68 const test_step = b.step("test", "Run unit tests");
66 test_step.dependOn(&exe_tests.step);69 test_step.dependOn(&run_unit_tests.step);
67}70}
lib/init-lib/build.zig+6-3
...@@ -27,18 +27,21 @@ pub fn build(b: *std.Build) void {...@@ -27,18 +27,21 @@ pub fn build(b: *std.Build) void {
27 // This declares intent for the library to be installed into the standard27 // This declares intent for the library to be installed into the standard
28 // location when the user invokes the "install" step (the default step when28 // location when the user invokes the "install" step (the default step when
29 // running `zig build`).29 // running `zig build`).
30 lib.install();30 b.installArtifact(lib);
3131
32 // Creates a step for unit testing.32 // Creates a step for unit testing. This only builds the test executable
33 // but does not run it.
33 const main_tests = b.addTest(.{34 const main_tests = b.addTest(.{
34 .root_source_file = .{ .path = "src/main.zig" },35 .root_source_file = .{ .path = "src/main.zig" },
35 .target = target,36 .target = target,
36 .optimize = optimize,37 .optimize = optimize,
37 });38 });
3839
40 const run_main_tests = b.addRunArtifact(main_tests);
41
39 // This creates a build step. It will be visible in the `zig build --help` menu,42 // This creates a build step. It will be visible in the `zig build --help` menu,
40 // and can be selected like this: `zig build test`43 // and can be selected like this: `zig build test`
41 // This will evaluate the `test` step rather than the default, which is "install".44 // This will evaluate the `test` step rather than the default, which is "install".
42 const test_step = b.step("test", "Run library tests");45 const test_step = b.step("test", "Run library tests");
43 test_step.dependOn(&main_tests.step);46 test_step.dependOn(&run_main_tests.step);
44}47}
lib/std/Build/CompileStep.zig+7-13
...@@ -111,7 +111,6 @@ vcpkg_bin_path: ?[]const u8 = null,...@@ -111,7 +111,6 @@ vcpkg_bin_path: ?[]const u8 = null,
111/// This may be set in order to override the default install directory111/// This may be set in order to override the default install directory
112override_dest_dir: ?InstallDir,112override_dest_dir: ?InstallDir,
113installed_path: ?[]const u8,113installed_path: ?[]const u8,
114install_step: ?*InstallArtifactStep,
115114
116/// Base address for an executable image.115/// Base address for an executable image.
117image_base: ?u64 = null,116image_base: ?u64 = null,
...@@ -390,7 +389,6 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {...@@ -390,7 +389,6 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {
390 .output_dir = null,389 .output_dir = null,
391 .override_dest_dir = null,390 .override_dest_dir = null,
392 .installed_path = null,391 .installed_path = null,
393 .install_step = null,
394 .force_undefined_symbols = StringHashMap(void).init(owner.allocator),392 .force_undefined_symbols = StringHashMap(void).init(owner.allocator),
395393
396 .output_path_source = GeneratedFile{ .step = &self.step },394 .output_path_source = GeneratedFile{ .step = &self.step },
...@@ -465,11 +463,6 @@ pub fn setOutputDir(self: *CompileStep, dir: []const u8) void {...@@ -465,11 +463,6 @@ pub fn setOutputDir(self: *CompileStep, dir: []const u8) void {
465 self.output_dir = b.dupePath(dir);463 self.output_dir = b.dupePath(dir);
466}464}
467465
468pub fn install(self: *CompileStep) void {
469 const b = self.step.owner;
470 b.installArtifact(self);
471}
472
473pub fn installHeader(cs: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void {466pub fn installHeader(cs: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void {
474 const b = cs.step.owner;467 const b = cs.step.owner;
475 const install_file = b.addInstallHeaderFile(src_path, dest_rel_path);468 const install_file = b.addInstallHeaderFile(src_path, dest_rel_path);
...@@ -533,7 +526,7 @@ pub fn installLibraryHeaders(cs: *CompileStep, l: *CompileStep) void {...@@ -533,7 +526,7 @@ pub fn installLibraryHeaders(cs: *CompileStep, l: *CompileStep) void {
533 const T = id.Type();526 const T = id.Type();
534 const ptr = b.allocator.create(T) catch @panic("OOM");527 const ptr = b.allocator.create(T) catch @panic("OOM");
535 ptr.* = step.cast(T).?.*;528 ptr.* = step.cast(T).?.*;
536 ptr.dest_builder = b;529 ptr.step.owner = b;
537 break :blk &ptr.step;530 break :blk &ptr.step;
538 },531 },
539 else => unreachable,532 else => unreachable,
...@@ -557,12 +550,13 @@ pub fn addObjCopy(cs: *CompileStep, options: ObjCopyStep.Options) *ObjCopyStep {...@@ -557,12 +550,13 @@ pub fn addObjCopy(cs: *CompileStep, options: ObjCopyStep.Options) *ObjCopyStep {
557 return b.addObjCopy(cs.getOutputSource(), copy);550 return b.addObjCopy(cs.getOutputSource(), copy);
558}551}
559552
560/// Deprecated: use `std.Build.addRunArtifact`553/// This function would run in the context of the package that created the executable,
561/// This function will run in the context of the package that created the executable,
562/// which is undesirable when running an executable provided by a dependency package.554/// which is undesirable when running an executable provided by a dependency package.
563pub fn run(cs: *CompileStep) *RunStep {555pub const run = @compileError("deprecated; use std.Build.addRunArtifact");
564 return cs.step.owner.addRunArtifact(cs);556
565}557/// This function would install in the context of the package that created the artifact,
558/// which is undesirable when installing an artifact provided by a dependency package.
559pub const install = @compileError("deprecated; use std.Build.installArtifact");
566560
567pub fn checkObject(self: *CompileStep) *CheckObjectStep {561pub fn checkObject(self: *CompileStep) *CheckObjectStep {
568 return CheckObjectStep.create(self.step.owner, self.getOutputSource(), self.target_info.target.ofmt);562 return CheckObjectStep.create(self.step.owner, self.getOutputSource(), self.target_info.target.ofmt);
lib/std/Build/InstallArtifactStep.zig+2-7
...@@ -8,7 +8,6 @@ const fs = std.fs;...@@ -8,7 +8,6 @@ const fs = std.fs;
8pub const base_id = .install_artifact;8pub const base_id = .install_artifact;
99
10step: Step,10step: Step,
11dest_builder: *std.Build,
12artifact: *CompileStep,11artifact: *CompileStep,
13dest_dir: InstallDir,12dest_dir: InstallDir,
14pdb_dir: ?InstallDir,13pdb_dir: ?InstallDir,
...@@ -18,8 +17,6 @@ h_dir: ?InstallDir,...@@ -18,8 +17,6 @@ h_dir: ?InstallDir,
18dest_sub_path: ?[]const u8,17dest_sub_path: ?[]const u8,
1918
20pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {19pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {
21 if (artifact.install_step) |s| return s;
22
23 const self = owner.allocator.create(InstallArtifactStep) catch @panic("OOM");20 const self = owner.allocator.create(InstallArtifactStep) catch @panic("OOM");
24 self.* = InstallArtifactStep{21 self.* = InstallArtifactStep{
25 .step = Step.init(.{22 .step = Step.init(.{
...@@ -28,7 +25,6 @@ pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {...@@ -28,7 +25,6 @@ pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {
28 .owner = owner,25 .owner = owner,
29 .makeFn = make,26 .makeFn = make,
30 }),27 }),
31 .dest_builder = owner,
32 .artifact = artifact,28 .artifact = artifact,
33 .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) {29 .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) {
34 .obj => @panic("Cannot install a .obj build artifact."),30 .obj => @panic("Cannot install a .obj build artifact."),
...@@ -46,7 +42,6 @@ pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {...@@ -46,7 +42,6 @@ pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {
46 .dest_sub_path = null,42 .dest_sub_path = null,
47 };43 };
48 self.step.dependOn(&artifact.step);44 self.step.dependOn(&artifact.step);
49 artifact.install_step = self;
5045
51 owner.pushInstalledFile(self.dest_dir, artifact.out_filename);46 owner.pushInstalledFile(self.dest_dir, artifact.out_filename);
52 if (self.artifact.isDynamicLibrary()) {47 if (self.artifact.isDynamicLibrary()) {
...@@ -71,9 +66,9 @@ pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {...@@ -71,9 +66,9 @@ pub fn create(owner: *std.Build, artifact: *CompileStep) *InstallArtifactStep {
7166
72fn make(step: *Step, prog_node: *std.Progress.Node) !void {67fn make(step: *Step, prog_node: *std.Progress.Node) !void {
73 _ = prog_node;68 _ = prog_node;
74 const src_builder = step.owner;
75 const self = @fieldParentPtr(InstallArtifactStep, "step", step);69 const self = @fieldParentPtr(InstallArtifactStep, "step", step);
76 const dest_builder = self.dest_builder;70 const src_builder = self.artifact.step.owner;
71 const dest_builder = step.owner;
7772
78 const dest_sub_path = if (self.dest_sub_path) |sub_path| sub_path else self.artifact.out_filename;73 const dest_sub_path = if (self.dest_sub_path) |sub_path| sub_path else self.artifact.out_filename;
79 const full_dest_path = dest_builder.getInstallPath(self.dest_dir, dest_sub_path);74 const full_dest_path = dest_builder.getInstallPath(self.dest_dir, dest_sub_path);
lib/std/Build/RunStep.zig+2-2
...@@ -866,9 +866,9 @@ fn spawnChildAndCollect(...@@ -866,9 +866,9 @@ fn spawnChildAndCollect(
866 child.request_resource_usage_statistics = true;866 child.request_resource_usage_statistics = true;
867867
868 child.stdin_behavior = switch (self.stdio) {868 child.stdin_behavior = switch (self.stdio) {
869 .infer_from_args => if (has_side_effects) .Inherit else .Close,869 .infer_from_args => if (has_side_effects) .Inherit else .Ignore,
870 .inherit => .Inherit,870 .inherit => .Inherit,
871 .check => .Close,871 .check => .Ignore,
872 .zig_test => .Pipe,872 .zig_test => .Pipe,
873 };873 };
874 child.stdout_behavior = switch (self.stdio) {874 child.stdout_behavior = switch (self.stdio) {
test/link/bss/build.zig+1-1
...@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {...@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {
10 .optimize = .Debug,10 .optimize = .Debug,
11 });11 });
1212
13 const run = exe.run();13 const run = b.addRunArtifact(exe);
14 run.expectStdOutEqual("0, 1, 0\n");14 run.expectStdOutEqual("0, 1, 0\n");
1515
16 test_step.dependOn(&run.step);16 test_step.dependOn(&run.step);
test/link/common_symbols/build.zig+1-1
...@@ -24,5 +24,5 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -24,5 +24,5 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
24 });24 });
25 test_exe.linkLibrary(lib_a);25 test_exe.linkLibrary(lib_a);
2626
27 test_step.dependOn(&test_exe.run().step);27 test_step.dependOn(&b.addRunArtifact(test_exe).step);
28}28}
test/link/common_symbols_alignment/build.zig+1-1
...@@ -24,5 +24,5 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -24,5 +24,5 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
24 });24 });
25 test_exe.linkLibrary(lib_a);25 test_exe.linkLibrary(lib_a);
2626
27 test_step.dependOn(&test_exe.run().step);27 test_step.dependOn(&b.addRunArtifact(test_exe).step);
28}28}
test/link/interdependent_static_c_libs/build.zig+1-1
...@@ -35,5 +35,5 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -35,5 +35,5 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
35 test_exe.linkLibrary(lib_b);35 test_exe.linkLibrary(lib_b);
36 test_exe.addIncludePath(".");36 test_exe.addIncludePath(".");
3737
38 test_step.dependOn(&test_exe.run().step);38 test_step.dependOn(&b.addRunArtifact(test_exe).step);
39}39}
test/link/macho/bugs/13056/build.zig+1-1
...@@ -31,7 +31,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -31,7 +31,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
31 });31 });
32 exe.addObjectFile(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/lib/libc++.tbd" }) catch unreachable);32 exe.addObjectFile(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/lib/libc++.tbd" }) catch unreachable);
3333
34 const run_cmd = exe.run();34 const run_cmd = b.addRunArtifact(exe);
35 run_cmd.expectStdErrEqual("x: 5\n");35 run_cmd.expectStdErrEqual("x: 5\n");
3636
37 test_step.dependOn(&run_cmd.step);37 test_step.dependOn(&run_cmd.step);
test/link/macho/dead_strip_dylibs/build.zig+1-1
...@@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2727
28 test_step.dependOn(&check.step);28 test_step.dependOn(&check.step);
2929
30 const run_cmd = exe.run();30 const run_cmd = b.addRunArtifact(exe);
31 test_step.dependOn(&run_cmd.step);31 test_step.dependOn(&run_cmd.step);
32 }32 }
3333
test/link/macho/entry_in_archive/build.zig+1-1
...@@ -29,7 +29,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -29,7 +29,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
29 exe.linkLibrary(lib);29 exe.linkLibrary(lib);
30 exe.linkLibC();30 exe.linkLibC();
3131
32 const run = exe.run();32 const run = b.addRunArtifact(exe);
33 run.skip_foreign_checks = true;33 run.skip_foreign_checks = true;
34 run.expectExitCode(0);34 run.expectExitCode(0);
35 test_step.dependOn(&run.step);35 test_step.dependOn(&run.step);
test/link/macho/headerpad/build.zig+4-4
...@@ -36,7 +36,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -36,7 +36,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3636
37 test_step.dependOn(&check.step);37 test_step.dependOn(&check.step);
3838
39 const run = exe.run();39 const run = b.addRunArtifact(exe);
40 test_step.dependOn(&run.step);40 test_step.dependOn(&run.step);
41 }41 }
4242
...@@ -52,7 +52,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -52,7 +52,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
5252
53 test_step.dependOn(&check.step);53 test_step.dependOn(&check.step);
5454
55 const run = exe.run();55 const run = b.addRunArtifact(exe);
56 test_step.dependOn(&run.step);56 test_step.dependOn(&run.step);
57 }57 }
5858
...@@ -69,7 +69,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -69,7 +69,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
6969
70 test_step.dependOn(&check.step);70 test_step.dependOn(&check.step);
7171
72 const run = exe.run();72 const run = b.addRunArtifact(exe);
73 test_step.dependOn(&run.step);73 test_step.dependOn(&run.step);
74 }74 }
7575
...@@ -95,7 +95,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -95,7 +95,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
9595
96 test_step.dependOn(&check.step);96 test_step.dependOn(&check.step);
9797
98 const run = exe.run();98 const run = b.addRunArtifact(exe);
99 test_step.dependOn(&run.step);99 test_step.dependOn(&run.step);
100 }100 }
101}101}
test/link/macho/needed_framework/build.zig+1-1
...@@ -30,6 +30,6 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -30,6 +30,6 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
30 check.checkNext("name {*}Cocoa");30 check.checkNext("name {*}Cocoa");
31 test_step.dependOn(&check.step);31 test_step.dependOn(&check.step);
3232
33 const run_cmd = exe.run();33 const run_cmd = b.addRunArtifact(exe);
34 test_step.dependOn(&run_cmd.step);34 test_step.dependOn(&run_cmd.step);
35}35}
test/link/macho/objcpp/build.zig+1-1
...@@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
27 // populate paths to the sysroot here.27 // populate paths to the sysroot here.
28 exe.linkFramework("Foundation");28 exe.linkFramework("Foundation");
2929
30 const run_cmd = exe.run();30 const run_cmd = b.addRunArtifact(exe);
31 run_cmd.expectStdOutEqual("Hello from C++ and Zig");31 run_cmd.expectStdOutEqual("Hello from C++ and Zig");
3232
33 test_step.dependOn(&run_cmd.step);33 test_step.dependOn(&run_cmd.step);
test/link/macho/tls/build.zig+1-1
...@@ -32,7 +32,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -32,7 +32,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
32 test_exe.linkLibrary(lib);32 test_exe.linkLibrary(lib);
33 test_exe.linkLibC();33 test_exe.linkLibC();
3434
35 const run = test_exe.run();35 const run = b.addRunArtifact(test_exe);
36 run.skip_foreign_checks = true;36 run.skip_foreign_checks = true;
3737
38 test_step.dependOn(&run.step);38 test_step.dependOn(&run.step);
test/link/macho/weak_framework/build.zig+1-1
...@@ -27,6 +27,6 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -27,6 +27,6 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
27 check.checkNext("name {*}Cocoa");27 check.checkNext("name {*}Cocoa");
28 test_step.dependOn(&check.step);28 test_step.dependOn(&check.step);
2929
30 const run_cmd = exe.run();30 const run_cmd = b.addRunArtifact(exe);
31 test_step.dependOn(&run_cmd.step);31 test_step.dependOn(&run_cmd.step);
32}32}
test/link/macho/weak_library/build.zig+1-1
...@@ -23,7 +23,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -23,7 +23,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
23 });23 });
24 dylib.addCSourceFile("a.c", &.{});24 dylib.addCSourceFile("a.c", &.{});
25 dylib.linkLibC();25 dylib.linkLibC();
26 dylib.install();26 b.installArtifact(dylib);
2727
28 const exe = b.addExecutable(.{28 const exe = b.addExecutable(.{
29 .name = "test",29 .name = "test",
test/link/wasm/producers/build.zig+1-1
...@@ -23,7 +23,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -23,7 +23,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
23 lib.use_llvm = false;23 lib.use_llvm = false;
24 lib.use_lld = false;24 lib.use_lld = false;
25 lib.strip = false;25 lib.strip = false;
26 lib.install();26 b.installArtifact(lib);
2727
28 const version_fmt = "version " ++ builtin.zig_version_string;28 const version_fmt = "version " ++ builtin.zig_version_string;
2929
test/link/wasm/segments/build.zig+1-1
...@@ -22,7 +22,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -22,7 +22,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
22 lib.use_llvm = false;22 lib.use_llvm = false;
23 lib.use_lld = false;23 lib.use_lld = false;
24 lib.strip = false;24 lib.strip = false;
25 lib.install();25 b.installArtifact(lib);
2626
27 const check_lib = lib.checkObject();27 const check_lib = lib.checkObject();
28 check_lib.checkStart("Section data");28 check_lib.checkStart("Section data");
test/link/wasm/stack_pointer/build.zig+1-1
...@@ -23,7 +23,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -23,7 +23,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
23 lib.use_lld = false;23 lib.use_lld = false;
24 lib.strip = false;24 lib.strip = false;
25 lib.stack_size = std.wasm.page_size * 2; // set an explicit stack size25 lib.stack_size = std.wasm.page_size * 2; // set an explicit stack size
26 lib.install();26 b.installArtifact(lib);
2727
28 const check_lib = lib.checkObject();28 const check_lib = lib.checkObject();
2929
test/link/wasm/type/build.zig+1-1
...@@ -22,7 +22,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -22,7 +22,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
22 lib.use_llvm = false;22 lib.use_llvm = false;
23 lib.use_lld = false;23 lib.use_lld = false;
24 lib.strip = false;24 lib.strip = false;
25 lib.install();25 b.installArtifact(lib);
2626
27 const check_lib = lib.checkObject();27 const check_lib = lib.checkObject();
28 check_lib.checkStart("Section type");28 check_lib.checkStart("Section type");
test/src/CompareOutput.zig+3-3
...@@ -101,7 +101,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -101,7 +101,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
101 });101 });
102 exe.addAssemblyFileSource(write_src.getFileSource(case.sources.items[0].filename).?);102 exe.addAssemblyFileSource(write_src.getFileSource(case.sources.items[0].filename).?);
103103
104 const run = exe.run();104 const run = b.addRunArtifact(exe);
105 run.setName(annotated_case_name);105 run.setName(annotated_case_name);
106 run.addArgs(case.cli_args);106 run.addArgs(case.cli_args);
107 run.expectStdOutEqual(case.expected_output);107 run.expectStdOutEqual(case.expected_output);
...@@ -128,7 +128,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -128,7 +128,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
128 exe.linkSystemLibrary("c");128 exe.linkSystemLibrary("c");
129 }129 }
130130
131 const run = exe.run();131 const run = b.addRunArtifact(exe);
132 run.setName(annotated_case_name);132 run.setName(annotated_case_name);
133 run.addArgs(case.cli_args);133 run.addArgs(case.cli_args);
134 run.expectStdOutEqual(case.expected_output);134 run.expectStdOutEqual(case.expected_output);
...@@ -155,7 +155,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -155,7 +155,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
155 exe.linkSystemLibrary("c");155 exe.linkSystemLibrary("c");
156 }156 }
157157
158 const run = exe.run();158 const run = b.addRunArtifact(exe);
159 run.setName(annotated_case_name);159 run.setName(annotated_case_name);
160 run.addArgs(case.cli_args);160 run.addArgs(case.cli_args);
161 run.expectExitCode(126);161 run.expectExitCode(126);
test/src/run_translated_c.zig+1-1
...@@ -94,7 +94,7 @@ pub const RunTranslatedCContext = struct {...@@ -94,7 +94,7 @@ pub const RunTranslatedCContext = struct {
94 const exe = translate_c.addExecutable(.{});94 const exe = translate_c.addExecutable(.{});
95 exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});95 exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
96 exe.linkLibC();96 exe.linkLibC();
97 const run = exe.run();97 const run = b.addRunArtifact(exe);
98 run.step.name = b.fmt("{s} run", .{annotated_case_name});98 run.step.name = b.fmt("{s} run", .{annotated_case_name});
99 if (!case.allow_warnings) {99 if (!case.allow_warnings) {
100 run.expectStdErrEqual("");100 run.expectStdErrEqual("");
test/standalone/dep_diamond/build.zig+1-2
...@@ -24,7 +24,6 @@ pub fn build(b: *std.Build) void {...@@ -24,7 +24,6 @@ pub fn build(b: *std.Build) void {
24 .dependencies = &.{.{ .name = "shared", .module = shared }},24 .dependencies = &.{.{ .name = "shared", .module = shared }},
25 });25 });
2626
27 const run = exe.run();27 const run = b.addRunArtifact(exe);
28
29 test_step.dependOn(&run.step);28 test_step.dependOn(&run.step);
30}29}
test/standalone/dep_mutually_recursive/build.zig+1-2
...@@ -22,7 +22,6 @@ pub fn build(b: *std.Build) void {...@@ -22,7 +22,6 @@ pub fn build(b: *std.Build) void {
22 });22 });
23 exe.addModule("foo", foo);23 exe.addModule("foo", foo);
2424
25 const run = exe.run();25 const run = b.addRunArtifact(exe);
26
27 test_step.dependOn(&run.step);26 test_step.dependOn(&run.step);
28}27}
test/standalone/dep_recursive/build.zig+1-2
...@@ -18,7 +18,6 @@ pub fn build(b: *std.Build) void {...@@ -18,7 +18,6 @@ pub fn build(b: *std.Build) void {
18 });18 });
19 exe.addModule("foo", foo);19 exe.addModule("foo", foo);
2020
21 const run = exe.run();21 const run = b.addRunArtifact(exe);
22
23 test_step.dependOn(&run.step);22 test_step.dependOn(&run.step);
24}23}
test/standalone/dep_shared_builtin/build.zig+1-2
...@@ -15,7 +15,6 @@ pub fn build(b: *std.Build) void {...@@ -15,7 +15,6 @@ pub fn build(b: *std.Build) void {
15 .source_file = .{ .path = "foo.zig" },15 .source_file = .{ .path = "foo.zig" },
16 });16 });
1717
18 const run = exe.run();18 const run = b.addRunArtifact(exe);
19
20 test_step.dependOn(&run.step);19 test_step.dependOn(&run.step);
21}20}
test/standalone/dep_triangle/build.zig+1-2
...@@ -21,7 +21,6 @@ pub fn build(b: *std.Build) void {...@@ -21,7 +21,6 @@ pub fn build(b: *std.Build) void {
21 });21 });
22 exe.addModule("shared", shared);22 exe.addModule("shared", shared);
2323
24 const run = exe.run();24 const run = b.addRunArtifact(exe);
25
26 test_step.dependOn(&run.step);25 test_step.dependOn(&run.step);
27}26}
test/standalone/emit_asm_and_bin/build.zig+1-1
...@@ -11,5 +11,5 @@ pub fn build(b: *std.Build) void {...@@ -11,5 +11,5 @@ pub fn build(b: *std.Build) void {
11 main.emit_asm = .{ .emit_to = b.pathFromRoot("main.s") };11 main.emit_asm = .{ .emit_to = b.pathFromRoot("main.s") };
12 main.emit_bin = .{ .emit_to = b.pathFromRoot("main") };12 main.emit_bin = .{ .emit_to = b.pathFromRoot("main") };
1313
14 test_step.dependOn(&main.run().step);14 test_step.dependOn(&b.addRunArtifact(main).step);
15}15}
test/standalone/global_linkage/build.zig+1-1
...@@ -28,5 +28,5 @@ pub fn build(b: *std.Build) void {...@@ -28,5 +28,5 @@ pub fn build(b: *std.Build) void {
28 main.linkLibrary(obj1);28 main.linkLibrary(obj1);
29 main.linkLibrary(obj2);29 main.linkLibrary(obj2);
3030
31 test_step.dependOn(&main.run().step);31 test_step.dependOn(&b.addRunArtifact(main).step);
32}32}
test/standalone/issue_11595/build.zig+1-1
...@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {...@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
19 .target = target,19 .target = target,
20 .optimize = optimize,20 .optimize = optimize,
21 });21 });
22 exe.install();22 b.installArtifact(exe);
2323
24 const c_sources = [_][]const u8{24 const c_sources = [_][]const u8{
25 "test.c",25 "test.c",
test/standalone/issue_13970/build.zig+3-3
...@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {...@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
17 test2.setTestRunner("src/main.zig");17 test2.setTestRunner("src/main.zig");
18 test3.setTestRunner("src/main.zig");18 test3.setTestRunner("src/main.zig");
1919
20 test_step.dependOn(&test1.run().step);20 test_step.dependOn(&b.addRunArtifact(test1).step);
21 test_step.dependOn(&test2.run().step);21 test_step.dependOn(&b.addRunArtifact(test2).step);
22 test_step.dependOn(&test3.run().step);22 test_step.dependOn(&b.addRunArtifact(test3).step);
23}23}
test/standalone/issue_8550/build.zig+1-1
...@@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void {...@@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void {
21 });21 });
22 kernel.addObjectFile("./boot.S");22 kernel.addObjectFile("./boot.S");
23 kernel.setLinkerScriptPath(.{ .path = "./linker.ld" });23 kernel.setLinkerScriptPath(.{ .path = "./linker.ld" });
24 kernel.install();24 b.installArtifact(kernel);
2525
26 test_step.dependOn(&kernel.step);26 test_step.dependOn(&kernel.step);
27}27}
test/standalone/main_pkg_path/build.zig+1-1
...@@ -9,5 +9,5 @@ pub fn build(b: *std.Build) void {...@@ -9,5 +9,5 @@ pub fn build(b: *std.Build) void {
9 });9 });
10 test_exe.setMainPkgPath(".");10 test_exe.setMainPkgPath(".");
1111
12 test_step.dependOn(&test_exe.run().step);12 test_step.dependOn(&b.addRunArtifact(test_exe).step);
13}13}
test/standalone/mix_o_files/build.zig+1-2
...@@ -25,7 +25,6 @@ pub fn build(b: *std.Build) void {...@@ -25,7 +25,6 @@ pub fn build(b: *std.Build) void {
2525
26 b.default_step.dependOn(&exe.step);26 b.default_step.dependOn(&exe.step);
2727
28 const run_cmd = exe.run();28 const run_cmd = b.addRunArtifact(exe);
29
30 test_step.dependOn(&run_cmd.step);29 test_step.dependOn(&run_cmd.step);
31}30}
test/standalone/options/build.zig+1-1
...@@ -17,5 +17,5 @@ pub fn build(b: *std.Build) void {...@@ -17,5 +17,5 @@ pub fn build(b: *std.Build) void {
17 options.addOption([]const u8, "string", b.option([]const u8, "string", "s").?);17 options.addOption([]const u8, "string", b.option([]const u8, "string", "s").?);
1818
19 const test_step = b.step("test", "Run unit tests");19 const test_step = b.step("test", "Run unit tests");
20 test_step.dependOn(&main.run().step);20 test_step.dependOn(&b.addRunArtifact(main).step);
21}21}
test/standalone/pie/build.zig+1-1
...@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {...@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
17 });17 });
18 main.pie = true;18 main.pie = true;
1919
20 const run = main.run();20 const run = b.addRunArtifact(main);
21 run.skip_foreign_checks = true;21 run.skip_foreign_checks = true;
2222
23 test_step.dependOn(&run.step);23 test_step.dependOn(&run.step);
test/standalone/pkg_import/build.zig+1-2
...@@ -13,7 +13,6 @@ pub fn build(b: *std.Build) void {...@@ -13,7 +13,6 @@ pub fn build(b: *std.Build) void {
13 });13 });
14 exe.addAnonymousModule("my_pkg", .{ .source_file = .{ .path = "pkg.zig" } });14 exe.addAnonymousModule("my_pkg", .{ .source_file = .{ .path = "pkg.zig" } });
1515
16 const run = exe.run();16 const run = b.addRunArtifact(exe);
17
18 test_step.dependOn(&run.step);17 test_step.dependOn(&run.step);
19}18}
test/standalone/shared_library/build.zig+1-2
...@@ -23,7 +23,6 @@ pub fn build(b: *std.Build) void {...@@ -23,7 +23,6 @@ pub fn build(b: *std.Build) void {
23 exe.linkLibrary(lib);23 exe.linkLibrary(lib);
24 exe.linkSystemLibrary("c");24 exe.linkSystemLibrary("c");
2525
26 const run_cmd = exe.run();26 const run_cmd = b.addRunArtifact(exe);
27
28 test_step.dependOn(&run_cmd.step);27 test_step.dependOn(&run_cmd.step);
29}28}
test/standalone/static_c_lib/build.zig+1-1
...@@ -21,5 +21,5 @@ pub fn build(b: *std.Build) void {...@@ -21,5 +21,5 @@ pub fn build(b: *std.Build) void {
21 test_exe.linkLibrary(foo);21 test_exe.linkLibrary(foo);
22 test_exe.addIncludePath(".");22 test_exe.addIncludePath(".");
2323
24 test_step.dependOn(&test_exe.run().step);24 test_step.dependOn(&b.addRunArtifact(test_exe).step);
25}25}
test/standalone/test_runner_module_imports/build.zig+1-1
...@@ -15,6 +15,6 @@ pub fn build(b: *std.Build) void {...@@ -15,6 +15,6 @@ pub fn build(b: *std.Build) void {
15 t.addModule("module2", module2);15 t.addModule("module2", module2);
1616
17 const test_step = b.step("test", "Run unit tests");17 const test_step = b.step("test", "Run unit tests");
18 test_step.dependOn(&t.run().step);18 test_step.dependOn(&b.addRunArtifact(t).step);
19 b.default_step = test_step;19 b.default_step = test_step;
20}20}
test/standalone/test_runner_path/build.zig+1-2
...@@ -11,7 +11,6 @@ pub fn build(b: *std.Build) void {...@@ -11,7 +11,6 @@ pub fn build(b: *std.Build) void {
11 });11 });
12 test_exe.test_runner = "test_runner.zig";12 test_exe.test_runner = "test_runner.zig";
1313
14 const test_run = test_exe.run();14 const test_run = b.addRunArtifact(test_exe);
15
16 test_step.dependOn(&test_run.step);15 test_step.dependOn(&test_run.step);
17}16}
test/standalone/use_alias/build.zig+1-1
...@@ -12,5 +12,5 @@ pub fn build(b: *std.Build) void {...@@ -12,5 +12,5 @@ pub fn build(b: *std.Build) void {
12 });12 });
13 main.addIncludePath(".");13 main.addIncludePath(".");
1414
15 test_step.dependOn(&main.run().step);15 test_step.dependOn(&b.addRunArtifact(main).step);
16}16}
test/tests.zig+4-3
...@@ -596,7 +596,8 @@ pub fn addStandaloneTests(...@@ -596,7 +596,8 @@ pub fn addStandaloneTests(
596 });596 });
597 if (case.link_libc) exe.linkLibC();597 if (case.link_libc) exe.linkLibC();
598598
599 step.dependOn(&exe.run().step);599 const run = b.addRunArtifact(exe);
600 step.dependOn(&run.step);
600 }601 }
601 }602 }
602 }603 }
...@@ -1004,7 +1005,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1004,7 +1005,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1004 },1005 },
1005 };1006 };
10061007
1007 const run = these_tests.run();1008 const run = b.addRunArtifact(these_tests);
1008 run.skip_foreign_checks = true;1009 run.skip_foreign_checks = true;
1009 run.setName(b.fmt("run test {s}-{s}-{s}-{s}-{s}-{s}", .{1010 run.setName(b.fmt("run test {s}-{s}-{s}-{s}-{s}-{s}", .{
1010 options.name,1011 options.name,
...@@ -1061,7 +1062,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S...@@ -1061,7 +1062,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
1061 triple_prefix, @tagName(optimize_mode),1062 triple_prefix, @tagName(optimize_mode),
1062 }));1063 }));
10631064
1064 const run = test_step.run();1065 const run = b.addRunArtifact(test_step);
1065 run.skip_foreign_checks = true;1066 run.skip_foreign_checks = true;
1066 step.dependOn(&run.step);1067 step.dependOn(&run.step);
1067 }1068 }