authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-07-25 22:52:29+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-07-26 08:10:53+02:00
log5131d074d85812c3d4298eba6ea6358261917e07
tree6d1aee0217a0ced7d88a294407e13f307e34d9b3
parent3b3ce449e333c233767737b0f57bc2f01fd8beaa

link-test: add test for TBDv3 updated parsing logic


4 files changed, 70 insertions(+), 0 deletions(-)

test/link.zig+4
...@@ -160,6 +160,10 @@ pub const cases = [_]Case{...@@ -160,6 +160,10 @@ pub const cases = [_]Case{
160 .build_root = "test/link/macho/strict_validation",160 .build_root = "test/link/macho/strict_validation",
161 .import = @import("link/macho/strict_validation/build.zig"),161 .import = @import("link/macho/strict_validation/build.zig"),
162 },162 },
163 .{
164 .build_root = "test/link/macho/tbdv3",
165 .import = @import("link/macho/tbdv3/build.zig"),
166 },
163 .{167 .{
164 .build_root = "test/link/macho/tls",168 .build_root = "test/link/macho/tls",
165 .import = @import("link/macho/tls/build.zig"),169 .import = @import("link/macho/tls/build.zig"),
test/link/macho/tbdv3/a.c created+3
...@@ -0,0 +1,3 @@
1int getFoo() {
2 return 42;
3}
test/link/macho/tbdv3/build.zig created+56
...@@ -0,0 +1,56 @@
1const std = @import("std");
2const builtin = @import("builtin");
3
4pub const requires_symlinks = true;
5pub const requires_macos_sdk = false;
6
7pub fn build(b: *std.Build) void {
8 const test_step = b.step("test", "Test it");
9 b.default_step = test_step;
10
11 add(b, test_step, .Debug);
12 add(b, test_step, .ReleaseFast);
13 add(b, test_step, .ReleaseSmall);
14 add(b, test_step, .ReleaseSafe);
15}
16
17fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
18 const target: std.zig.CrossTarget = .{ .os_tag = .macos };
19
20 const lib = b.addSharedLibrary(.{
21 .name = "a",
22 .version = .{ .major = 1, .minor = 0, .patch = 0 },
23 .optimize = optimize,
24 .target = target,
25 });
26 lib.addCSourceFile("a.c", &.{});
27 lib.linkLibC();
28
29 const tbd_file = b.addWriteFile("liba.tbd",
30 \\--- !tapi-tbd-v3
31 \\archs: [ arm64 ]
32 \\uuids: [ 'arm64: DEADBEEF' ]
33 \\platform: macos
34 \\install-name: @rpath/liba.dylib
35 \\current-version: 0
36 \\exports:
37 \\ - archs: [ arm64 ]
38 \\ symbols: [ _getFoo ]
39 );
40
41 const exe = b.addExecutable(.{
42 .name = "main",
43 .root_source_file = .{ .path = "main.c" },
44 .optimize = optimize,
45 .target = target,
46 });
47 exe.linkSystemLibrary("a");
48 exe.addLibraryPathDirectorySource(tbd_file.getDirectorySource());
49 exe.addRPathDirectorySource(lib.getOutputDirectorySource());
50 exe.linkLibC();
51
52 const run = b.addRunArtifact(exe);
53 run.skip_foreign_checks = true;
54
55 test_step.dependOn(&run.step);
56}
test/link/macho/tbdv3/main.c created+7
...@@ -0,0 +1,7 @@
1#include <stdio.h>
2
3int getFoo();
4
5int main() {
6 return getFoo() - 42;
7}