mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
link-test: add test for TBDv3 updated parsing logic
This commit is contained in:
parent
3b3ce449e3
commit
5131d074d8
@ -160,6 +160,10 @@ pub const cases = [_]Case{
|
||||
.build_root = "test/link/macho/strict_validation",
|
||||
.import = @import("link/macho/strict_validation/build.zig"),
|
||||
},
|
||||
.{
|
||||
.build_root = "test/link/macho/tbdv3",
|
||||
.import = @import("link/macho/tbdv3/build.zig"),
|
||||
},
|
||||
.{
|
||||
.build_root = "test/link/macho/tls",
|
||||
.import = @import("link/macho/tls/build.zig"),
|
||||
|
||||
3
test/link/macho/tbdv3/a.c
Normal file
3
test/link/macho/tbdv3/a.c
Normal file
@ -0,0 +1,3 @@
|
||||
int getFoo() {
|
||||
return 42;
|
||||
}
|
||||
56
test/link/macho/tbdv3/build.zig
Normal file
56
test/link/macho/tbdv3/build.zig
Normal file
@ -0,0 +1,56 @@
|
||||
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: std.zig.CrossTarget = .{ .os_tag = .macos };
|
||||
|
||||
const lib = b.addSharedLibrary(.{
|
||||
.name = "a",
|
||||
.version = .{ .major = 1, .minor = 0, .patch = 0 },
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
});
|
||||
lib.addCSourceFile("a.c", &.{});
|
||||
lib.linkLibC();
|
||||
|
||||
const tbd_file = b.addWriteFile("liba.tbd",
|
||||
\\--- !tapi-tbd-v3
|
||||
\\archs: [ arm64 ]
|
||||
\\uuids: [ 'arm64: DEADBEEF' ]
|
||||
\\platform: macos
|
||||
\\install-name: @rpath/liba.dylib
|
||||
\\current-version: 0
|
||||
\\exports:
|
||||
\\ - archs: [ arm64 ]
|
||||
\\ symbols: [ _getFoo ]
|
||||
);
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "main",
|
||||
.root_source_file = .{ .path = "main.c" },
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
});
|
||||
exe.linkSystemLibrary("a");
|
||||
exe.addLibraryPathDirectorySource(tbd_file.getDirectorySource());
|
||||
exe.addRPathDirectorySource(lib.getOutputDirectorySource());
|
||||
exe.linkLibC();
|
||||
|
||||
const run = b.addRunArtifact(exe);
|
||||
run.skip_foreign_checks = true;
|
||||
|
||||
test_step.dependOn(&run.step);
|
||||
}
|
||||
7
test/link/macho/tbdv3/main.c
Normal file
7
test/link/macho/tbdv3/main.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int getFoo();
|
||||
|
||||
int main() {
|
||||
return getFoo() - 42;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user