| ... | ... | @@ -1275,6 +1275,15 @@ fn isLibCLibrary(name: []const u8) bool { |
| 1275 | 1275 | return false; |
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | fn isLibCppLibrary(name: []const u8) bool { |
| 1279 | const libcpp_libraries = [_][]const u8{ "c++", "stdc++" }; |
| 1280 | for (libcpp_libraries) |libcpp_lib_name| { |
| 1281 | if (mem.eql(u8, name, libcpp_lib_name)) |
| 1282 | return true; |
| 1283 | } |
| 1284 | return false; |
| 1285 | } |
| 1286 | |
| 1278 | 1287 | pub const FileSource = union(enum) { |
| 1279 | 1288 | /// Relative to build root |
| 1280 | 1289 | path: []const u8, |
| ... | ... | @@ -1381,6 +1390,7 @@ pub const LibExeObjStep = struct { |
| 1381 | 1390 | c_macros: ArrayList([]const u8), |
| 1382 | 1391 | output_dir: ?[]const u8, |
| 1383 | 1392 | is_linking_libc: bool = false, |
| 1393 | is_linking_libcpp: bool = false, |
| 1384 | 1394 | vcpkg_bin_path: ?[]const u8 = null, |
| 1385 | 1395 | |
| 1386 | 1396 | /// This may be set in order to override the default install directory |
| ... | ... | @@ -1661,6 +1671,9 @@ pub const LibExeObjStep = struct { |
| 1661 | 1671 | if (isLibCLibrary(name)) { |
| 1662 | 1672 | return self.is_linking_libc; |
| 1663 | 1673 | } |
| 1674 | if (isLibCppLibrary(name)) { |
| 1675 | return self.is_linking_libcpp; |
| 1676 | } |
| 1664 | 1677 | for (self.link_objects.items) |link_object| { |
| 1665 | 1678 | switch (link_object) { |
| 1666 | 1679 | LinkObject.SystemLib => |n| if (mem.eql(u8, n, name)) return true, |
| ... | ... | @@ -1692,6 +1705,13 @@ pub const LibExeObjStep = struct { |
| 1692 | 1705 | } |
| 1693 | 1706 | } |
| 1694 | 1707 | |
| 1708 | pub fn linkLibCpp(self: *LibExeObjStep) void { |
| 1709 | if (!self.is_linking_libcpp) { |
| 1710 | self.is_linking_libcpp = true; |
| 1711 | self.link_objects.append(LinkObject{ .SystemLib = "c++" }) catch unreachable; |
| 1712 | } |
| 1713 | } |
| 1714 | |
| 1695 | 1715 | /// name_and_value looks like [name]=[value]. If the value is omitted, it is set to 1. |
| 1696 | 1716 | pub fn defineCMacro(self: *LibExeObjStep, name_and_value: []const u8) void { |
| 1697 | 1717 | self.c_macros.append(self.builder.dupe(name_and_value)) catch unreachable; |
| ... | ... | @@ -1798,6 +1818,10 @@ pub const LibExeObjStep = struct { |
| 1798 | 1818 | self.linkLibC(); |
| 1799 | 1819 | return; |
| 1800 | 1820 | } |
| 1821 | if (isLibCppLibrary(name)) { |
| 1822 | self.linkLibCpp(); |
| 1823 | return; |
| 1824 | } |
| 1801 | 1825 | if (self.linkSystemLibraryPkgConfigOnly(name)) |_| { |
| 1802 | 1826 | // pkg-config worked, so nothing further needed to do. |
| 1803 | 1827 | return; |