authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-14 10:23:11+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
log105655857f02c8bd59f5c0250f124a064df400cf
tree8011d253e5f769da3ace6654b2dd90078c3096cc
parente96f8b817a889abecc86a71961ba9a95c13c315e

test/link/macho: upgrade weak framework test


4 files changed, 20 insertions(+), 41 deletions(-)

test/link.zig-4
......@@ -171,8 +171,4 @@ pub const cases = [_]Case{
171171 .build_root = "test/link/macho/unwind_info",
172172 .import = @import("link/macho/unwind_info/build.zig"),
173173 },
174 .{
175 .build_root = "test/link/macho/weak_framework",
176 .import = @import("link/macho/weak_framework/build.zig"),
177 },
178174};
test/link/macho.zig+20
......@@ -32,6 +32,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
3232 if (build_opts.has_macos_sdk) {
3333 macho_step.dependOn(testHeaderpad(b, .{ .target = b.host }));
3434 macho_step.dependOn(testNeededFramework(b, .{ .target = b.host }));
35 macho_step.dependOn(testWeakFramework(b, .{ .target = b.host }));
3536 }
3637 }
3738
......@@ -767,6 +768,25 @@ fn testWeakBind(b: *Build, opts: Options) *Step {
767768 return test_step;
768769}
769770
771fn testWeakFramework(b: *Build, opts: Options) *Step {
772 const test_step = addTestStep(b, "macho-weak-framework", opts);
773
774 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });
775 exe.root_module.linkFramework("Cocoa", .{ .weak = true });
776
777 const run = addRunArtifact(exe);
778 run.expectExitCode(0);
779 test_step.dependOn(&run.step);
780
781 const check = exe.checkObject();
782 check.checkInHeaders();
783 check.checkExact("cmd LOAD_WEAK_DYLIB");
784 check.checkContains("Cocoa");
785 test_step.dependOn(&check.step);
786
787 return test_step;
788}
789
770790fn testWeakLibrary(b: *Build, opts: Options) *Step {
771791 const test_step = addTestStep(b, "macho-weak-library", opts);
772792
test/link/macho/weak_framework/build.zig deleted-34
......@@ -1,34 +0,0 @@
1const std = @import("std");
2
3pub const requires_symlinks = true;
4pub const requires_macos_sdk = true;
5
6pub fn build(b: *std.Build) void {
7 const test_step = b.step("test", "Test it");
8 b.default_step = test_step;
9
10 add(b, test_step, .Debug);
11 add(b, test_step, .ReleaseFast);
12 add(b, test_step, .ReleaseSmall);
13 add(b, test_step, .ReleaseSafe);
14}
15
16fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
17 const exe = b.addExecutable(.{
18 .name = "test",
19 .optimize = optimize,
20 .target = b.host,
21 });
22 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
23 exe.linkLibC();
24 exe.linkFrameworkWeak("Cocoa");
25
26 const check = exe.checkObject();
27 check.checkInHeaders();
28 check.checkExact("cmd LOAD_WEAK_DYLIB");
29 check.checkContains("Cocoa");
30 test_step.dependOn(&check.step);
31
32 const run_cmd = b.addRunArtifact(exe);
33 test_step.dependOn(&run_cmd.step);
34}
test/link/macho/weak_framework/main.c deleted-3
......@@ -1,3 +0,0 @@
1int main(int argc, char* argv[]) {
2 return 0;
3}