authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-06-06 17:32:38+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-06 18:01:52-07:00
loga745a17aa96a25dd33bddaa2f8f8239159051fb9
tree4b6bc6a0b185c14c3ee802b40912bf5fec87042f
parent2681e1ffe0822d8574df1d3a733e69e01945e6bf

build: Avoid using undefined variables

Closes #9013 Closes #8928 Closes #7991

1 files changed, 11 insertions(+), 9 deletions(-)

lib/std/build.zig+11-9
...@@ -1336,8 +1336,8 @@ pub const LibExeObjStep = struct {...@@ -1336,8 +1336,8 @@ pub const LibExeObjStep = struct {
1336 version: ?Version,1336 version: ?Version,
1337 build_mode: builtin.Mode,1337 build_mode: builtin.Mode,
1338 kind: Kind,1338 kind: Kind,
1339 major_only_filename: []const u8,1339 major_only_filename: ?[]const u8,
1340 name_only_filename: []const u8,1340 name_only_filename: ?[]const u8,
1341 strip: bool,1341 strip: bool,
1342 lib_paths: ArrayList([]const u8),1342 lib_paths: ArrayList([]const u8),
1343 rpaths: ArrayList([]const u8),1343 rpaths: ArrayList([]const u8),
...@@ -1529,8 +1529,8 @@ pub const LibExeObjStep = struct {...@@ -1529,8 +1529,8 @@ pub const LibExeObjStep = struct {
1529 .out_h_filename = builder.fmt("{s}.h", .{name}),1529 .out_h_filename = builder.fmt("{s}.h", .{name}),
1530 .out_lib_filename = undefined,1530 .out_lib_filename = undefined,
1531 .out_pdb_filename = builder.fmt("{s}.pdb", .{name}),1531 .out_pdb_filename = builder.fmt("{s}.pdb", .{name}),
1532 .major_only_filename = undefined,1532 .major_only_filename = null,
1533 .name_only_filename = undefined,1533 .name_only_filename = null,
1534 .packages = ArrayList(Pkg).init(builder.allocator),1534 .packages = ArrayList(Pkg).init(builder.allocator),
1535 .include_dirs = ArrayList(IncludeDir).init(builder.allocator),1535 .include_dirs = ArrayList(IncludeDir).init(builder.allocator),
1536 .link_objects = ArrayList(LinkObject).init(builder.allocator),1536 .link_objects = ArrayList(LinkObject).init(builder.allocator),
...@@ -2703,7 +2703,7 @@ pub const LibExeObjStep = struct {...@@ -2703,7 +2703,7 @@ pub const LibExeObjStep = struct {
2703 }2703 }
27042704
2705 if (self.kind == Kind.Lib and self.is_dynamic and self.version != null and self.target.wantSharedLibSymLinks()) {2705 if (self.kind == Kind.Lib and self.is_dynamic and self.version != null and self.target.wantSharedLibSymLinks()) {
2706 try doAtomicSymLinks(builder.allocator, self.getOutputPath(), self.major_only_filename, self.name_only_filename);2706 try doAtomicSymLinks(builder.allocator, self.getOutputPath(), self.major_only_filename.?, self.name_only_filename.?);
2707 }2707 }
2708 }2708 }
2709};2709};
...@@ -2746,9 +2746,11 @@ pub const InstallArtifactStep = struct {...@@ -2746,9 +2746,11 @@ pub const InstallArtifactStep = struct {
27462746
2747 builder.pushInstalledFile(self.dest_dir, artifact.out_filename);2747 builder.pushInstalledFile(self.dest_dir, artifact.out_filename);
2748 if (self.artifact.isDynamicLibrary()) {2748 if (self.artifact.isDynamicLibrary()) {
2749 if (self.artifact.version != null) {2749 if (artifact.major_only_filename) |name| {
2750 builder.pushInstalledFile(.Lib, artifact.major_only_filename);2750 builder.pushInstalledFile(.Lib, name);
2751 builder.pushInstalledFile(.Lib, artifact.name_only_filename);2751 }
2752 if (artifact.name_only_filename) |name| {
2753 builder.pushInstalledFile(.Lib, name);
2752 }2754 }
2753 if (self.artifact.target.isWindows()) {2755 if (self.artifact.target.isWindows()) {
2754 builder.pushInstalledFile(.Lib, artifact.out_lib_filename);2756 builder.pushInstalledFile(.Lib, artifact.out_lib_filename);
...@@ -2770,7 +2772,7 @@ pub const InstallArtifactStep = struct {...@@ -2770,7 +2772,7 @@ pub const InstallArtifactStep = struct {
2770 const full_dest_path = builder.getInstallPath(self.dest_dir, self.artifact.out_filename);2772 const full_dest_path = builder.getInstallPath(self.dest_dir, self.artifact.out_filename);
2771 try builder.updateFile(self.artifact.getOutputPath(), full_dest_path);2773 try builder.updateFile(self.artifact.getOutputPath(), full_dest_path);
2772 if (self.artifact.isDynamicLibrary() and self.artifact.version != null and self.artifact.target.wantSharedLibSymLinks()) {2774 if (self.artifact.isDynamicLibrary() and self.artifact.version != null and self.artifact.target.wantSharedLibSymLinks()) {
2773 try doAtomicSymLinks(builder.allocator, full_dest_path, self.artifact.major_only_filename, self.artifact.name_only_filename);2775 try doAtomicSymLinks(builder.allocator, full_dest_path, self.artifact.major_only_filename.?, self.artifact.name_only_filename.?);
2774 }2776 }
2775 if (self.pdb_dir) |pdb_dir| {2777 if (self.pdb_dir) |pdb_dir| {
2776 const full_pdb_path = builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename);2778 const full_pdb_path = builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename);