| ... | ... | @@ -4,6 +4,7 @@ const io = std.io; |
| 4 | 4 | const fs = std.fs; |
| 5 | 5 | const mem = std.mem; |
| 6 | 6 | const debug = std.debug; |
| 7 | const panic = std.debug.panic; |
| 7 | 8 | const assert = debug.assert; |
| 8 | 9 | const warn = std.debug.warn; |
| 9 | 10 | const ArrayList = std.ArrayList; |
| ... | ... | @@ -42,8 +43,8 @@ pub const Builder = struct { |
| 42 | 43 | top_level_steps: ArrayList(*TopLevelStep), |
| 43 | 44 | install_prefix: ?[]const u8, |
| 44 | 45 | dest_dir: ?[]const u8, |
| 45 | | lib_dir: ?[]const u8, |
| 46 | | exe_dir: ?[]const u8, |
| 46 | lib_dir: []const u8, |
| 47 | exe_dir: []const u8, |
| 47 | 48 | install_path: []const u8, |
| 48 | 49 | search_prefixes: ArrayList([]const u8), |
| 49 | 50 | installed_files: ArrayList(InstalledFile), |
| ... | ... | @@ -129,8 +130,8 @@ pub const Builder = struct { |
| 129 | 130 | .env_map = env_map, |
| 130 | 131 | .search_prefixes = ArrayList([]const u8).init(allocator), |
| 131 | 132 | .install_prefix = null, |
| 132 | | .lib_dir = null, |
| 133 | | .exe_dir = null, |
| 133 | .lib_dir = undefined, |
| 134 | .exe_dir = undefined, |
| 134 | 135 | .dest_dir = env_map.get("DESTDIR"), |
| 135 | 136 | .installed_files = ArrayList(InstalledFile).init(allocator), |
| 136 | 137 | .install_tls = TopLevelStep{ |
| ... | ... | @@ -163,11 +164,13 @@ pub const Builder = struct { |
| 163 | 164 | self.allocator.destroy(self); |
| 164 | 165 | } |
| 165 | 166 | |
| 167 | /// This function is intended to be called by std/special/build_runner.zig, not a build.zig file. |
| 166 | 168 | pub fn setInstallPrefix(self: *Builder, optional_prefix: ?[]const u8) void { |
| 167 | 169 | self.install_prefix = optional_prefix; |
| 168 | 170 | } |
| 169 | 171 | |
| 170 | | fn resolveInstallPrefix(self: *Builder) void { |
| 172 | /// This function is intended to be called by std/special/build_runner.zig, not a build.zig file. |
| 173 | pub fn resolveInstallPrefix(self: *Builder) void { |
| 171 | 174 | if (self.dest_dir) |dest_dir| { |
| 172 | 175 | const install_prefix = self.install_prefix orelse "/usr"; |
| 173 | 176 | self.install_path = fs.path.join(self.allocator, [_][]const u8{ dest_dir, install_prefix }) catch unreachable; |
| ... | ... | @@ -437,7 +440,7 @@ pub const Builder = struct { |
| 437 | 440 | .description = description, |
| 438 | 441 | }; |
| 439 | 442 | if ((self.available_options_map.put(name, available_option) catch unreachable) != null) { |
| 440 | | debug.panic("Option '{}' declared twice", name); |
| 443 | panic("Option '{}' declared twice", name); |
| 441 | 444 | } |
| 442 | 445 | self.available_options_list.append(available_option) catch unreachable; |
| 443 | 446 | |
| ... | ... | @@ -463,8 +466,8 @@ pub const Builder = struct { |
| 463 | 466 | return null; |
| 464 | 467 | }, |
| 465 | 468 | }, |
| 466 | | TypeId.Int => debug.panic("TODO integer options to build script"), |
| 467 | | TypeId.Float => debug.panic("TODO float options to build script"), |
| 469 | TypeId.Int => panic("TODO integer options to build script"), |
| 470 | TypeId.Float => panic("TODO float options to build script"), |
| 468 | 471 | TypeId.String => switch (entry.value.value) { |
| 469 | 472 | UserValue.Flag => { |
| 470 | 473 | warn("Expected -D{} to be a string, but received a boolean.\n", name); |
| ... | ... | @@ -478,7 +481,7 @@ pub const Builder = struct { |
| 478 | 481 | }, |
| 479 | 482 | UserValue.Scalar => |s| return s, |
| 480 | 483 | }, |
| 481 | | TypeId.List => debug.panic("TODO list options to build script"), |
| 484 | TypeId.List => panic("TODO list options to build script"), |
| 482 | 485 | } |
| 483 | 486 | } |
| 484 | 487 | |
| ... | ... | @@ -644,8 +647,6 @@ pub const Builder = struct { |
| 644 | 647 | } |
| 645 | 648 | |
| 646 | 649 | pub fn validateUserInputDidItFail(self: *Builder) bool { |
| 647 | | self.resolveInstallPrefix(); |
| 648 | | |
| 649 | 650 | // make sure all args are used |
| 650 | 651 | var it = self.user_input_options.iterator(); |
| 651 | 652 | while (true) { |
| ... | ... | @@ -855,7 +856,7 @@ pub const Builder = struct { |
| 855 | 856 | var stdout_file_in_stream = child.stdout.?.inStream(); |
| 856 | 857 | try stdout_file_in_stream.stream.readAllBuffer(&stdout, max_output_size); |
| 857 | 858 | |
| 858 | | const term = child.wait() catch |err| std.debug.panic("unable to spawn {}: {}", argv[0], err); |
| 859 | const term = child.wait() catch |err| panic("unable to spawn {}: {}", argv[0], err); |
| 859 | 860 | switch (term) { |
| 860 | 861 | .Exited => |code| { |
| 861 | 862 | if (code != 0) { |
| ... | ... | @@ -882,8 +883,8 @@ pub const Builder = struct { |
| 882 | 883 | fn getInstallPath(self: *Builder, dir: InstallDir, dest_rel_path: []const u8) []const u8 { |
| 883 | 884 | const base_dir = switch (dir) { |
| 884 | 885 | .Prefix => self.install_path, |
| 885 | | .Bin => self.exe_dir.?, |
| 886 | | .Lib => self.lib_dir.?, |
| 886 | .Bin => self.exe_dir, |
| 887 | .Lib => self.lib_dir, |
| 887 | 888 | }; |
| 888 | 889 | return fs.path.resolve( |
| 889 | 890 | self.allocator, |
| ... | ... | @@ -1318,6 +1319,9 @@ pub const LibExeObjStep = struct { |
| 1318 | 1319 | } |
| 1319 | 1320 | |
| 1320 | 1321 | fn initExtraArgs(builder: *Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, is_dynamic: bool, ver: Version) LibExeObjStep { |
| 1322 | if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) { |
| 1323 | panic("invalid name: '{}'. It looks like a file path, but it is supposed to be the library or application name.", name); |
| 1324 | } |
| 1321 | 1325 | var self = LibExeObjStep{ |
| 1322 | 1326 | .strip = false, |
| 1323 | 1327 | .builder = builder, |