link-test: add test for entry in a static archive for MachO

This commit is contained in:
Jakub Konka 2023-03-31 23:06:00 +02:00
parent 6f83a741d8
commit 3874df839d
3 changed files with 44 additions and 0 deletions

View File

@ -104,6 +104,10 @@ pub const cases = [_]Case{
.build_root = "test/link/macho/entry",
.import = @import("link/macho/entry/build.zig"),
},
.{
.build_root = "test/link/macho/entry_in_archive",
.import = @import("link/macho/entry_in_archive/build.zig"),
},
.{
.build_root = "test/link/macho/headerpad",
.import = @import("link/macho/headerpad/build.zig"),

View File

@ -0,0 +1,35 @@
const std = @import("std");
pub const requires_symlinks = true;
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 lib = b.addStaticLibrary(.{
.name = "main",
.optimize = optimize,
.target = .{ .os_tag = .macos },
});
lib.addCSourceFile("main.c", &.{});
lib.linkLibC();
const exe = b.addExecutable(.{
.name = "main",
.optimize = optimize,
.target = .{ .os_tag = .macos },
});
exe.linkLibrary(lib);
exe.linkLibC();
const run = exe.run();
run.expectExitCode(0);
test_step.dependOn(&run.step);
}

View File

@ -0,0 +1,5 @@
#include <stdio.h>
int main(int argc, char* argv[]) {
return 0;
}