| ... | ... | @@ -214,11 +214,11 @@ pub const Builder = struct { |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { |
| 217 | | return addExecutableSource(self, name, convertOptionalPathToFileSource(root_src), .static); |
| 217 | return addExecutableSource(self, name, convertOptionalPathToFileSource(root_src)); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | | pub fn addExecutableSource(builder: *Builder, name: []const u8, root_src: ?FileSource, linkage: LibExeObjStep.Linkage) *LibExeObjStep { |
| 221 | | return LibExeObjStep.createExecutable(builder, name, root_src, linkage); |
| 220 | pub fn addExecutableSource(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep { |
| 221 | return LibExeObjStep.createExecutable(builder, name, root_src); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | pub fn addObject(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { |
| ... | ... | @@ -1363,7 +1363,7 @@ pub const LibExeObjStep = struct { |
| 1363 | 1363 | linker_script: ?FileSource = null, |
| 1364 | 1364 | version_script: ?[]const u8 = null, |
| 1365 | 1365 | out_filename: []const u8, |
| 1366 | | linkage: Linkage, |
| 1366 | linkage: ?Linkage = null, |
| 1367 | 1367 | version: ?Version, |
| 1368 | 1368 | build_mode: builtin.Mode, |
| 1369 | 1369 | kind: Kind, |
| ... | ... | @@ -1517,15 +1517,15 @@ pub const LibExeObjStep = struct { |
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | pub fn createObject(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep { |
| 1520 | | return initExtraArgs(builder, name, root_src, .obj, .static, null); |
| 1520 | return initExtraArgs(builder, name, root_src, .obj, null, null); |
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | | pub fn createExecutable(builder: *Builder, name: []const u8, root_src: ?FileSource, linkage: Linkage) *LibExeObjStep { |
| 1524 | | return initExtraArgs(builder, name, root_src, .exe, linkage, null); |
| 1523 | pub fn createExecutable(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep { |
| 1524 | return initExtraArgs(builder, name, root_src, .exe, null, null); |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | pub fn createTest(builder: *Builder, name: []const u8, root_src: FileSource) *LibExeObjStep { |
| 1528 | | return initExtraArgs(builder, name, root_src, .@"test", .static, null); |
| 1528 | return initExtraArgs(builder, name, root_src, .@"test", null, null); |
| 1529 | 1529 | } |
| 1530 | 1530 | |
| 1531 | 1531 | fn initExtraArgs( |
| ... | ... | @@ -1533,7 +1533,7 @@ pub const LibExeObjStep = struct { |
| 1533 | 1533 | name_raw: []const u8, |
| 1534 | 1534 | root_src_raw: ?FileSource, |
| 1535 | 1535 | kind: Kind, |
| 1536 | | linkage: Linkage, |
| 1536 | linkage: ?Linkage, |
| 1537 | 1537 | ver: ?Version, |
| 1538 | 1538 | ) *LibExeObjStep { |
| 1539 | 1539 | const name = builder.dupe(name_raw); |
| ... | ... | @@ -1613,15 +1613,15 @@ pub const LibExeObjStep = struct { |
| 1613 | 1613 | .obj => .Obj, |
| 1614 | 1614 | .exe, .@"test" => .Exe, |
| 1615 | 1615 | }, |
| 1616 | | .link_mode = switch (self.linkage) { |
| 1616 | .link_mode = if (self.linkage) |some| @as(std.builtin.LinkMode, switch (some) { |
| 1617 | 1617 | .dynamic => .Dynamic, |
| 1618 | 1618 | .static => .Static, |
| 1619 | | }, |
| 1619 | }) else null, |
| 1620 | 1620 | .version = self.version, |
| 1621 | 1621 | }) catch unreachable; |
| 1622 | 1622 | |
| 1623 | 1623 | if (self.kind == .lib) { |
| 1624 | | if (self.linkage == .static) { |
| 1624 | if (self.linkage != null and self.linkage.? == .static) { |
| 1625 | 1625 | self.out_lib_filename = self.out_filename; |
| 1626 | 1626 | } else if (self.version) |version| { |
| 1627 | 1627 | if (target.isDarwin()) { |
| ... | ... | @@ -1725,7 +1725,7 @@ pub const LibExeObjStep = struct { |
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | pub fn isDynamicLibrary(self: *LibExeObjStep) bool { |
| 1728 | | return self.kind == .lib and self.linkage == .dynamic; |
| 1728 | return self.kind == .lib and self.linkage != null and self.linkage.? == .dynamic; |
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | 1731 | pub fn producesPdbFile(self: *LibExeObjStep) bool { |
| ... | ... | @@ -2298,7 +2298,7 @@ pub const LibExeObjStep = struct { |
| 2298 | 2298 | const full_path_lib = other.getOutputLibSource().getPath(builder); |
| 2299 | 2299 | try zig_args.append(full_path_lib); |
| 2300 | 2300 | |
| 2301 | | if (other.linkage == .dynamic and !self.target.isWindows()) { |
| 2301 | if (other.linkage != null and other.linkage.? == .dynamic and !self.target.isWindows()) { |
| 2302 | 2302 | if (fs.path.dirname(full_path_lib)) |dirname| { |
| 2303 | 2303 | try zig_args.append("-rpath"); |
| 2304 | 2304 | try zig_args.append(dirname); |
| ... | ... | @@ -2464,15 +2464,17 @@ pub const LibExeObjStep = struct { |
| 2464 | 2464 | zig_args.append("--name") catch unreachable; |
| 2465 | 2465 | zig_args.append(self.name) catch unreachable; |
| 2466 | 2466 | |
| 2467 | | if (self.kind == .lib and self.linkage == .dynamic) { |
| 2467 | if (self.linkage) |some| switch (some) { |
| 2468 | .dynamic => try zig_args.append("-dynamic"), |
| 2469 | .static => try zig_args.append("-static"), |
| 2470 | }; |
| 2471 | if (self.kind == .lib and self.linkage != null and self.linkage.? == .dynamic) { |
| 2468 | 2472 | if (self.version) |version| { |
| 2469 | 2473 | zig_args.append("--version") catch unreachable; |
| 2470 | 2474 | zig_args.append(builder.fmt("{}", .{version})) catch unreachable; |
| 2471 | 2475 | } |
| 2472 | 2476 | } |
| 2473 | | if (self.linkage == .dynamic) { |
| 2474 | | try zig_args.append("-dynamic"); |
| 2475 | | } |
| 2477 | |
| 2476 | 2478 | if (self.bundle_compiler_rt) |x| { |
| 2477 | 2479 | if (x) { |
| 2478 | 2480 | try zig_args.append("-fcompiler-rt"); |
| ... | ... | @@ -2801,7 +2803,7 @@ pub const LibExeObjStep = struct { |
| 2801 | 2803 | } |
| 2802 | 2804 | } |
| 2803 | 2805 | |
| 2804 | | if (self.kind == .lib and self.linkage == .dynamic and self.version != null and self.target.wantSharedLibSymLinks()) { |
| 2806 | if (self.kind == .lib and self.linkage != null and self.linkage.? == .dynamic and self.version != null and self.target.wantSharedLibSymLinks()) { |
| 2805 | 2807 | try doAtomicSymLinks(builder.allocator, self.getOutputSource().getPath(builder), self.major_only_filename.?, self.name_only_filename.?); |
| 2806 | 2808 | } |
| 2807 | 2809 | } |