| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); |
| 3 | const Builder = std.build.Builder; |
| 4 | const LibExeObjectStep = std.build.LibExeObjStep; |
| 5 | |
| 6 | pub fn build(b: *Builder) void { |
| 7 | const test_step = b.step("test", "Test"); |
| 8 | test_step.dependOn(b.getInstallStep()); |
| 9 | |
| 10 | switch (builtin.cpu.arch) { |
| 11 | .aarch64 => { |
| 12 | testUuid(b, test_step, .ReleaseSafe, "eb1203019e453d808d4f1e71053af9af"); |
| 13 | testUuid(b, test_step, .ReleaseFast, "eb1203019e453d808d4f1e71053af9af"); |
| 14 | testUuid(b, test_step, .ReleaseSmall, "eb1203019e453d808d4f1e71053af9af"); |
| 15 | }, |
| 16 | .x86_64 => { |
| 17 | testUuid(b, test_step, .ReleaseSafe, "b3598e7c42dc38b0bd2975ead6e4ae85"); |
| 18 | testUuid(b, test_step, .ReleaseFast, "b3598e7c42dc38b0bd2975ead6e4ae85"); |
| 19 | testUuid(b, test_step, .ReleaseSmall, "1064b25eef4e3e6391866188b3dd7156"); |
| 20 | }, |
| 21 | else => unreachable, |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | fn testUuid(b: *Builder, test_step: *std.build.Step, mode: std.builtin.Mode, comptime exp: []const u8) void { |
| 26 | // The calculated UUID value is independent of debug info and so it should |
| 27 | // stay the same across builds. |
| 28 | { |
| 29 | const dylib = simpleDylib(b, mode); |
| 30 | const check_dylib = dylib.checkObject(.macho); |
| 31 | check_dylib.checkStart("cmd UUID"); |
| 32 | check_dylib.checkNext("uuid " ++ exp); |
| 33 | test_step.dependOn(&check_dylib.step); |
| 34 | } |
| 35 | { |
| 36 | const dylib = simpleDylib(b, mode); |
| 37 | dylib.strip = true; |
| 38 | const check_dylib = dylib.checkObject(.macho); |
| 39 | check_dylib.checkStart("cmd UUID"); |
| 40 | check_dylib.checkNext("uuid " ++ exp); |
| 41 | test_step.dependOn(&check_dylib.step); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | fn simpleDylib(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep { |
| 46 | const dylib = b.addSharedLibrary("test", null, b.version(1, 0, 0)); |
| 47 | dylib.setBuildMode(mode); |
| 48 | dylib.setTarget(.{ .os_tag = .macos }); |
| 49 | dylib.addCSourceFile("test.c", &.{}); |
| 50 | dylib.linkLibC(); |
| 51 | return dylib; |
| 52 | } |