Commit 45c77931c2

Krzysztof Wolicki <der.teufel.mail@gmail.com>
2024-06-13 14:00:22
Change deprecated b.host to b.graph.host in tests and Zig's build.zig
1 parent 76fb2b6
Changed files (39)
test
link
bss
common_symbols
common_symbols_alignment
interdependent_static_c_libs
static_libs_from_object_files
src
standalone
c_compiler
child_process
dep_diamond
dep_mutually_recursive
dep_recursive
dep_shared_builtin
dep_triangle
empty_env
extern
global_linkage
issue_11595
issue_12588
issue_12706
issue_339
load_dynamic_library
mix_c_files
mix_o_files
options
pkg_import
self_exe_symlink
shared_library
static_c_lib
strip_empty_loop
windows_argv
windows_bat_args
windows_resources
windows_spawn
test/link/bss/build.zig
@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
     const exe = b.addExecutable(.{
         .name = "bss",
         .root_source_file = b.path("main.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = .Debug,
     });
 
test/link/common_symbols/build.zig
@@ -14,7 +14,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
     const lib_a = b.addStaticLibrary(.{
         .name = "a",
         .optimize = optimize,
-        .target = b.host,
+        .target = b.graph.host,
     });
     lib_a.addCSourceFiles(.{
         .files = &.{ "c.c", "a.c", "b.c" },
test/link/common_symbols_alignment/build.zig
@@ -14,7 +14,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
     const lib_a = b.addStaticLibrary(.{
         .name = "a",
         .optimize = optimize,
-        .target = b.host,
+        .target = b.graph.host,
     });
     lib_a.addCSourceFiles(.{
         .files = &.{"a.c"},
test/link/interdependent_static_c_libs/build.zig
@@ -14,7 +14,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
     const lib_a = b.addStaticLibrary(.{
         .name = "a",
         .optimize = optimize,
-        .target = b.host,
+        .target = b.graph.host,
     });
     lib_a.addCSourceFile(.{ .file = b.path("a.c"), .flags = &[_][]const u8{} });
     lib_a.addIncludePath(b.path("."));
@@ -22,7 +22,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
     const lib_b = b.addStaticLibrary(.{
         .name = "b",
         .optimize = optimize,
-        .target = b.host,
+        .target = b.graph.host,
     });
     lib_b.addCSourceFile(.{ .file = b.path("b.c"), .flags = &[_][]const u8{} });
     lib_b.addIncludePath(b.path("."));
test/link/static_libs_from_object_files/build.zig
@@ -59,7 +59,7 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
             .name = "test1",
             .root_source_file = b.path("main.zig"),
             .optimize = optimize,
-            .target = b.host,
+            .target = b.graph.host,
         });
 
         for (files) |file| {
@@ -77,12 +77,12 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
     {
         const lib_a = b.addStaticLibrary(.{
             .name = "test2_a",
-            .target = b.host,
+            .target = b.graph.host,
             .optimize = optimize,
         });
         const lib_b = b.addStaticLibrary(.{
             .name = "test2_b",
-            .target = b.host,
+            .target = b.graph.host,
             .optimize = optimize,
         });
 
@@ -94,7 +94,7 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
         const exe = b.addExecutable(.{
             .name = "test2",
             .root_source_file = b.path("main.zig"),
-            .target = b.host,
+            .target = b.graph.host,
             .optimize = optimize,
         });
         exe.linkLibrary(lib_a);
@@ -111,19 +111,19 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
     {
         const lib_a = b.addStaticLibrary(.{
             .name = "test3_a",
-            .target = b.host,
+            .target = b.graph.host,
             .optimize = optimize,
         });
         const lib_b = b.addStaticLibrary(.{
             .name = "test3_b",
-            .target = b.host,
+            .target = b.graph.host,
             .optimize = optimize,
         });
 
         for (files, 1..) |file, i| {
             const obj = b.addObject(.{
                 .name = b.fmt("obj_{}", .{i}),
-                .target = b.host,
+                .target = b.graph.host,
                 .optimize = optimize,
             });
             obj.addCSourceFile(.{ .file = file, .flags = &flags });
@@ -135,7 +135,7 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
         const exe = b.addExecutable(.{
             .name = "test3",
             .root_source_file = b.path("main.zig"),
-            .target = b.host,
+            .target = b.graph.host,
             .optimize = optimize,
         });
         exe.linkLibrary(lib_a);
test/link/macho.zig
@@ -83,14 +83,14 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
 
         // Tests requiring presence of macOS SDK in system path
         if (build_opts.has_macos_sdk) {
-            macho_step.dependOn(testDeadStripDylibs(b, .{ .target = b.host }));
-            macho_step.dependOn(testHeaderpad(b, .{ .target = b.host }));
-            macho_step.dependOn(testLinkDirectlyCppTbd(b, .{ .target = b.host }));
-            macho_step.dependOn(testMergeLiteralsObjc(b, .{ .target = b.host }));
-            macho_step.dependOn(testNeededFramework(b, .{ .target = b.host }));
-            macho_step.dependOn(testObjc(b, .{ .target = b.host }));
-            macho_step.dependOn(testObjcpp(b, .{ .target = b.host }));
-            macho_step.dependOn(testWeakFramework(b, .{ .target = b.host }));
+            macho_step.dependOn(testDeadStripDylibs(b, .{ .target = b.graph.host }));
+            macho_step.dependOn(testHeaderpad(b, .{ .target = b.graph.host }));
+            macho_step.dependOn(testLinkDirectlyCppTbd(b, .{ .target = b.graph.host }));
+            macho_step.dependOn(testMergeLiteralsObjc(b, .{ .target = b.graph.host }));
+            macho_step.dependOn(testNeededFramework(b, .{ .target = b.graph.host }));
+            macho_step.dependOn(testObjc(b, .{ .target = b.graph.host }));
+            macho_step.dependOn(testObjcpp(b, .{ .target = b.graph.host }));
+            macho_step.dependOn(testWeakFramework(b, .{ .target = b.graph.host }));
         }
     }
 
test/src/CompareOutput.zig
@@ -96,7 +96,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
 
             const exe = b.addExecutable(.{
                 .name = "test",
-                .target = b.host,
+                .target = b.graph.host,
                 .optimize = .Debug,
             });
             exe.addAssemblyFile(write_src.files.items[0].getPath());
@@ -121,7 +121,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
                     .name = "test",
                     .root_source_file = write_src.files.items[0].getPath(),
                     .optimize = optimize,
-                    .target = b.host,
+                    .target = b.graph.host,
                 });
                 if (case.link_libc) {
                     exe.linkSystemLibrary("c");
@@ -146,7 +146,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
             const exe = b.addExecutable(.{
                 .name = "test",
                 .root_source_file = write_src.files.items[0].getPath(),
-                .target = b.host,
+                .target = b.graph.host,
                 .optimize = .Debug,
             });
             if (case.link_libc) {
test/src/RunTranslatedC.zig
@@ -77,7 +77,7 @@ pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
     }
     const translate_c = b.addTranslateC(.{
         .root_source_file = write_src.files.items[0].getPath(),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = .Debug,
     });
 
test/src/StackTrace.zig
@@ -56,7 +56,7 @@ fn addExpect(
         .name = "test",
         .root_source_file = write_src.files.items[0].getPath(),
         .optimize = optimize_mode,
-        .target = b.host,
+        .target = b.graph.host,
         .error_tracing = mode_config.error_tracing,
     });
 
test/standalone/c_compiler/build.zig
@@ -23,7 +23,7 @@ fn add(
     cpp_name: []const u8,
     optimize: std.builtin.OptimizeMode,
 ) void {
-    const target = b.host;
+    const target = b.graph.host;
 
     const exe_c = b.addExecutable(.{
         .name = c_name,
test/standalone/child_process/build.zig
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     if (builtin.os.tag == .wasi) return;
 
test/standalone/dep_diamond/build.zig
@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {
     const exe = b.addExecutable(.{
         .name = "test",
         .root_source_file = b.path("test.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
     exe.root_module.addAnonymousImport("foo", .{
test/standalone/dep_mutually_recursive/build.zig
@@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {
     const exe = b.addExecutable(.{
         .name = "test",
         .root_source_file = b.path("test.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
     exe.root_module.addImport("foo", foo);
test/standalone/dep_recursive/build.zig
@@ -14,7 +14,7 @@ pub fn build(b: *std.Build) void {
     const exe = b.addExecutable(.{
         .name = "test",
         .root_source_file = b.path("test.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
     exe.root_module.addImport("foo", foo);
test/standalone/dep_shared_builtin/build.zig
@@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
     const exe = b.addExecutable(.{
         .name = "test",
         .root_source_file = b.path("test.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
     exe.root_module.addAnonymousImport("foo", .{
test/standalone/dep_triangle/build.zig
@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {
     const exe = b.addExecutable(.{
         .name = "test",
         .root_source_file = b.path("test.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
     exe.root_module.addAnonymousImport("foo", .{
test/standalone/empty_env/build.zig
@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
     const main = b.addExecutable(.{
         .name = "main",
         .root_source_file = b.path("main.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
 
test/standalone/extern/build.zig
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
     const obj = b.addObject(.{
         .name = "exports",
         .root_source_file = b.path("exports.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
     const main = b.addTest(.{
test/standalone/global_linkage/build.zig
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     const obj1 = b.addStaticLibrary(.{
         .name = "obj1",
test/standalone/issue_11595/build.zig
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     if (builtin.os.tag == .windows) {
         // https://github.com/ziglang/zig/issues/12419
test/standalone/issue_12588/build.zig
@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {
         .name = "main",
         .root_source_file = b.path("main.zig"),
         .optimize = optimize,
-        .target = b.host,
+        .target = b.graph.host,
     });
     _ = obj.getEmittedLlvmIr();
     _ = obj.getEmittedLlvmBc();
test/standalone/issue_12706/build.zig
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     const exe = b.addExecutable(.{
         .name = "main",
test/standalone/issue_339/build.zig
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     const obj = b.addObject(.{
         .name = "test",
test/standalone/load_dynamic_library/build.zig
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     if (builtin.os.tag == .wasi) return;
 
test/standalone/mix_c_files/build.zig
@@ -19,7 +19,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
     const exe = b.addExecutable(.{
         .name = "test",
         .root_source_file = b.path("main.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
     exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &[_][]const u8{"-std=c11"} });
test/standalone/mix_o_files/build.zig
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     const obj = b.addObject(.{
         .name = "base64",
test/standalone/options/build.zig
@@ -3,7 +3,7 @@ const std = @import("std");
 pub fn build(b: *std.Build) void {
     const main = b.addTest(.{
         .root_source_file = b.path("src/main.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = .Debug,
     });
 
test/standalone/pkg_import/build.zig
@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {
         .name = "test",
         .root_source_file = b.path("test.zig"),
         .optimize = optimize,
-        .target = b.host,
+        .target = b.graph.host,
     });
     exe.root_module.addAnonymousImport("my_pkg", .{ .root_source_file = b.path("pkg.zig") });
 
test/standalone/self_exe_symlink/build.zig
@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     // The test requires getFdPath in order to to get the path of the
     // File returned by openSelfExe
test/standalone/shared_library/build.zig
@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {
     }
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
     const lib = b.addSharedLibrary(.{
         .name = "mathtest",
         .root_source_file = b.path("mathtest.zig"),
test/standalone/static_c_lib/build.zig
@@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
     const foo = b.addStaticLibrary(.{
         .name = "foo",
         .optimize = optimize,
-        .target = b.host,
+        .target = b.graph.host,
     });
     foo.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &[_][]const u8{} });
     foo.addIncludePath(b.path("."));
test/standalone/strip_empty_loop/build.zig
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize = std.builtin.OptimizeMode.Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     const main = b.addExecutable(.{
         .name = "main",
test/standalone/windows_argv/build.zig
@@ -35,7 +35,7 @@ pub fn build(b: *std.Build) !void {
     const fuzz = b.addExecutable(.{
         .name = "fuzz",
         .root_source_file = b.path("fuzz.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
     });
 
test/standalone/windows_bat_args/build.zig
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) !void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     if (builtin.os.tag != .windows) return;
 
test/standalone/windows_resources/build.zig
@@ -12,10 +12,10 @@ pub fn build(b: *std.Build) void {
 
     const generated_h_step = b.addWriteFile("generated.h", "#define GENERATED_DEFINE \"foo\"");
 
-    add(b, b.host, .any, test_step, generated_h_step);
+    add(b, b.graph.host, .any, test_step, generated_h_step);
     add(b, target, .any, test_step, generated_h_step);
 
-    add(b, b.host, .gnu, test_step, generated_h_step);
+    add(b, b.graph.host, .gnu, test_step, generated_h_step);
     add(b, target, .gnu, test_step, generated_h_step);
 }
 
test/standalone/windows_spawn/build.zig
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
     b.default_step = test_step;
 
     const optimize: std.builtin.OptimizeMode = .Debug;
-    const target = b.host;
+    const target = b.graph.host;
 
     if (builtin.os.tag != .windows) return;
 
test/compile_errors.zig
@@ -4,7 +4,7 @@ const Cases = @import("src/Cases.zig");
 
 pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     {
-        const case = ctx.obj("multiline error messages", b.host);
+        const case = ctx.obj("multiline error messages", b.graph.host);
 
         case.addError(
             \\comptime {
@@ -39,7 +39,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("isolated carriage return in multiline string literal", b.host);
+        const case = ctx.obj("isolated carriage return in multiline string literal", b.graph.host);
 
         case.addError("const foo = \\\\\test\r\r rogue carriage return\n;", &[_][]const u8{
             ":1:19: error: expected ';' after declaration",
@@ -48,7 +48,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("missing semicolon at EOF", b.host);
+        const case = ctx.obj("missing semicolon at EOF", b.graph.host);
         case.addError(
             \\const foo = 1
         , &[_][]const u8{
@@ -57,7 +57,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("argument causes error", b.host);
+        const case = ctx.obj("argument causes error", b.graph.host);
 
         case.addError(
             \\pub export fn entry() void {
@@ -80,7 +80,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("astgen failure in file struct", b.host);
+        const case = ctx.obj("astgen failure in file struct", b.graph.host);
 
         case.addError(
             \\pub export fn entry() void {
@@ -95,7 +95,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("invalid store to comptime field", b.host);
+        const case = ctx.obj("invalid store to comptime field", b.graph.host);
 
         case.addError(
             \\const a = @import("a.zig");
@@ -119,7 +119,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("file in multiple modules", b.host);
+        const case = ctx.obj("file in multiple modules", b.graph.host);
         case.addDepModule("foo", "foo.zig");
 
         case.addError(
@@ -138,7 +138,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("wrong same named struct", b.host);
+        const case = ctx.obj("wrong same named struct", b.graph.host);
 
         case.addError(
             \\const a = @import("a.zig");
@@ -172,7 +172,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("non-printable invalid character", b.host);
+        const case = ctx.obj("non-printable invalid character", b.graph.host);
 
         case.addError("\xff\xfe" ++
             \\export fn foo() bool {
@@ -185,7 +185,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
     }
 
     {
-        const case = ctx.obj("imported generic method call with invalid param", b.host);
+        const case = ctx.obj("imported generic method call with invalid param", b.graph.host);
 
         case.addError(
             \\pub const import = @import("import.zig");
test/tests.zig
@@ -658,7 +658,7 @@ pub fn addStackTraceTests(
     const check_exe = b.addExecutable(.{
         .name = "check-stack-trace",
         .root_source_file = b.path("test/src/check-stack-trace.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = .Debug,
     });
 
build.zig
@@ -72,7 +72,7 @@ pub fn build(b: *std.Build) !void {
     const check_case_exe = b.addExecutable(.{
         .name = "check-case",
         .root_source_file = b.path("test/src/Cases.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = optimize,
         .single_threaded = single_threaded,
     });
@@ -541,7 +541,7 @@ pub fn build(b: *std.Build) !void {
     const opt_mingw_src_path = b.option([]const u8, "mingw-src", "path to mingw-w64 source directory");
     const update_mingw_exe = b.addExecutable(.{
         .name = "update_mingw",
-        .target = b.host,
+        .target = b.graph.host,
         .root_source_file = b.path("tools/update_mingw.zig"),
     });
     const update_mingw_run = b.addRunArtifact(update_mingw_exe);
@@ -1259,7 +1259,7 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
     const doctest_exe = b.addExecutable(.{
         .name = "doctest",
         .root_source_file = b.path("tools/doctest.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = .Debug,
     });
 
@@ -1297,7 +1297,7 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
     const docgen_exe = b.addExecutable(.{
         .name = "docgen",
         .root_source_file = b.path("tools/docgen.zig"),
-        .target = b.host,
+        .target = b.graph.host,
         .optimize = .Debug,
     });