| author | |
| committer | |
| log | 5129fae4e8fdb68db1efdff20679b13487501691 |
| tree | 94d4a545091873df4236372608db368d2d79cf91 |
| parent | 60c4befad39a1e1689872bc78dd1b8f8d5c34887 |
And only detect native target in LibExeObjStep once, in create().4 files changed, 19 insertions(+), 6 deletions(-)
lib/build_runner.zig+3| ... | @@ -41,12 +41,15 @@ pub fn main() !void { | ... | @@ -41,12 +41,15 @@ pub fn main() !void { |
| 41 | return error.InvalidArgs; | 41 | return error.InvalidArgs; |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | const host = try std.zig.system.NativeTargetInfo.detect(.{}); | ||
| 45 | |||
| 44 | const builder = try std.Build.create( | 46 | const builder = try std.Build.create( |
| 45 | allocator, | 47 | allocator, |
| 46 | zig_exe, | 48 | zig_exe, |
| 47 | build_root, | 49 | build_root, |
| 48 | cache_root, | 50 | cache_root, |
| 49 | global_cache_root, | 51 | global_cache_root, |
| 52 | host, | ||
| 50 | ); | 53 | ); |
| 51 | defer builder.destroy(); | 54 | defer builder.destroy(); |
| 52 | 55 |
lib/std/Build.zig+8-2| ... | @@ -179,12 +179,11 @@ pub fn create( | ... | @@ -179,12 +179,11 @@ pub fn create( |
| 179 | build_root: []const u8, | 179 | build_root: []const u8, |
| 180 | cache_root: []const u8, | 180 | cache_root: []const u8, |
| 181 | global_cache_root: []const u8, | 181 | global_cache_root: []const u8, |
| 182 | host: NativeTargetInfo, | ||
| 182 | ) !*Build { | 183 | ) !*Build { |
| 183 | const env_map = try allocator.create(EnvMap); | 184 | const env_map = try allocator.create(EnvMap); |
| 184 | env_map.* = try process.getEnvMap(allocator); | 185 | env_map.* = try process.getEnvMap(allocator); |
| 185 | 186 | ||
| 186 | const host = try NativeTargetInfo.detect(.{}); | ||
| 187 | |||
| 188 | const self = try allocator.create(Build); | 187 | const self = try allocator.create(Build); |
| 189 | self.* = Build{ | 188 | self.* = Build{ |
| 190 | .zig_exe = zig_exe, | 189 | .zig_exe = zig_exe, |
| ... | @@ -1529,12 +1528,15 @@ test "builder.findProgram compiles" { | ... | @@ -1529,12 +1528,15 @@ test "builder.findProgram compiles" { |
| 1529 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | 1528 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 1530 | defer arena.deinit(); | 1529 | defer arena.deinit(); |
| 1531 | 1530 | ||
| 1531 | const host = try NativeTargetInfo.detect(.{}); | ||
| 1532 | |||
| 1532 | const builder = try Build.create( | 1533 | const builder = try Build.create( |
| 1533 | arena.allocator(), | 1534 | arena.allocator(), |
| 1534 | "zig", | 1535 | "zig", |
| 1535 | "zig-cache", | 1536 | "zig-cache", |
| 1536 | "zig-cache", | 1537 | "zig-cache", |
| 1537 | "zig-cache", | 1538 | "zig-cache", |
| 1539 | host, | ||
| 1538 | ); | 1540 | ); |
| 1539 | defer builder.destroy(); | 1541 | defer builder.destroy(); |
| 1540 | _ = builder.findProgram(&[_][]const u8{}, &[_][]const u8{}) catch null; | 1542 | _ = builder.findProgram(&[_][]const u8{}, &[_][]const u8{}) catch null; |
| ... | @@ -1713,12 +1715,16 @@ test "dupePkg()" { | ... | @@ -1713,12 +1715,16 @@ test "dupePkg()" { |
| 1713 | 1715 | ||
| 1714 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); | 1716 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 1715 | defer arena.deinit(); | 1717 | defer arena.deinit(); |
| 1718 | |||
| 1719 | const host = try NativeTargetInfo.detect(.{}); | ||
| 1720 | |||
| 1716 | var builder = try Build.create( | 1721 | var builder = try Build.create( |
| 1717 | arena.allocator(), | 1722 | arena.allocator(), |
| 1718 | "test", | 1723 | "test", |
| 1719 | "test", | 1724 | "test", |
| 1720 | "test", | 1725 | "test", |
| 1721 | "test", | 1726 | "test", |
| 1727 | host, | ||
| 1722 | ); | 1728 | ); |
| 1723 | defer builder.destroy(); | 1729 | defer builder.destroy(); |
| 1724 | 1730 |
lib/std/Build/LibExeObjStep.zig+4-4| ... | @@ -364,7 +364,7 @@ pub fn create(builder: *std.Build, options: Options) *LibExeObjStep { | ... | @@ -364,7 +364,7 @@ pub fn create(builder: *std.Build, options: Options) *LibExeObjStep { |
| 364 | .output_h_path_source = GeneratedFile{ .step = &self.step }, | 364 | .output_h_path_source = GeneratedFile{ .step = &self.step }, |
| 365 | .output_pdb_path_source = GeneratedFile{ .step = &self.step }, | 365 | .output_pdb_path_source = GeneratedFile{ .step = &self.step }, |
| 366 | 366 | ||
| 367 | .target_info = undefined, // populated in computeOutFileNames | 367 | .target_info = NativeTargetInfo.detect(self.target) catch unreachable, |
| 368 | }; | 368 | }; |
| 369 | self.computeOutFileNames(); | 369 | self.computeOutFileNames(); |
| 370 | if (root_src) |rs| rs.addStepDependencies(&self.step); | 370 | if (root_src) |rs| rs.addStepDependencies(&self.step); |
| ... | @@ -372,9 +372,6 @@ pub fn create(builder: *std.Build, options: Options) *LibExeObjStep { | ... | @@ -372,9 +372,6 @@ pub fn create(builder: *std.Build, options: Options) *LibExeObjStep { |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | fn computeOutFileNames(self: *LibExeObjStep) void { | 374 | fn computeOutFileNames(self: *LibExeObjStep) void { |
| 375 | self.target_info = NativeTargetInfo.detect(self.target) catch | ||
| 376 | unreachable; | ||
| 377 | |||
| 378 | const target = self.target_info.target; | 375 | const target = self.target_info.target; |
| 379 | 376 | ||
| 380 | self.out_filename = std.zig.binNameAlloc(self.builder.allocator, .{ | 377 | self.out_filename = std.zig.binNameAlloc(self.builder.allocator, .{ |
| ... | @@ -1946,12 +1943,15 @@ test "addPackage" { | ... | @@ -1946,12 +1943,15 @@ test "addPackage" { |
| 1946 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); | 1943 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 1947 | defer arena.deinit(); | 1944 | defer arena.deinit(); |
| 1948 | 1945 | ||
| 1946 | const host = try NativeTargetInfo.detect(.{}); | ||
| 1947 | |||
| 1949 | var builder = try std.Build.create( | 1948 | var builder = try std.Build.create( |
| 1950 | arena.allocator(), | 1949 | arena.allocator(), |
| 1951 | "test", | 1950 | "test", |
| 1952 | "test", | 1951 | "test", |
| 1953 | "test", | 1952 | "test", |
| 1954 | "test", | 1953 | "test", |
| 1954 | host, | ||
| 1955 | ); | 1955 | ); |
| 1956 | defer builder.destroy(); | 1956 | defer builder.destroy(); |
| 1957 | 1957 |
lib/std/Build/OptionsStep.zig+4| ... | @@ -279,12 +279,16 @@ test "OptionsStep" { | ... | @@ -279,12 +279,16 @@ test "OptionsStep" { |
| 279 | 279 | ||
| 280 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); | 280 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 281 | defer arena.deinit(); | 281 | defer arena.deinit(); |
| 282 | |||
| 283 | const host = try std.zig.system.NativeTargetInfo.detect(.{}); | ||
| 284 | |||
| 282 | var builder = try std.Build.create( | 285 | var builder = try std.Build.create( |
| 283 | arena.allocator(), | 286 | arena.allocator(), |
| 284 | "test", | 287 | "test", |
| 285 | "test", | 288 | "test", |
| 286 | "test", | 289 | "test", |
| 287 | "test", | 290 | "test", |
| 291 | host, | ||
| 288 | ); | 292 | ); |
| 289 | defer builder.destroy(); | 293 | defer builder.destroy(); |
| 290 | 294 |