diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-01-15 12:05:26 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-01-24 12:34:40 +0100 |
| commit | 2b3ac3e82f4207981469739b4ecd9fa0c3ac3308 (patch) | |
| tree | 92d69521c967826a29b78d0a1302eb0eeff22f99 | |
| parent | a3f68c6fa23f893597b7708e0c00e81f57cb35c1 (diff) | |
| download | zig-2b3ac3e82f4207981469739b4ecd9fa0c3ac3308.tar.gz zig-2b3ac3e82f4207981469739b4ecd9fa0c3ac3308.zip | |
test/link/macho: upgrade tbdv3 test
| -rw-r--r-- | test/link.zig | 4 | ||||
| -rw-r--r-- | test/link/macho.zig | 39 | ||||
| -rw-r--r-- | test/link/macho/tbdv3/a.c | 3 | ||||
| -rw-r--r-- | test/link/macho/tbdv3/build.zig | 57 | ||||
| -rw-r--r-- | test/link/macho/tbdv3/main.c | 7 |
5 files changed, 39 insertions, 71 deletions
diff --git a/test/link.zig b/test/link.zig index 3f85cd1a20..8cd04a9142 100644 --- a/test/link.zig +++ b/test/link.zig @@ -115,8 +115,4 @@ pub const cases = [_]Case{ .build_root = "test/link/macho/objcpp", .import = @import("link/macho/objcpp/build.zig"), }, - .{ - .build_root = "test/link/macho/tbdv3", - .import = @import("link/macho/tbdv3/build.zig"), - }, }; diff --git a/test/link/macho.zig b/test/link/macho.zig index 6692b1888b..f4018089f8 100644 --- a/test/link/macho.zig +++ b/test/link/macho.zig @@ -50,6 +50,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { macho_step.dependOn(testDylib(b, .{ .target = default_target })); macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); macho_step.dependOn(testSearchStrategy(b, .{ .target = default_target })); + macho_step.dependOn(testTbdv3(b, .{ .target = default_target })); macho_step.dependOn(testTls(b, .{ .target = default_target })); macho_step.dependOn(testTwoLevelNamespace(b, .{ .target = default_target })); macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); @@ -1285,6 +1286,44 @@ fn testStackSize(b: *Build, opts: Options) *Step { return test_step; } +fn testTbdv3(b: *Build, opts: Options) *Step { + const test_step = addTestStep(b, "macho-tbdv3", opts); + + const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes = "int getFoo() { return 42; }" }); + + const tbd = tbd: { + const wf = WriteFile.create(b); + break :tbd wf.add("liba.tbd", + \\--- !tapi-tbd-v3 + \\archs: [ arm64, x86_64 ] + \\uuids: [ 'arm64: DEADBEEF', 'x86_64: BEEFDEAD' ] + \\platform: macos + \\install-name: @rpath/liba.dylib + \\current-version: 0 + \\exports: + \\ - archs: [ arm64, x86_64 ] + \\ symbols: [ _getFoo ] + ); + }; + + const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = + \\#include <stdio.h> + \\int getFoo(); + \\int main() { + \\ return getFoo() - 42; + \\} + }); + exe.root_module.linkSystemLibrary("a", .{}); + exe.root_module.addLibraryPath(tbd.dirname()); + exe.root_module.addRPath(dylib.getEmittedBinDirectory()); + + const run = addRunArtifact(exe); + run.expectExitCode(0); + test_step.dependOn(&run.step); + + return test_step; +} + fn testTentative(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "macho-tentative", opts); diff --git a/test/link/macho/tbdv3/a.c b/test/link/macho/tbdv3/a.c deleted file mode 100644 index ddd18ee4b6..0000000000 --- a/test/link/macho/tbdv3/a.c +++ /dev/null @@ -1,3 +0,0 @@ -int getFoo() { - return 42; -} diff --git a/test/link/macho/tbdv3/build.zig b/test/link/macho/tbdv3/build.zig deleted file mode 100644 index 547f72c25f..0000000000 --- a/test/link/macho/tbdv3/build.zig +++ /dev/null @@ -1,57 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); - -pub const requires_symlinks = true; -pub const requires_macos_sdk = false; - -pub fn build(b: *std.Build) void { - const test_step = b.step("test", "Test it"); - b.default_step = test_step; - - add(b, test_step, .Debug); - add(b, test_step, .ReleaseFast); - add(b, test_step, .ReleaseSmall); - add(b, test_step, .ReleaseSafe); -} - -fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { - const target = b.resolveTargetQuery(.{ .os_tag = .macos }); - - const lib = b.addSharedLibrary(.{ - .name = "a", - .version = .{ .major = 1, .minor = 0, .patch = 0 }, - .optimize = optimize, - .target = target, - }); - lib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); - lib.linkLibC(); - - const tbd_file = b.addWriteFile("liba.tbd", - \\--- !tapi-tbd-v3 - \\archs: [ arm64, x86_64 ] - \\uuids: [ 'arm64: DEADBEEF', 'x86_64: BEEFDEAD' ] - \\platform: macos - \\install-name: @rpath/liba.dylib - \\current-version: 0 - \\exports: - \\ - archs: [ arm64, x86_64 ] - \\ symbols: [ _getFoo ] - ); - - const exe = b.addExecutable(.{ - .name = "test", - .optimize = optimize, - .target = target, - }); - exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} }); - exe.linkSystemLibrary("a"); - exe.addLibraryPath(tbd_file.getDirectory()); - exe.addRPath(lib.getEmittedBinDirectory()); - exe.linkLibC(); - - const run = b.addRunArtifact(exe); - run.skip_foreign_checks = true; - run.expectExitCode(0); - - test_step.dependOn(&run.step); -} diff --git a/test/link/macho/tbdv3/main.c b/test/link/macho/tbdv3/main.c deleted file mode 100644 index 3cf37ae590..0000000000 --- a/test/link/macho/tbdv3/main.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdio.h> - -int getFoo(); - -int main() { - return getFoo() - 42; -} |
