| ... | ... | @@ -62,7 +62,6 @@ pub fn createAndParseFromPath( |
| 62 | 62 | arch: Arch, |
| 63 | 63 | path: []const u8, |
| 64 | 64 | syslibroot: ?[]const u8, |
| 65 | | recurse_libs: bool, |
| 66 | 65 | ) Error!?[]*Dylib { |
| 67 | 66 | const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) { |
| 68 | 67 | error.FileNotFound => return null, |
| ... | ... | @@ -102,11 +101,9 @@ pub fn createAndParseFromPath( |
| 102 | 101 | |
| 103 | 102 | var dylibs = std.ArrayList(*Dylib).init(allocator); |
| 104 | 103 | defer dylibs.deinit(); |
| 105 | | try dylibs.append(dylib); |
| 106 | 104 | |
| 107 | | if (recurse_libs) { |
| 108 | | try dylib.parseDependentLibs(&dylibs); |
| 109 | | } |
| 105 | try dylibs.append(dylib); |
| 106 | try dylib.parseDependentLibs(&dylibs); |
| 110 | 107 | |
| 111 | 108 | return dylibs.toOwnedSlice(); |
| 112 | 109 | } |
| ... | ... | @@ -283,18 +280,17 @@ pub fn parseFromStub(self: *Dylib, lib_stub: LibStub) !void { |
| 283 | 280 | else => unreachable, |
| 284 | 281 | }; |
| 285 | 282 | |
| 286 | | for (lib_stub.inner) |stub| { |
| 287 | | if (!hasTarget(stub.targets, target_string)) continue; |
| 283 | var umbrella_libs = std.StringHashMap(void).init(self.allocator); |
| 284 | defer umbrella_libs.deinit(); |
| 288 | 285 | |
| 289 | | if (stub.reexported_libraries) |reexports| { |
| 290 | | for (reexports) |reexp| { |
| 291 | | if (!hasTarget(reexp.targets, target_string)) continue; |
| 286 | for (lib_stub.inner) |stub, stub_index| { |
| 287 | if (!hasTarget(stub.targets, target_string)) continue; |
| 292 | 288 | |
| 293 | | try self.dependent_libs.ensureUnusedCapacity(self.allocator, reexp.libraries.len); |
| 294 | | for (reexp.libraries) |lib| { |
| 295 | | self.dependent_libs.putAssumeCapacity(try self.allocator.dupe(u8, lib), {}); |
| 296 | | } |
| 297 | | } |
| 289 | if (stub_index > 0) { |
| 290 | // TODO I thought that we could switch on presence of `parent-umbrella` map; |
| 291 | // however, turns out `libsystem_notify.dylib` is fully reexported by `libSystem.dylib` |
| 292 | // BUT does not feature a `parent-umbrella` map as the only sublib. Apple's bug perhaps? |
| 293 | try umbrella_libs.put(stub.install_name, .{}); |
| 298 | 294 | } |
| 299 | 295 | |
| 300 | 296 | if (stub.exports) |exports| { |
| ... | ... | @@ -341,6 +337,29 @@ pub fn parseFromStub(self: *Dylib, lib_stub: LibStub) !void { |
| 341 | 337 | } |
| 342 | 338 | } |
| 343 | 339 | } |
| 340 | |
| 341 | log.debug("{s}", .{umbrella_lib.install_name}); |
| 342 | |
| 343 | // TODO track which libs were already parsed in different steps |
| 344 | for (lib_stub.inner) |stub| { |
| 345 | if (!hasTarget(stub.targets, target_string)) continue; |
| 346 | |
| 347 | if (stub.reexported_libraries) |reexports| { |
| 348 | for (reexports) |reexp| { |
| 349 | if (!hasTarget(reexp.targets, target_string)) continue; |
| 350 | |
| 351 | for (reexp.libraries) |lib| { |
| 352 | if (umbrella_libs.contains(lib)) { |
| 353 | log.debug(" | {s} <= {s}", .{ lib, umbrella_lib.install_name }); |
| 354 | continue; |
| 355 | } |
| 356 | |
| 357 | log.debug(" | {s}", .{lib}); |
| 358 | try self.dependent_libs.put(self.allocator, try self.allocator.dupe(u8, lib), {}); |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | } |
| 344 | 363 | } |
| 345 | 364 | |
| 346 | 365 | pub fn parseDependentLibs(self: *Dylib, out: *std.ArrayList(*Dylib)) !void { |
| ... | ... | @@ -374,7 +393,6 @@ pub fn parseDependentLibs(self: *Dylib, out: *std.ArrayList(*Dylib)) !void { |
| 374 | 393 | self.arch.?, |
| 375 | 394 | lib_path, |
| 376 | 395 | self.syslibroot, |
| 377 | | true, |
| 378 | 396 | )) orelse { |
| 379 | 397 | continue; |
| 380 | 398 | }; |