authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-27 16:43:21+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-27 16:43:35+01:00
log8d29c84d007849d82268f80c902742a7a19ba400
tree2ef61aecd1cb3d6a421e01f792b7b89471c5c29f
parent6925ef0f1af0497c6ea454348b0c3fbe451313a9

link-tests: test uuid on x86_64-macos too


1 files changed, 30 insertions(+), 8 deletions(-)

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