| ... | @@ -584,24 +584,29 @@ fn resolveLib( | ... | @@ -584,24 +584,29 @@ fn resolveLib( |
| 584 | // Look in each directory for a dylib (next, tbd), and then for archive | 584 | // Look in each directory for a dylib (next, tbd), and then for archive |
| 585 | // TODO implement alternative: -search_dylibs_first | 585 | // TODO implement alternative: -search_dylibs_first |
| 586 | const exts = switch (lib_kind) { | 586 | const exts = switch (lib_kind) { |
| 587 | .lib => &[_][]const u8{ "dylib", "tbd", "a" }, | 587 | .lib => &[_]?[]const u8{ "dylib", "tbd", "a" }, |
| 588 | .framework => &[_][]const u8{ "dylib", "tbd" }, | 588 | .framework => &[_]?[]const u8{ null, "dylib", "tbd" }, |
| 589 | }; | 589 | }; |
| 590 | | 590 | |
| 591 | for (exts) |ext| { | 591 | for (exts) |ext| { |
| 592 | const lib_name_ext = blk: { | 592 | const lib_name_ext = if (ext) |some| |
| | 593 | try std.fmt.allocPrint(arena, "{s}.{s}", .{ lib_name, some }) |
| | 594 | else |
| | 595 | lib_name; |
| | 596 | const with_prefix = blk: { |
| 593 | switch (lib_kind) { | 597 | switch (lib_kind) { |
| 594 | .lib => break :blk try std.fmt.allocPrint(arena, "lib{s}.{s}", .{ lib_name, ext }), | 598 | .lib => { |
| | 599 | break :blk try std.fmt.allocPrint(arena, "lib{s}", .{lib_name_ext}); |
| | 600 | }, |
| 595 | .framework => { | 601 | .framework => { |
| 596 | const prefix = try std.fmt.allocPrint(arena, "{s}.framework", .{lib_name}); | 602 | const prefix = try std.fmt.allocPrint(arena, "{s}.framework", .{lib_name}); |
| 597 | const nn = try std.fmt.allocPrint(arena, "{s}.{s}", .{ lib_name, ext }); | 603 | break :blk try fs.path.join(arena, &[_][]const u8{ prefix, lib_name_ext }); |
| 598 | break :blk try fs.path.join(arena, &[_][]const u8{ prefix, nn }); | | |
| 599 | }, | 604 | }, |
| 600 | } | 605 | } |
| 601 | }; | 606 | }; |
| 602 | | 607 | |
| 603 | for (lib_dirs) |dir| { | 608 | for (lib_dirs) |dir| { |
| 604 | const full_path = try fs.path.join(arena, &[_][]const u8{ dir, lib_name_ext }); | 609 | const full_path = try fs.path.join(arena, &[_][]const u8{ dir, with_prefix }); |
| 605 | | 610 | |
| 606 | // Check if the lib file exists. | 611 | // Check if the lib file exists. |
| 607 | const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) { | 612 | const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) { |