authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-31 23:06:00+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-01 14:22:44+02:00
log3874df839d3deabec0e82d0ae19947d655f5713d
tree8d291a94f14583738af2300ecb141d846ea15aa9
parent6f83a741d8f3847c65aa8b791a865f339b77531d

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


3 files changed, 44 insertions(+), 0 deletions(-)

test/link.zig+4
......@@ -104,6 +104,10 @@ pub const cases = [_]Case{
104104 .build_root = "test/link/macho/entry",
105105 .import = @import("link/macho/entry/build.zig"),
106106 },
107 .{
108 .build_root = "test/link/macho/entry_in_archive",
109 .import = @import("link/macho/entry_in_archive/build.zig"),
110 },
107111 .{
108112 .build_root = "test/link/macho/headerpad",
109113 .import = @import("link/macho/headerpad/build.zig"),
test/link/macho/entry_in_archive/build.zig created+35
......@@ -0,0 +1,35 @@
1const std = @import("std");
2
3pub const requires_symlinks = true;
4
5pub fn build(b: *std.Build) void {
6 const test_step = b.step("test", "Test it");
7 b.default_step = test_step;
8
9 add(b, test_step, .Debug);
10 add(b, test_step, .ReleaseFast);
11 add(b, test_step, .ReleaseSmall);
12 add(b, test_step, .ReleaseSafe);
13}
14
15fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
16 const lib = b.addStaticLibrary(.{
17 .name = "main",
18 .optimize = optimize,
19 .target = .{ .os_tag = .macos },
20 });
21 lib.addCSourceFile("main.c", &.{});
22 lib.linkLibC();
23
24 const exe = b.addExecutable(.{
25 .name = "main",
26 .optimize = optimize,
27 .target = .{ .os_tag = .macos },
28 });
29 exe.linkLibrary(lib);
30 exe.linkLibC();
31
32 const run = exe.run();
33 run.expectExitCode(0);
34 test_step.dependOn(&run.step);
35}
test/link/macho/entry_in_archive/main.c created+5
......@@ -0,0 +1,5 @@
1#include <stdio.h>
2
3int main(int argc, char* argv[]) {
4 return 0;
5}