| ... | ... | @@ -5,23 +5,45 @@ const LibExeObjectStep = std.build.LibExeObjStep; |
| 5 | 5 | pub fn build(b: *Builder) void { |
| 6 | 6 | const test_step = b.step("test", "Test"); |
| 7 | 7 | test_step.dependOn(b.getInstallStep()); |
| 8 | | testUuid(b, test_step, .ReleaseSafe, "46b333df88f5314686fc0cba3b939ca8"); |
| 9 | | testUuid(b, test_step, .ReleaseFast, "46b333df88f5314686fc0cba3b939ca8"); |
| 10 | | testUuid(b, test_step, .ReleaseSmall, "46b333df88f5314686fc0cba3b939ca8"); |
| 8 | |
| 9 | // We force cross-compilation to ensure we always pick a generic CPU with constant set of CPU features. |
| 10 | const aarch64_macos = std.zig.CrossTarget{ |
| 11 | .cpu_arch = .aarch64, |
| 12 | .os_tag = .macos, |
| 13 | }; |
| 14 | |
| 15 | testUuid(b, test_step, .ReleaseSafe, aarch64_macos, "46b333df88f5314686fc0cba3b939ca8"); |
| 16 | testUuid(b, test_step, .ReleaseFast, aarch64_macos, "46b333df88f5314686fc0cba3b939ca8"); |
| 17 | testUuid(b, test_step, .ReleaseSmall, aarch64_macos, "46b333df88f5314686fc0cba3b939ca8"); |
| 18 | |
| 19 | const x86_64_macos = std.zig.CrossTarget{ |
| 20 | .cpu_arch = .x86_64, |
| 21 | .os_tag = .macos, |
| 22 | }; |
| 23 | |
| 24 | testUuid(b, test_step, .ReleaseSafe, x86_64_macos, "342ac765194131e1bad5692b9e0e54a4"); |
| 25 | testUuid(b, test_step, .ReleaseFast, x86_64_macos, "342ac765194131e1bad5692b9e0e54a4"); |
| 26 | testUuid(b, test_step, .ReleaseSmall, x86_64_macos, "f119310e24773ecf8ec42e09d0379dad"); |
| 11 | 27 | } |
| 12 | 28 | |
| 13 | | fn testUuid(b: *Builder, test_step: *std.build.Step, mode: std.builtin.Mode, comptime exp: []const u8) void { |
| 29 | fn testUuid( |
| 30 | b: *Builder, |
| 31 | test_step: *std.build.Step, |
| 32 | mode: std.builtin.Mode, |
| 33 | target: std.zig.CrossTarget, |
| 34 | comptime exp: []const u8, |
| 35 | ) void { |
| 14 | 36 | // The calculated UUID value is independent of debug info and so it should |
| 15 | 37 | // stay the same across builds. |
| 16 | 38 | { |
| 17 | | const dylib = simpleDylib(b, mode); |
| 39 | const dylib = simpleDylib(b, mode, target); |
| 18 | 40 | const check_dylib = dylib.checkObject(.macho); |
| 19 | 41 | check_dylib.checkStart("cmd UUID"); |
| 20 | 42 | check_dylib.checkNext("uuid " ++ exp); |
| 21 | 43 | test_step.dependOn(&check_dylib.step); |
| 22 | 44 | } |
| 23 | 45 | { |
| 24 | | const dylib = simpleDylib(b, mode); |
| 46 | const dylib = simpleDylib(b, mode, target); |
| 25 | 47 | dylib.strip = true; |
| 26 | 48 | const check_dylib = dylib.checkObject(.macho); |
| 27 | 49 | check_dylib.checkStart("cmd UUID"); |
| ... | ... | @@ -30,10 +52,10 @@ fn testUuid(b: *Builder, test_step: *std.build.Step, mode: std.builtin.Mode, com |
| 30 | 52 | } |
| 31 | 53 | } |
| 32 | 54 | |
| 33 | | fn simpleDylib(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep { |
| 55 | fn simpleDylib(b: *Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget) *LibExeObjectStep { |
| 34 | 56 | const dylib = b.addSharedLibrary("test", null, b.version(1, 0, 0)); |
| 57 | dylib.setTarget(target); |
| 35 | 58 | dylib.setBuildMode(mode); |
| 36 | | dylib.setTarget(.{ .cpu_arch = .aarch64, .os_tag = .macos }); |
| 37 | 59 | dylib.addCSourceFile("test.c", &.{}); |
| 38 | 60 | dylib.linkLibC(); |
| 39 | 61 | return dylib; |