| ... | ... | @@ -42,6 +42,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 42 | 42 | |
| 43 | 43 | // Tests requiring presence of macOS SDK in system path |
| 44 | 44 | if (build_opts.has_macos_sdk) { |
| 45 | macho_step.dependOn(testDeadStripDylibs(b, .{ .target = b.host })); |
| 45 | 46 | macho_step.dependOn(testHeaderpad(b, .{ .target = b.host })); |
| 46 | 47 | macho_step.dependOn(testNeededFramework(b, .{ .target = b.host })); |
| 47 | 48 | macho_step.dependOn(testWeakFramework(b, .{ .target = b.host })); |
| ... | ... | @@ -132,6 +133,55 @@ fn testDeadStrip(b: *Build, opts: Options) *Step { |
| 132 | 133 | return test_step; |
| 133 | 134 | } |
| 134 | 135 | |
| 136 | fn testDeadStripDylibs(b: *Build, opts: Options) *Step { |
| 137 | const test_step = addTestStep(b, "macho-dead-strip-dylibs", opts); |
| 138 | |
| 139 | const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = |
| 140 | \\#include <objc/runtime.h> |
| 141 | \\int main() { |
| 142 | \\ if (objc_getClass("NSObject") == 0) { |
| 143 | \\ return -1; |
| 144 | \\ } |
| 145 | \\ if (objc_getClass("NSApplication") == 0) { |
| 146 | \\ return -2; |
| 147 | \\ } |
| 148 | \\ return 0; |
| 149 | \\} |
| 150 | }); |
| 151 | |
| 152 | { |
| 153 | const exe = addExecutable(b, opts, .{ .name = "main1" }); |
| 154 | exe.addObject(main_o); |
| 155 | exe.root_module.linkFramework("Cocoa", .{}); |
| 156 | |
| 157 | const check = exe.checkObject(); |
| 158 | check.checkInHeaders(); |
| 159 | check.checkExact("cmd LOAD_DYLIB"); |
| 160 | check.checkContains("Cocoa"); |
| 161 | check.checkInHeaders(); |
| 162 | check.checkExact("cmd LOAD_DYLIB"); |
| 163 | check.checkContains("libobjc"); |
| 164 | test_step.dependOn(&check.step); |
| 165 | |
| 166 | const run = addRunArtifact(exe); |
| 167 | run.expectExitCode(0); |
| 168 | test_step.dependOn(&run.step); |
| 169 | } |
| 170 | |
| 171 | { |
| 172 | const exe = addExecutable(b, opts, .{ .name = "main2" }); |
| 173 | exe.addObject(main_o); |
| 174 | exe.root_module.linkFramework("Cocoa", .{}); |
| 175 | exe.dead_strip_dylibs = true; |
| 176 | |
| 177 | const run = addRunArtifact(exe); |
| 178 | run.expectExitCode(@as(u8, @bitCast(@as(i8, -2)))); |
| 179 | test_step.dependOn(&run.step); |
| 180 | } |
| 181 | |
| 182 | return test_step; |
| 183 | } |
| 184 | |
| 135 | 185 | fn testEntryPointDylib(b: *Build, opts: Options) *Step { |
| 136 | 186 | const test_step = addTestStep(b, "macho-entry-point-dylib", opts); |
| 137 | 187 | |