| author | |
| committer | |
| log | 90e48d4b3469fb4f8dd2f3b52e05453029d45fdc |
| tree | c213ee58f8a39ce6275456f5d37a59de4a58cf68 |
| parent | 13a96165405af33fa6ef43a3ce2c1d8aea846287 |
Usage of `catch unreachable` in build scripts is completely harmless
because build scripts are always run in Debug mode, however, it sets a
poor example for beginners to learn from.13 files changed, 169 insertions(+), 161 deletions(-)
lib/std/Build.zig+34-35| ... | @@ -564,12 +564,12 @@ pub fn addConfigHeader( | ... | @@ -564,12 +564,12 @@ pub fn addConfigHeader( |
| 564 | 564 | ||
| 565 | /// Allocator.dupe without the need to handle out of memory. | 565 | /// Allocator.dupe without the need to handle out of memory. |
| 566 | pub fn dupe(self: *Build, bytes: []const u8) []u8 { | 566 | pub fn dupe(self: *Build, bytes: []const u8) []u8 { |
| 567 | return self.allocator.dupe(u8, bytes) catch unreachable; | 567 | return self.allocator.dupe(u8, bytes) catch @panic("OOM"); |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | /// Duplicates an array of strings without the need to handle out of memory. | 570 | /// Duplicates an array of strings without the need to handle out of memory. |
| 571 | pub fn dupeStrings(self: *Build, strings: []const []const u8) [][]u8 { | 571 | pub fn dupeStrings(self: *Build, strings: []const []const u8) [][]u8 { |
| 572 | const array = self.allocator.alloc([]u8, strings.len) catch unreachable; | 572 | const array = self.allocator.alloc([]u8, strings.len) catch @panic("OOM"); |
| 573 | for (strings) |s, i| { | 573 | for (strings) |s, i| { |
| 574 | array[i] = self.dupe(s); | 574 | array[i] = self.dupe(s); |
| 575 | } | 575 | } |
| ... | @@ -596,7 +596,7 @@ pub fn dupePkg(self: *Build, package: Pkg) Pkg { | ... | @@ -596,7 +596,7 @@ pub fn dupePkg(self: *Build, package: Pkg) Pkg { |
| 596 | }; | 596 | }; |
| 597 | 597 | ||
| 598 | if (package.dependencies) |dependencies| { | 598 | if (package.dependencies) |dependencies| { |
| 599 | const new_dependencies = self.allocator.alloc(Pkg, dependencies.len) catch unreachable; | 599 | const new_dependencies = self.allocator.alloc(Pkg, dependencies.len) catch @panic("OOM"); |
| 600 | the_copy.dependencies = new_dependencies; | 600 | the_copy.dependencies = new_dependencies; |
| 601 | 601 | ||
| 602 | for (dependencies) |dep_package, i| { | 602 | for (dependencies) |dep_package, i| { |
| ... | @@ -613,20 +613,20 @@ pub fn addWriteFile(self: *Build, file_path: []const u8, data: []const u8) *Writ | ... | @@ -613,20 +613,20 @@ pub fn addWriteFile(self: *Build, file_path: []const u8, data: []const u8) *Writ |
| 613 | } | 613 | } |
| 614 | 614 | ||
| 615 | pub fn addWriteFiles(self: *Build) *WriteFileStep { | 615 | pub fn addWriteFiles(self: *Build) *WriteFileStep { |
| 616 | const write_file_step = self.allocator.create(WriteFileStep) catch unreachable; | 616 | const write_file_step = self.allocator.create(WriteFileStep) catch @panic("OOM"); |
| 617 | write_file_step.* = WriteFileStep.init(self); | 617 | write_file_step.* = WriteFileStep.init(self); |
| 618 | return write_file_step; | 618 | return write_file_step; |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | pub fn addLog(self: *Build, comptime format: []const u8, args: anytype) *LogStep { | 621 | pub fn addLog(self: *Build, comptime format: []const u8, args: anytype) *LogStep { |
| 622 | const data = self.fmt(format, args); | 622 | const data = self.fmt(format, args); |
| 623 | const log_step = self.allocator.create(LogStep) catch unreachable; | 623 | const log_step = self.allocator.create(LogStep) catch @panic("OOM"); |
| 624 | log_step.* = LogStep.init(self, data); | 624 | log_step.* = LogStep.init(self, data); |
| 625 | return log_step; | 625 | return log_step; |
| 626 | } | 626 | } |
| 627 | 627 | ||
| 628 | pub fn addRemoveDirTree(self: *Build, dir_path: []const u8) *RemoveDirStep { | 628 | pub fn addRemoveDirTree(self: *Build, dir_path: []const u8) *RemoveDirStep { |
| 629 | const remove_dir_step = self.allocator.create(RemoveDirStep) catch unreachable; | 629 | const remove_dir_step = self.allocator.create(RemoveDirStep) catch @panic("OOM"); |
| 630 | remove_dir_step.* = RemoveDirStep.init(self, dir_path); | 630 | remove_dir_step.* = RemoveDirStep.init(self, dir_path); |
| 631 | return remove_dir_step; | 631 | return remove_dir_step; |
| 632 | } | 632 | } |
| ... | @@ -719,13 +719,13 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ | ... | @@ -719,13 +719,13 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ |
| 719 | const type_id = comptime typeToEnum(T); | 719 | const type_id = comptime typeToEnum(T); |
| 720 | const enum_options = if (type_id == .@"enum") blk: { | 720 | const enum_options = if (type_id == .@"enum") blk: { |
| 721 | const fields = comptime std.meta.fields(T); | 721 | const fields = comptime std.meta.fields(T); |
| 722 | var options = ArrayList([]const u8).initCapacity(self.allocator, fields.len) catch unreachable; | 722 | var options = ArrayList([]const u8).initCapacity(self.allocator, fields.len) catch @panic("OOM"); |
| 723 | 723 | ||
| 724 | inline for (fields) |field| { | 724 | inline for (fields) |field| { |
| 725 | options.appendAssumeCapacity(field.name); | 725 | options.appendAssumeCapacity(field.name); |
| 726 | } | 726 | } |
| 727 | 727 | ||
| 728 | break :blk options.toOwnedSlice() catch unreachable; | 728 | break :blk options.toOwnedSlice() catch @panic("OOM"); |
| 729 | } else null; | 729 | } else null; |
| 730 | const available_option = AvailableOption{ | 730 | const available_option = AvailableOption{ |
| 731 | .name = name, | 731 | .name = name, |
| ... | @@ -733,10 +733,10 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ | ... | @@ -733,10 +733,10 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ |
| 733 | .description = description, | 733 | .description = description, |
| 734 | .enum_options = enum_options, | 734 | .enum_options = enum_options, |
| 735 | }; | 735 | }; |
| 736 | if ((self.available_options_map.fetchPut(name, available_option) catch unreachable) != null) { | 736 | if ((self.available_options_map.fetchPut(name, available_option) catch @panic("OOM")) != null) { |
| 737 | panic("Option '{s}' declared twice", .{name}); | 737 | panic("Option '{s}' declared twice", .{name}); |
| 738 | } | 738 | } |
| 739 | self.available_options_list.append(available_option) catch unreachable; | 739 | self.available_options_list.append(available_option) catch @panic("OOM"); |
| 740 | 740 | ||
| 741 | const option_ptr = self.user_input_options.getPtr(name) orelse return null; | 741 | const option_ptr = self.user_input_options.getPtr(name) orelse return null; |
| 742 | option_ptr.used = true; | 742 | option_ptr.used = true; |
| ... | @@ -840,7 +840,7 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ | ... | @@ -840,7 +840,7 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ |
| 840 | return null; | 840 | return null; |
| 841 | }, | 841 | }, |
| 842 | .scalar => |s| { | 842 | .scalar => |s| { |
| 843 | return self.allocator.dupe([]const u8, &[_][]const u8{s}) catch unreachable; | 843 | return self.allocator.dupe([]const u8, &[_][]const u8{s}) catch @panic("OOM"); |
| 844 | }, | 844 | }, |
| 845 | .list => |lst| return lst.items, | 845 | .list => |lst| return lst.items, |
| 846 | }, | 846 | }, |
| ... | @@ -848,12 +848,12 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ | ... | @@ -848,12 +848,12 @@ pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_ |
| 848 | } | 848 | } |
| 849 | 849 | ||
| 850 | pub fn step(self: *Build, name: []const u8, description: []const u8) *Step { | 850 | pub fn step(self: *Build, name: []const u8, description: []const u8) *Step { |
| 851 | const step_info = self.allocator.create(TopLevelStep) catch unreachable; | 851 | const step_info = self.allocator.create(TopLevelStep) catch @panic("OOM"); |
| 852 | step_info.* = TopLevelStep{ | 852 | step_info.* = TopLevelStep{ |
| 853 | .step = Step.initNoOp(.top_level, name, self.allocator), | 853 | .step = Step.initNoOp(.top_level, name, self.allocator), |
| 854 | .description = self.dupe(description), | 854 | .description = self.dupe(description), |
| 855 | }; | 855 | }; |
| 856 | self.top_level_steps.append(step_info) catch unreachable; | 856 | self.top_level_steps.append(step_info) catch @panic("OOM"); |
| 857 | return &step_info.step; | 857 | return &step_info.step; |
| 858 | } | 858 | } |
| 859 | 859 | ||
| ... | @@ -949,7 +949,7 @@ pub fn standardTargetOptions(self: *Build, args: StandardTargetOptionsArgs) Cros | ... | @@ -949,7 +949,7 @@ pub fn standardTargetOptions(self: *Build, args: StandardTargetOptionsArgs) Cros |
| 949 | }, | 949 | }, |
| 950 | }; | 950 | }; |
| 951 | 951 | ||
| 952 | const selected_canonicalized_triple = selected_target.zigTriple(self.allocator) catch unreachable; | 952 | const selected_canonicalized_triple = selected_target.zigTriple(self.allocator) catch @panic("OOM"); |
| 953 | 953 | ||
| 954 | if (args.whitelist) |list| whitelist_check: { | 954 | if (args.whitelist) |list| whitelist_check: { |
| 955 | // Make sure it's a match of one of the list. | 955 | // Make sure it's a match of one of the list. |
| ... | @@ -960,7 +960,7 @@ pub fn standardTargetOptions(self: *Build, args: StandardTargetOptionsArgs) Cros | ... | @@ -960,7 +960,7 @@ pub fn standardTargetOptions(self: *Build, args: StandardTargetOptionsArgs) Cros |
| 960 | mismatch_cpu_features = true; | 960 | mismatch_cpu_features = true; |
| 961 | mismatch_triple = true; | 961 | mismatch_triple = true; |
| 962 | 962 | ||
| 963 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 963 | const t_triple = t.zigTriple(self.allocator) catch @panic("OOM"); |
| 964 | if (mem.eql(u8, t_triple, selected_canonicalized_triple)) { | 964 | if (mem.eql(u8, t_triple, selected_canonicalized_triple)) { |
| 965 | mismatch_triple = false; | 965 | mismatch_triple = false; |
| 966 | whitelist_item = t; | 966 | whitelist_item = t; |
| ... | @@ -977,7 +977,7 @@ pub fn standardTargetOptions(self: *Build, args: StandardTargetOptionsArgs) Cros | ... | @@ -977,7 +977,7 @@ pub fn standardTargetOptions(self: *Build, args: StandardTargetOptionsArgs) Cros |
| 977 | selected_canonicalized_triple, | 977 | selected_canonicalized_triple, |
| 978 | }); | 978 | }); |
| 979 | for (list) |t| { | 979 | for (list) |t| { |
| 980 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 980 | const t_triple = t.zigTriple(self.allocator) catch @panic("OOM"); |
| 981 | log.err(" {s}", .{t_triple}); | 981 | log.err(" {s}", .{t_triple}); |
| 982 | } | 982 | } |
| 983 | } else { | 983 | } else { |
| ... | @@ -1033,22 +1033,22 @@ pub fn addUserInputOption(self: *Build, name_raw: []const u8, value_raw: []const | ... | @@ -1033,22 +1033,22 @@ pub fn addUserInputOption(self: *Build, name_raw: []const u8, value_raw: []const |
| 1033 | .scalar => |s| { | 1033 | .scalar => |s| { |
| 1034 | // turn it into a list | 1034 | // turn it into a list |
| 1035 | var list = ArrayList([]const u8).init(self.allocator); | 1035 | var list = ArrayList([]const u8).init(self.allocator); |
| 1036 | list.append(s) catch unreachable; | 1036 | try list.append(s); |
| 1037 | list.append(value) catch unreachable; | 1037 | try list.append(value); |
| 1038 | self.user_input_options.put(name, .{ | 1038 | try self.user_input_options.put(name, .{ |
| 1039 | .name = name, | 1039 | .name = name, |
| 1040 | .value = .{ .list = list }, | 1040 | .value = .{ .list = list }, |
| 1041 | .used = false, | 1041 | .used = false, |
| 1042 | }) catch unreachable; | 1042 | }); |
| 1043 | }, | 1043 | }, |
| 1044 | .list => |*list| { | 1044 | .list => |*list| { |
| 1045 | // append to the list | 1045 | // append to the list |
| 1046 | list.append(value) catch unreachable; | 1046 | try list.append(value); |
| 1047 | self.user_input_options.put(name, .{ | 1047 | try self.user_input_options.put(name, .{ |
| 1048 | .name = name, | 1048 | .name = name, |
| 1049 | .value = .{ .list = list.* }, | 1049 | .value = .{ .list = list.* }, |
| 1050 | .used = false, | 1050 | .used = false, |
| 1051 | }) catch unreachable; | 1051 | }); |
| 1052 | }, | 1052 | }, |
| 1053 | .flag => { | 1053 | .flag => { |
| 1054 | log.warn("Option '-D{s}={s}' conflicts with flag '-D{s}'.", .{ name, value, name }); | 1054 | log.warn("Option '-D{s}={s}' conflicts with flag '-D{s}'.", .{ name, value, name }); |
| ... | @@ -1240,13 +1240,13 @@ pub fn addInstallFileWithDir( | ... | @@ -1240,13 +1240,13 @@ pub fn addInstallFileWithDir( |
| 1240 | if (dest_rel_path.len == 0) { | 1240 | if (dest_rel_path.len == 0) { |
| 1241 | panic("dest_rel_path must be non-empty", .{}); | 1241 | panic("dest_rel_path must be non-empty", .{}); |
| 1242 | } | 1242 | } |
| 1243 | const install_step = self.allocator.create(InstallFileStep) catch unreachable; | 1243 | const install_step = self.allocator.create(InstallFileStep) catch @panic("OOM"); |
| 1244 | install_step.* = InstallFileStep.init(self, source.dupe(self), install_dir, dest_rel_path); | 1244 | install_step.* = InstallFileStep.init(self, source.dupe(self), install_dir, dest_rel_path); |
| 1245 | return install_step; | 1245 | return install_step; |
| 1246 | } | 1246 | } |
| 1247 | 1247 | ||
| 1248 | pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *InstallDirStep { | 1248 | pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *InstallDirStep { |
| 1249 | const install_step = self.allocator.create(InstallDirStep) catch unreachable; | 1249 | const install_step = self.allocator.create(InstallDirStep) catch @panic("OOM"); |
| 1250 | install_step.* = InstallDirStep.init(self, options); | 1250 | install_step.* = InstallDirStep.init(self, options); |
| 1251 | return install_step; | 1251 | return install_step; |
| 1252 | } | 1252 | } |
| ... | @@ -1256,7 +1256,7 @@ pub fn pushInstalledFile(self: *Build, dir: InstallDir, dest_rel_path: []const u | ... | @@ -1256,7 +1256,7 @@ pub fn pushInstalledFile(self: *Build, dir: InstallDir, dest_rel_path: []const u |
| 1256 | .dir = dir, | 1256 | .dir = dir, |
| 1257 | .path = dest_rel_path, | 1257 | .path = dest_rel_path, |
| 1258 | }; | 1258 | }; |
| 1259 | self.installed_files.append(file.dupe(self)) catch unreachable; | 1259 | self.installed_files.append(file.dupe(self)) catch @panic("OOM"); |
| 1260 | } | 1260 | } |
| 1261 | 1261 | ||
| 1262 | pub fn updateFile(self: *Build, source_path: []const u8, dest_path: []const u8) !void { | 1262 | pub fn updateFile(self: *Build, source_path: []const u8, dest_path: []const u8) !void { |
| ... | @@ -1289,16 +1289,15 @@ pub fn truncateFile(self: *Build, dest_path: []const u8) !void { | ... | @@ -1289,16 +1289,15 @@ pub fn truncateFile(self: *Build, dest_path: []const u8) !void { |
| 1289 | } | 1289 | } |
| 1290 | 1290 | ||
| 1291 | pub fn pathFromRoot(self: *Build, rel_path: []const u8) []u8 { | 1291 | pub fn pathFromRoot(self: *Build, rel_path: []const u8) []u8 { |
| 1292 | return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable; | 1292 | return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch @panic("OOM"); |
| 1293 | } | 1293 | } |
| 1294 | 1294 | ||
| 1295 | /// Shorthand for `std.fs.path.join(Build.allocator, paths) catch unreachable` | ||
| 1296 | pub fn pathJoin(self: *Build, paths: []const []const u8) []u8 { | 1295 | pub fn pathJoin(self: *Build, paths: []const []const u8) []u8 { |
| 1297 | return fs.path.join(self.allocator, paths) catch unreachable; | 1296 | return fs.path.join(self.allocator, paths) catch @panic("OOM"); |
| 1298 | } | 1297 | } |
| 1299 | 1298 | ||
| 1300 | pub fn fmt(self: *Build, comptime format: []const u8, args: anytype) []u8 { | 1299 | pub fn fmt(self: *Build, comptime format: []const u8, args: anytype) []u8 { |
| 1301 | return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable; | 1300 | return fmt_lib.allocPrint(self.allocator, format, args) catch @panic("OOM"); |
| 1302 | } | 1301 | } |
| 1303 | 1302 | ||
| 1304 | pub fn findProgram(self: *Build, names: []const []const u8, paths: []const []const u8) ![]const u8 { | 1303 | pub fn findProgram(self: *Build, names: []const []const u8, paths: []const []const u8) ![]const u8 { |
| ... | @@ -1442,7 +1441,7 @@ pub fn exec(self: *Build, argv: []const []const u8) ![]u8 { | ... | @@ -1442,7 +1441,7 @@ pub fn exec(self: *Build, argv: []const []const u8) ![]u8 { |
| 1442 | } | 1441 | } |
| 1443 | 1442 | ||
| 1444 | pub fn addSearchPrefix(self: *Build, search_prefix: []const u8) void { | 1443 | pub fn addSearchPrefix(self: *Build, search_prefix: []const u8) void { |
| 1445 | self.search_prefixes.append(self.dupePath(search_prefix)) catch unreachable; | 1444 | self.search_prefixes.append(self.dupePath(search_prefix)) catch @panic("OOM"); |
| 1446 | } | 1445 | } |
| 1447 | 1446 | ||
| 1448 | pub fn getInstallPath(self: *Build, dir: InstallDir, dest_rel_path: []const u8) []const u8 { | 1447 | pub fn getInstallPath(self: *Build, dir: InstallDir, dest_rel_path: []const u8) []const u8 { |
| ... | @@ -1457,7 +1456,7 @@ pub fn getInstallPath(self: *Build, dir: InstallDir, dest_rel_path: []const u8) | ... | @@ -1457,7 +1456,7 @@ pub fn getInstallPath(self: *Build, dir: InstallDir, dest_rel_path: []const u8) |
| 1457 | return fs.path.resolve( | 1456 | return fs.path.resolve( |
| 1458 | self.allocator, | 1457 | self.allocator, |
| 1459 | &[_][]const u8{ base_dir, dest_rel_path }, | 1458 | &[_][]const u8{ base_dir, dest_rel_path }, |
| 1460 | ) catch unreachable; | 1459 | ) catch @panic("OOM"); |
| 1461 | } | 1460 | } |
| 1462 | 1461 | ||
| 1463 | pub const Dependency = struct { | 1462 | pub const Dependency = struct { |
| ... | @@ -1509,14 +1508,14 @@ fn dependencyInner( | ... | @@ -1509,14 +1508,14 @@ fn dependencyInner( |
| 1509 | comptime build_zig: type, | 1508 | comptime build_zig: type, |
| 1510 | args: anytype, | 1509 | args: anytype, |
| 1511 | ) *Dependency { | 1510 | ) *Dependency { |
| 1512 | const sub_builder = b.createChild(name, build_root, args) catch unreachable; | 1511 | const sub_builder = b.createChild(name, build_root, args) catch @panic("unhandled error"); |
| 1513 | sub_builder.runBuild(build_zig) catch unreachable; | 1512 | sub_builder.runBuild(build_zig) catch @panic("unhandled error"); |
| 1514 | 1513 | ||
| 1515 | if (sub_builder.validateUserInputDidItFail()) { | 1514 | if (sub_builder.validateUserInputDidItFail()) { |
| 1516 | std.debug.dumpCurrentStackTrace(@returnAddress()); | 1515 | std.debug.dumpCurrentStackTrace(@returnAddress()); |
| 1517 | } | 1516 | } |
| 1518 | 1517 | ||
| 1519 | const dep = b.allocator.create(Dependency) catch unreachable; | 1518 | const dep = b.allocator.create(Dependency) catch @panic("OOM"); |
| 1520 | dep.* = .{ .builder = sub_builder }; | 1519 | dep.* = .{ .builder = sub_builder }; |
| 1521 | return dep; | 1520 | return dep; |
| 1522 | } | 1521 | } |
lib/std/Build/CheckFileStep.zig+1-1| ... | @@ -18,7 +18,7 @@ pub fn create( | ... | @@ -18,7 +18,7 @@ pub fn create( |
| 18 | source: std.Build.FileSource, | 18 | source: std.Build.FileSource, |
| 19 | expected_matches: []const []const u8, | 19 | expected_matches: []const []const u8, |
| 20 | ) *CheckFileStep { | 20 | ) *CheckFileStep { |
| 21 | const self = builder.allocator.create(CheckFileStep) catch unreachable; | 21 | const self = builder.allocator.create(CheckFileStep) catch @panic("OOM"); |
| 22 | self.* = CheckFileStep{ | 22 | self.* = CheckFileStep{ |
| 23 | .builder = builder, | 23 | .builder = builder, |
| 24 | .step = Step.init(.check_file, "CheckFile", builder.allocator, make), | 24 | .step = Step.init(.check_file, "CheckFile", builder.allocator, make), |
lib/std/Build/CheckObjectStep.zig+6-6| ... | @@ -24,7 +24,7 @@ obj_format: std.Target.ObjectFormat, | ... | @@ -24,7 +24,7 @@ obj_format: std.Target.ObjectFormat, |
| 24 | 24 | ||
| 25 | pub fn create(builder: *std.Build, source: std.Build.FileSource, obj_format: std.Target.ObjectFormat) *CheckObjectStep { | 25 | pub fn create(builder: *std.Build, source: std.Build.FileSource, obj_format: std.Target.ObjectFormat) *CheckObjectStep { |
| 26 | const gpa = builder.allocator; | 26 | const gpa = builder.allocator; |
| 27 | const self = gpa.create(CheckObjectStep) catch unreachable; | 27 | const self = gpa.create(CheckObjectStep) catch @panic("OOM"); |
| 28 | self.* = .{ | 28 | self.* = .{ |
| 29 | .builder = builder, | 29 | .builder = builder, |
| 30 | .step = Step.init(.check_file, "CheckObject", gpa, make), | 30 | .step = Step.init(.check_file, "CheckObject", gpa, make), |
| ... | @@ -228,14 +228,14 @@ const Check = struct { | ... | @@ -228,14 +228,14 @@ const Check = struct { |
| 228 | self.actions.append(.{ | 228 | self.actions.append(.{ |
| 229 | .tag = .match, | 229 | .tag = .match, |
| 230 | .phrase = self.builder.dupe(phrase), | 230 | .phrase = self.builder.dupe(phrase), |
| 231 | }) catch unreachable; | 231 | }) catch @panic("OOM"); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | fn notPresent(self: *Check, phrase: []const u8) void { | 234 | fn notPresent(self: *Check, phrase: []const u8) void { |
| 235 | self.actions.append(.{ | 235 | self.actions.append(.{ |
| 236 | .tag = .not_present, | 236 | .tag = .not_present, |
| 237 | .phrase = self.builder.dupe(phrase), | 237 | .phrase = self.builder.dupe(phrase), |
| 238 | }) catch unreachable; | 238 | }) catch @panic("OOM"); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | fn computeCmp(self: *Check, phrase: []const u8, expected: ComputeCompareExpected) void { | 241 | fn computeCmp(self: *Check, phrase: []const u8, expected: ComputeCompareExpected) void { |
| ... | @@ -243,7 +243,7 @@ const Check = struct { | ... | @@ -243,7 +243,7 @@ const Check = struct { |
| 243 | .tag = .compute_cmp, | 243 | .tag = .compute_cmp, |
| 244 | .phrase = self.builder.dupe(phrase), | 244 | .phrase = self.builder.dupe(phrase), |
| 245 | .expected = expected, | 245 | .expected = expected, |
| 246 | }) catch unreachable; | 246 | }) catch @panic("OOM"); |
| 247 | } | 247 | } |
| 248 | }; | 248 | }; |
| 249 | 249 | ||
| ... | @@ -251,7 +251,7 @@ const Check = struct { | ... | @@ -251,7 +251,7 @@ const Check = struct { |
| 251 | pub fn checkStart(self: *CheckObjectStep, phrase: []const u8) void { | 251 | pub fn checkStart(self: *CheckObjectStep, phrase: []const u8) void { |
| 252 | var new_check = Check.create(self.builder); | 252 | var new_check = Check.create(self.builder); |
| 253 | new_check.match(phrase); | 253 | new_check.match(phrase); |
| 254 | self.checks.append(new_check) catch unreachable; | 254 | self.checks.append(new_check) catch @panic("OOM"); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | /// Adds another searched phrase to the latest created Check with `CheckObjectStep.checkStart(...)`. | 257 | /// Adds another searched phrase to the latest created Check with `CheckObjectStep.checkStart(...)`. |
| ... | @@ -293,7 +293,7 @@ pub fn checkComputeCompare( | ... | @@ -293,7 +293,7 @@ pub fn checkComputeCompare( |
| 293 | ) void { | 293 | ) void { |
| 294 | var new_check = Check.create(self.builder); | 294 | var new_check = Check.create(self.builder); |
| 295 | new_check.computeCmp(program, expected); | 295 | new_check.computeCmp(program, expected); |
| 296 | self.checks.append(new_check) catch unreachable; | 296 | self.checks.append(new_check) catch @panic("OOM"); |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | fn make(step: *Step) !void { | 299 | fn make(step: *Step) !void { |
lib/std/Build/CompileStep.zig+63-58| ... | @@ -312,7 +312,7 @@ pub fn create(builder: *std.Build, options: Options) *CompileStep { | ... | @@ -312,7 +312,7 @@ pub fn create(builder: *std.Build, options: Options) *CompileStep { |
| 312 | panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name}); | 312 | panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name}); |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | const self = builder.allocator.create(CompileStep) catch unreachable; | 315 | const self = builder.allocator.create(CompileStep) catch @panic("OOM"); |
| 316 | self.* = CompileStep{ | 316 | self.* = CompileStep{ |
| 317 | .strip = null, | 317 | .strip = null, |
| 318 | .unwind_tables = null, | 318 | .unwind_tables = null, |
| ... | @@ -364,7 +364,7 @@ pub fn create(builder: *std.Build, options: Options) *CompileStep { | ... | @@ -364,7 +364,7 @@ pub fn create(builder: *std.Build, options: Options) *CompileStep { |
| 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 = NativeTargetInfo.detect(self.target) catch unreachable, | 367 | .target_info = NativeTargetInfo.detect(self.target) catch @panic("unhandled error"), |
| 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); |
| ... | @@ -387,7 +387,7 @@ fn computeOutFileNames(self: *CompileStep) void { | ... | @@ -387,7 +387,7 @@ fn computeOutFileNames(self: *CompileStep) void { |
| 387 | .static => .Static, | 387 | .static => .Static, |
| 388 | }) else null, | 388 | }) else null, |
| 389 | .version = self.version, | 389 | .version = self.version, |
| 390 | }) catch unreachable; | 390 | }) catch @panic("OOM"); |
| 391 | 391 | ||
| 392 | if (self.kind == .lib) { | 392 | if (self.kind == .lib) { |
| 393 | if (self.linkage != null and self.linkage.? == .static) { | 393 | if (self.linkage != null and self.linkage.? == .static) { |
| ... | @@ -439,7 +439,7 @@ pub fn installRaw(self: *CompileStep, dest_filename: []const u8, options: Instal | ... | @@ -439,7 +439,7 @@ pub fn installRaw(self: *CompileStep, dest_filename: []const u8, options: Instal |
| 439 | pub fn installHeader(a: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void { | 439 | pub fn installHeader(a: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void { |
| 440 | const install_file = a.builder.addInstallHeaderFile(src_path, dest_rel_path); | 440 | const install_file = a.builder.addInstallHeaderFile(src_path, dest_rel_path); |
| 441 | a.builder.getInstallStep().dependOn(&install_file.step); | 441 | a.builder.getInstallStep().dependOn(&install_file.step); |
| 442 | a.installed_headers.append(&install_file.step) catch unreachable; | 442 | a.installed_headers.append(&install_file.step) catch @panic("OOM"); |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | pub fn installHeadersDirectory( | 445 | pub fn installHeadersDirectory( |
| ... | @@ -460,7 +460,7 @@ pub fn installHeadersDirectoryOptions( | ... | @@ -460,7 +460,7 @@ pub fn installHeadersDirectoryOptions( |
| 460 | ) void { | 460 | ) void { |
| 461 | const install_dir = a.builder.addInstallDirectory(options); | 461 | const install_dir = a.builder.addInstallDirectory(options); |
| 462 | a.builder.getInstallStep().dependOn(&install_dir.step); | 462 | a.builder.getInstallStep().dependOn(&install_dir.step); |
| 463 | a.installed_headers.append(&install_dir.step) catch unreachable; | 463 | a.installed_headers.append(&install_dir.step) catch @panic("OOM"); |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | pub fn installLibraryHeaders(a: *CompileStep, l: *CompileStep) void { | 466 | pub fn installLibraryHeaders(a: *CompileStep, l: *CompileStep) void { |
| ... | @@ -472,7 +472,7 @@ pub fn installLibraryHeaders(a: *CompileStep, l: *CompileStep) void { | ... | @@ -472,7 +472,7 @@ pub fn installLibraryHeaders(a: *CompileStep, l: *CompileStep) void { |
| 472 | const step_copy = switch (step.id) { | 472 | const step_copy = switch (step.id) { |
| 473 | inline .install_file, .install_dir => |id| blk: { | 473 | inline .install_file, .install_dir => |id| blk: { |
| 474 | const T = id.Type(); | 474 | const T = id.Type(); |
| 475 | const ptr = a.builder.allocator.create(T) catch unreachable; | 475 | const ptr = a.builder.allocator.create(T) catch @panic("OOM"); |
| 476 | ptr.* = step.cast(T).?.*; | 476 | ptr.* = step.cast(T).?.*; |
| 477 | ptr.override_source_builder = ptr.builder; | 477 | ptr.override_source_builder = ptr.builder; |
| 478 | ptr.builder = a.builder; | 478 | ptr.builder = a.builder; |
| ... | @@ -480,10 +480,10 @@ pub fn installLibraryHeaders(a: *CompileStep, l: *CompileStep) void { | ... | @@ -480,10 +480,10 @@ pub fn installLibraryHeaders(a: *CompileStep, l: *CompileStep) void { |
| 480 | }, | 480 | }, |
| 481 | else => unreachable, | 481 | else => unreachable, |
| 482 | }; | 482 | }; |
| 483 | a.installed_headers.append(step_copy) catch unreachable; | 483 | a.installed_headers.append(step_copy) catch @panic("OOM"); |
| 484 | install_step.dependOn(step_copy); | 484 | install_step.dependOn(step_copy); |
| 485 | } | 485 | } |
| 486 | a.installed_headers.appendSlice(l.installed_headers.items) catch unreachable; | 486 | a.installed_headers.appendSlice(l.installed_headers.items) catch @panic("OOM"); |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | /// Creates a `RunStep` with an executable built with `addExecutable`. | 489 | /// Creates a `RunStep` with an executable built with `addExecutable`. |
| ... | @@ -532,19 +532,19 @@ pub fn setLinkerScriptPath(self: *CompileStep, source: FileSource) void { | ... | @@ -532,19 +532,19 @@ pub fn setLinkerScriptPath(self: *CompileStep, source: FileSource) void { |
| 532 | } | 532 | } |
| 533 | 533 | ||
| 534 | pub fn linkFramework(self: *CompileStep, framework_name: []const u8) void { | 534 | pub fn linkFramework(self: *CompileStep, framework_name: []const u8) void { |
| 535 | self.frameworks.put(self.builder.dupe(framework_name), .{}) catch unreachable; | 535 | self.frameworks.put(self.builder.dupe(framework_name), .{}) catch @panic("OOM"); |
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | pub fn linkFrameworkNeeded(self: *CompileStep, framework_name: []const u8) void { | 538 | pub fn linkFrameworkNeeded(self: *CompileStep, framework_name: []const u8) void { |
| 539 | self.frameworks.put(self.builder.dupe(framework_name), .{ | 539 | self.frameworks.put(self.builder.dupe(framework_name), .{ |
| 540 | .needed = true, | 540 | .needed = true, |
| 541 | }) catch unreachable; | 541 | }) catch @panic("OOM"); |
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | pub fn linkFrameworkWeak(self: *CompileStep, framework_name: []const u8) void { | 544 | pub fn linkFrameworkWeak(self: *CompileStep, framework_name: []const u8) void { |
| 545 | self.frameworks.put(self.builder.dupe(framework_name), .{ | 545 | self.frameworks.put(self.builder.dupe(framework_name), .{ |
| 546 | .weak = true, | 546 | .weak = true, |
| 547 | }) catch unreachable; | 547 | }) catch @panic("OOM"); |
| 548 | } | 548 | } |
| 549 | 549 | ||
| 550 | /// Returns whether the library, executable, or object depends on a particular system library. | 550 | /// Returns whether the library, executable, or object depends on a particular system library. |
| ... | @@ -596,12 +596,12 @@ pub fn linkLibCpp(self: *CompileStep) void { | ... | @@ -596,12 +596,12 @@ pub fn linkLibCpp(self: *CompileStep) void { |
| 596 | /// `name` and `value` need not live longer than the function call. | 596 | /// `name` and `value` need not live longer than the function call. |
| 597 | pub fn defineCMacro(self: *CompileStep, name: []const u8, value: ?[]const u8) void { | 597 | pub fn defineCMacro(self: *CompileStep, name: []const u8, value: ?[]const u8) void { |
| 598 | const macro = std.Build.constructCMacro(self.builder.allocator, name, value); | 598 | const macro = std.Build.constructCMacro(self.builder.allocator, name, value); |
| 599 | self.c_macros.append(macro) catch unreachable; | 599 | self.c_macros.append(macro) catch @panic("OOM"); |
| 600 | } | 600 | } |
| 601 | 601 | ||
| 602 | /// name_and_value looks like [name]=[value]. If the value is omitted, it is set to 1. | 602 | /// name_and_value looks like [name]=[value]. If the value is omitted, it is set to 1. |
| 603 | pub fn defineCMacroRaw(self: *CompileStep, name_and_value: []const u8) void { | 603 | pub fn defineCMacroRaw(self: *CompileStep, name_and_value: []const u8) void { |
| 604 | self.c_macros.append(self.builder.dupe(name_and_value)) catch unreachable; | 604 | self.c_macros.append(self.builder.dupe(name_and_value)) catch @panic("OOM"); |
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | /// This one has no integration with anything, it just puts -lname on the command line. | 607 | /// This one has no integration with anything, it just puts -lname on the command line. |
| ... | @@ -614,7 +614,7 @@ pub fn linkSystemLibraryName(self: *CompileStep, name: []const u8) void { | ... | @@ -614,7 +614,7 @@ pub fn linkSystemLibraryName(self: *CompileStep, name: []const u8) void { |
| 614 | .weak = false, | 614 | .weak = false, |
| 615 | .use_pkg_config = .no, | 615 | .use_pkg_config = .no, |
| 616 | }, | 616 | }, |
| 617 | }) catch unreachable; | 617 | }) catch @panic("OOM"); |
| 618 | } | 618 | } |
| 619 | 619 | ||
| 620 | /// This one has no integration with anything, it just puts -needed-lname on the command line. | 620 | /// This one has no integration with anything, it just puts -needed-lname on the command line. |
| ... | @@ -627,7 +627,7 @@ pub fn linkSystemLibraryNeededName(self: *CompileStep, name: []const u8) void { | ... | @@ -627,7 +627,7 @@ pub fn linkSystemLibraryNeededName(self: *CompileStep, name: []const u8) void { |
| 627 | .weak = false, | 627 | .weak = false, |
| 628 | .use_pkg_config = .no, | 628 | .use_pkg_config = .no, |
| 629 | }, | 629 | }, |
| 630 | }) catch unreachable; | 630 | }) catch @panic("OOM"); |
| 631 | } | 631 | } |
| 632 | 632 | ||
| 633 | /// Darwin-only. This one has no integration with anything, it just puts -weak-lname on the | 633 | /// Darwin-only. This one has no integration with anything, it just puts -weak-lname on the |
| ... | @@ -640,7 +640,7 @@ pub fn linkSystemLibraryWeakName(self: *CompileStep, name: []const u8) void { | ... | @@ -640,7 +640,7 @@ pub fn linkSystemLibraryWeakName(self: *CompileStep, name: []const u8) void { |
| 640 | .weak = true, | 640 | .weak = true, |
| 641 | .use_pkg_config = .no, | 641 | .use_pkg_config = .no, |
| 642 | }, | 642 | }, |
| 643 | }) catch unreachable; | 643 | }) catch @panic("OOM"); |
| 644 | } | 644 | } |
| 645 | 645 | ||
| 646 | /// This links against a system library, exclusively using pkg-config to find the library. | 646 | /// This links against a system library, exclusively using pkg-config to find the library. |
| ... | @@ -653,7 +653,7 @@ pub fn linkSystemLibraryPkgConfigOnly(self: *CompileStep, lib_name: []const u8) | ... | @@ -653,7 +653,7 @@ pub fn linkSystemLibraryPkgConfigOnly(self: *CompileStep, lib_name: []const u8) |
| 653 | .weak = false, | 653 | .weak = false, |
| 654 | .use_pkg_config = .force, | 654 | .use_pkg_config = .force, |
| 655 | }, | 655 | }, |
| 656 | }) catch unreachable; | 656 | }) catch @panic("OOM"); |
| 657 | } | 657 | } |
| 658 | 658 | ||
| 659 | /// This links against a system library, exclusively using pkg-config to find the library. | 659 | /// This links against a system library, exclusively using pkg-config to find the library. |
| ... | @@ -666,7 +666,7 @@ pub fn linkSystemLibraryNeededPkgConfigOnly(self: *CompileStep, lib_name: []cons | ... | @@ -666,7 +666,7 @@ pub fn linkSystemLibraryNeededPkgConfigOnly(self: *CompileStep, lib_name: []cons |
| 666 | .weak = false, | 666 | .weak = false, |
| 667 | .use_pkg_config = .force, | 667 | .use_pkg_config = .force, |
| 668 | }, | 668 | }, |
| 669 | }) catch unreachable; | 669 | }) catch @panic("OOM"); |
| 670 | } | 670 | } |
| 671 | 671 | ||
| 672 | /// Run pkg-config for the given library name and parse the output, returning the arguments | 672 | /// Run pkg-config for the given library name and parse the output, returning the arguments |
| ... | @@ -797,7 +797,7 @@ fn linkSystemLibraryInner(self: *CompileStep, name: []const u8, opts: struct { | ... | @@ -797,7 +797,7 @@ fn linkSystemLibraryInner(self: *CompileStep, name: []const u8, opts: struct { |
| 797 | .weak = opts.weak, | 797 | .weak = opts.weak, |
| 798 | .use_pkg_config = .yes, | 798 | .use_pkg_config = .yes, |
| 799 | }, | 799 | }, |
| 800 | }) catch unreachable; | 800 | }) catch @panic("OOM"); |
| 801 | } | 801 | } |
| 802 | 802 | ||
| 803 | pub fn setNamePrefix(self: *CompileStep, text: []const u8) void { | 803 | pub fn setNamePrefix(self: *CompileStep, text: []const u8) void { |
| ... | @@ -817,7 +817,7 @@ pub fn setTestRunner(self: *CompileStep, path: ?[]const u8) void { | ... | @@ -817,7 +817,7 @@ pub fn setTestRunner(self: *CompileStep, path: ?[]const u8) void { |
| 817 | 817 | ||
| 818 | /// Handy when you have many C/C++ source files and want them all to have the same flags. | 818 | /// Handy when you have many C/C++ source files and want them all to have the same flags. |
| 819 | pub fn addCSourceFiles(self: *CompileStep, files: []const []const u8, flags: []const []const u8) void { | 819 | pub fn addCSourceFiles(self: *CompileStep, files: []const []const u8, flags: []const []const u8) void { |
| 820 | const c_source_files = self.builder.allocator.create(CSourceFiles) catch unreachable; | 820 | const c_source_files = self.builder.allocator.create(CSourceFiles) catch @panic("OOM"); |
| 821 | 821 | ||
| 822 | const files_copy = self.builder.dupeStrings(files); | 822 | const files_copy = self.builder.dupeStrings(files); |
| 823 | const flags_copy = self.builder.dupeStrings(flags); | 823 | const flags_copy = self.builder.dupeStrings(flags); |
| ... | @@ -826,7 +826,7 @@ pub fn addCSourceFiles(self: *CompileStep, files: []const []const u8, flags: []c | ... | @@ -826,7 +826,7 @@ pub fn addCSourceFiles(self: *CompileStep, files: []const []const u8, flags: []c |
| 826 | .files = files_copy, | 826 | .files = files_copy, |
| 827 | .flags = flags_copy, | 827 | .flags = flags_copy, |
| 828 | }; | 828 | }; |
| 829 | self.link_objects.append(.{ .c_source_files = c_source_files }) catch unreachable; | 829 | self.link_objects.append(.{ .c_source_files = c_source_files }) catch @panic("OOM"); |
| 830 | } | 830 | } |
| 831 | 831 | ||
| 832 | pub fn addCSourceFile(self: *CompileStep, file: []const u8, flags: []const []const u8) void { | 832 | pub fn addCSourceFile(self: *CompileStep, file: []const u8, flags: []const []const u8) void { |
| ... | @@ -837,9 +837,9 @@ pub fn addCSourceFile(self: *CompileStep, file: []const u8, flags: []const []con | ... | @@ -837,9 +837,9 @@ pub fn addCSourceFile(self: *CompileStep, file: []const u8, flags: []const []con |
| 837 | } | 837 | } |
| 838 | 838 | ||
| 839 | pub fn addCSourceFileSource(self: *CompileStep, source: CSourceFile) void { | 839 | pub fn addCSourceFileSource(self: *CompileStep, source: CSourceFile) void { |
| 840 | const c_source_file = self.builder.allocator.create(CSourceFile) catch unreachable; | 840 | const c_source_file = self.builder.allocator.create(CSourceFile) catch @panic("OOM"); |
| 841 | c_source_file.* = source.dupe(self.builder); | 841 | c_source_file.* = source.dupe(self.builder); |
| 842 | self.link_objects.append(.{ .c_source_file = c_source_file }) catch unreachable; | 842 | self.link_objects.append(.{ .c_source_file = c_source_file }) catch @panic("OOM"); |
| 843 | source.source.addStepDependencies(&self.step); | 843 | source.source.addStepDependencies(&self.step); |
| 844 | } | 844 | } |
| 845 | 845 | ||
| ... | @@ -893,12 +893,12 @@ pub fn getOutputPdbSource(self: *CompileStep) FileSource { | ... | @@ -893,12 +893,12 @@ pub fn getOutputPdbSource(self: *CompileStep) FileSource { |
| 893 | pub fn addAssemblyFile(self: *CompileStep, path: []const u8) void { | 893 | pub fn addAssemblyFile(self: *CompileStep, path: []const u8) void { |
| 894 | self.link_objects.append(.{ | 894 | self.link_objects.append(.{ |
| 895 | .assembly_file = .{ .path = self.builder.dupe(path) }, | 895 | .assembly_file = .{ .path = self.builder.dupe(path) }, |
| 896 | }) catch unreachable; | 896 | }) catch @panic("OOM"); |
| 897 | } | 897 | } |
| 898 | 898 | ||
| 899 | pub fn addAssemblyFileSource(self: *CompileStep, source: FileSource) void { | 899 | pub fn addAssemblyFileSource(self: *CompileStep, source: FileSource) void { |
| 900 | const source_duped = source.dupe(self.builder); | 900 | const source_duped = source.dupe(self.builder); |
| 901 | self.link_objects.append(.{ .assembly_file = source_duped }) catch unreachable; | 901 | self.link_objects.append(.{ .assembly_file = source_duped }) catch @panic("OOM"); |
| 902 | source_duped.addStepDependencies(&self.step); | 902 | source_duped.addStepDependencies(&self.step); |
| 903 | } | 903 | } |
| 904 | 904 | ||
| ... | @@ -907,7 +907,7 @@ pub fn addObjectFile(self: *CompileStep, source_file: []const u8) void { | ... | @@ -907,7 +907,7 @@ pub fn addObjectFile(self: *CompileStep, source_file: []const u8) void { |
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | pub fn addObjectFileSource(self: *CompileStep, source: FileSource) void { | 909 | pub fn addObjectFileSource(self: *CompileStep, source: FileSource) void { |
| 910 | self.link_objects.append(.{ .static_path = source.dupe(self.builder) }) catch unreachable; | 910 | self.link_objects.append(.{ .static_path = source.dupe(self.builder) }) catch @panic("OOM"); |
| 911 | source.addStepDependencies(&self.step); | 911 | source.addStepDependencies(&self.step); |
| 912 | } | 912 | } |
| 913 | 913 | ||
| ... | @@ -922,11 +922,11 @@ pub const addLibPath = @compileError("deprecated, use addLibraryPath"); | ... | @@ -922,11 +922,11 @@ pub const addLibPath = @compileError("deprecated, use addLibraryPath"); |
| 922 | pub const addFrameworkDir = @compileError("deprecated, use addFrameworkPath"); | 922 | pub const addFrameworkDir = @compileError("deprecated, use addFrameworkPath"); |
| 923 | 923 | ||
| 924 | pub fn addSystemIncludePath(self: *CompileStep, path: []const u8) void { | 924 | pub fn addSystemIncludePath(self: *CompileStep, path: []const u8) void { |
| 925 | self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable; | 925 | self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch @panic("OOM"); |
| 926 | } | 926 | } |
| 927 | 927 | ||
| 928 | pub fn addIncludePath(self: *CompileStep, path: []const u8) void { | 928 | pub fn addIncludePath(self: *CompileStep, path: []const u8) void { |
| 929 | self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable; | 929 | self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch @panic("OOM"); |
| 930 | } | 930 | } |
| 931 | 931 | ||
| 932 | pub fn addConfigHeader(self: *CompileStep, config_header: *ConfigHeaderStep) void { | 932 | pub fn addConfigHeader(self: *CompileStep, config_header: *ConfigHeaderStep) void { |
| ... | @@ -935,19 +935,19 @@ pub fn addConfigHeader(self: *CompileStep, config_header: *ConfigHeaderStep) voi | ... | @@ -935,19 +935,19 @@ pub fn addConfigHeader(self: *CompileStep, config_header: *ConfigHeaderStep) voi |
| 935 | } | 935 | } |
| 936 | 936 | ||
| 937 | pub fn addLibraryPath(self: *CompileStep, path: []const u8) void { | 937 | pub fn addLibraryPath(self: *CompileStep, path: []const u8) void { |
| 938 | self.lib_paths.append(self.builder.dupe(path)) catch unreachable; | 938 | self.lib_paths.append(self.builder.dupe(path)) catch @panic("OOM"); |
| 939 | } | 939 | } |
| 940 | 940 | ||
| 941 | pub fn addRPath(self: *CompileStep, path: []const u8) void { | 941 | pub fn addRPath(self: *CompileStep, path: []const u8) void { |
| 942 | self.rpaths.append(self.builder.dupe(path)) catch unreachable; | 942 | self.rpaths.append(self.builder.dupe(path)) catch @panic("OOM"); |
| 943 | } | 943 | } |
| 944 | 944 | ||
| 945 | pub fn addFrameworkPath(self: *CompileStep, dir_path: []const u8) void { | 945 | pub fn addFrameworkPath(self: *CompileStep, dir_path: []const u8) void { |
| 946 | self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable; | 946 | self.framework_dirs.append(self.builder.dupe(dir_path)) catch @panic("OOM"); |
| 947 | } | 947 | } |
| 948 | 948 | ||
| 949 | pub fn addPackage(self: *CompileStep, package: Pkg) void { | 949 | pub fn addPackage(self: *CompileStep, package: Pkg) void { |
| 950 | self.packages.append(self.builder.dupePkg(package)) catch unreachable; | 950 | self.packages.append(self.builder.dupePkg(package)) catch @panic("OOM"); |
| 951 | self.addRecursiveBuildDeps(package); | 951 | self.addRecursiveBuildDeps(package); |
| 952 | } | 952 | } |
| 953 | 953 | ||
| ... | @@ -1010,7 +1010,7 @@ pub fn addVcpkgPaths(self: *CompileStep, linkage: CompileStep.Linkage) !void { | ... | @@ -1010,7 +1010,7 @@ pub fn addVcpkgPaths(self: *CompileStep, linkage: CompileStep.Linkage) !void { |
| 1010 | 1010 | ||
| 1011 | pub fn setExecCmd(self: *CompileStep, args: []const ?[]const u8) void { | 1011 | pub fn setExecCmd(self: *CompileStep, args: []const ?[]const u8) void { |
| 1012 | assert(self.kind == .@"test"); | 1012 | assert(self.kind == .@"test"); |
| 1013 | const duped_args = self.builder.allocator.alloc(?[]u8, args.len) catch unreachable; | 1013 | const duped_args = self.builder.allocator.alloc(?[]u8, args.len) catch @panic("OOM"); |
| 1014 | for (args) |arg, i| { | 1014 | for (args) |arg, i| { |
| 1015 | duped_args[i] = if (arg) |a| self.builder.dupe(a) else null; | 1015 | duped_args[i] = if (arg) |a| self.builder.dupe(a) else null; |
| 1016 | } | 1016 | } |
| ... | @@ -1019,8 +1019,8 @@ pub fn setExecCmd(self: *CompileStep, args: []const ?[]const u8) void { | ... | @@ -1019,8 +1019,8 @@ pub fn setExecCmd(self: *CompileStep, args: []const ?[]const u8) void { |
| 1019 | 1019 | ||
| 1020 | fn linkLibraryOrObject(self: *CompileStep, other: *CompileStep) void { | 1020 | fn linkLibraryOrObject(self: *CompileStep, other: *CompileStep) void { |
| 1021 | self.step.dependOn(&other.step); | 1021 | self.step.dependOn(&other.step); |
| 1022 | self.link_objects.append(.{ .other_step = other }) catch unreachable; | 1022 | self.link_objects.append(.{ .other_step = other }) catch @panic("OOM"); |
| 1023 | self.include_dirs.append(.{ .other_step = other }) catch unreachable; | 1023 | self.include_dirs.append(.{ .other_step = other }) catch @panic("OOM"); |
| 1024 | } | 1024 | } |
| 1025 | 1025 | ||
| 1026 | fn makePackageCmd(self: *CompileStep, pkg: Pkg, zig_args: *ArrayList([]const u8)) error{OutOfMemory}!void { | 1026 | fn makePackageCmd(self: *CompileStep, pkg: Pkg, zig_args: *ArrayList([]const u8)) error{OutOfMemory}!void { |
| ... | @@ -1051,7 +1051,7 @@ fn make(step: *Step) !void { | ... | @@ -1051,7 +1051,7 @@ fn make(step: *Step) !void { |
| 1051 | var zig_args = ArrayList([]const u8).init(builder.allocator); | 1051 | var zig_args = ArrayList([]const u8).init(builder.allocator); |
| 1052 | defer zig_args.deinit(); | 1052 | defer zig_args.deinit(); |
| 1053 | 1053 | ||
| 1054 | zig_args.append(builder.zig_exe) catch unreachable; | 1054 | try zig_args.append(builder.zig_exe); |
| 1055 | 1055 | ||
| 1056 | const cmd = switch (self.kind) { | 1056 | const cmd = switch (self.kind) { |
| 1057 | .lib => "build-lib", | 1057 | .lib => "build-lib", |
| ... | @@ -1060,7 +1060,7 @@ fn make(step: *Step) !void { | ... | @@ -1060,7 +1060,7 @@ fn make(step: *Step) !void { |
| 1060 | .@"test" => "test", | 1060 | .@"test" => "test", |
| 1061 | .test_exe => "test", | 1061 | .test_exe => "test", |
| 1062 | }; | 1062 | }; |
| 1063 | zig_args.append(cmd) catch unreachable; | 1063 | try zig_args.append(cmd); |
| 1064 | 1064 | ||
| 1065 | if (builder.color != .auto) { | 1065 | if (builder.color != .auto) { |
| 1066 | try zig_args.append("--color"); | 1066 | try zig_args.append("--color"); |
| ... | @@ -1265,12 +1265,12 @@ fn make(step: *Step) !void { | ... | @@ -1265,12 +1265,12 @@ fn make(step: *Step) !void { |
| 1265 | try zig_args.append("--debug-compile-errors"); | 1265 | try zig_args.append("--debug-compile-errors"); |
| 1266 | } | 1266 | } |
| 1267 | 1267 | ||
| 1268 | if (builder.verbose_cimport) zig_args.append("--verbose-cimport") catch unreachable; | 1268 | if (builder.verbose_cimport) try zig_args.append("--verbose-cimport"); |
| 1269 | if (builder.verbose_air) zig_args.append("--verbose-air") catch unreachable; | 1269 | if (builder.verbose_air) try zig_args.append("--verbose-air"); |
| 1270 | if (builder.verbose_llvm_ir) zig_args.append("--verbose-llvm-ir") catch unreachable; | 1270 | if (builder.verbose_llvm_ir) try zig_args.append("--verbose-llvm-ir"); |
| 1271 | if (builder.verbose_link or self.verbose_link) zig_args.append("--verbose-link") catch unreachable; | 1271 | if (builder.verbose_link or self.verbose_link) try zig_args.append("--verbose-link"); |
| 1272 | if (builder.verbose_cc or self.verbose_cc) zig_args.append("--verbose-cc") catch unreachable; | 1272 | if (builder.verbose_cc or self.verbose_cc) try zig_args.append("--verbose-cc"); |
| 1273 | if (builder.verbose_llvm_cpu_features) zig_args.append("--verbose-llvm-cpu-features") catch unreachable; | 1273 | if (builder.verbose_llvm_cpu_features) try zig_args.append("--verbose-llvm-cpu-features"); |
| 1274 | 1274 | ||
| 1275 | if (self.emit_analysis.getArg(builder, "emit-analysis")) |arg| try zig_args.append(arg); | 1275 | if (self.emit_analysis.getArg(builder, "emit-analysis")) |arg| try zig_args.append(arg); |
| 1276 | if (self.emit_asm.getArg(builder, "emit-asm")) |arg| try zig_args.append(arg); | 1276 | if (self.emit_asm.getArg(builder, "emit-asm")) |arg| try zig_args.append(arg); |
| ... | @@ -1336,7 +1336,7 @@ fn make(step: *Step) !void { | ... | @@ -1336,7 +1336,7 @@ fn make(step: *Step) !void { |
| 1336 | 1336 | ||
| 1337 | switch (self.optimize) { | 1337 | switch (self.optimize) { |
| 1338 | .Debug => {}, // Skip since it's the default. | 1338 | .Debug => {}, // Skip since it's the default. |
| 1339 | else => zig_args.append(builder.fmt("-O{s}", .{@tagName(self.optimize)})) catch unreachable, | 1339 | else => try zig_args.append(builder.fmt("-O{s}", .{@tagName(self.optimize)})), |
| 1340 | } | 1340 | } |
| 1341 | 1341 | ||
| 1342 | try zig_args.append("--cache-dir"); | 1342 | try zig_args.append("--cache-dir"); |
| ... | @@ -1345,8 +1345,8 @@ fn make(step: *Step) !void { | ... | @@ -1345,8 +1345,8 @@ fn make(step: *Step) !void { |
| 1345 | try zig_args.append("--global-cache-dir"); | 1345 | try zig_args.append("--global-cache-dir"); |
| 1346 | try zig_args.append(builder.pathFromRoot(builder.global_cache_root)); | 1346 | try zig_args.append(builder.pathFromRoot(builder.global_cache_root)); |
| 1347 | 1347 | ||
| 1348 | zig_args.append("--name") catch unreachable; | 1348 | try zig_args.append("--name"); |
| 1349 | zig_args.append(self.name) catch unreachable; | 1349 | try zig_args.append(self.name); |
| 1350 | 1350 | ||
| 1351 | if (self.linkage) |some| switch (some) { | 1351 | if (self.linkage) |some| switch (some) { |
| 1352 | .dynamic => try zig_args.append("-dynamic"), | 1352 | .dynamic => try zig_args.append("-dynamic"), |
| ... | @@ -1354,8 +1354,8 @@ fn make(step: *Step) !void { | ... | @@ -1354,8 +1354,8 @@ fn make(step: *Step) !void { |
| 1354 | }; | 1354 | }; |
| 1355 | if (self.kind == .lib and self.linkage != null and self.linkage.? == .dynamic) { | 1355 | if (self.kind == .lib and self.linkage != null and self.linkage.? == .dynamic) { |
| 1356 | if (self.version) |version| { | 1356 | if (self.version) |version| { |
| 1357 | zig_args.append("--version") catch unreachable; | 1357 | try zig_args.append("--version"); |
| 1358 | zig_args.append(builder.fmt("{}", .{version})) catch unreachable; | 1358 | try zig_args.append(builder.fmt("{}", .{version})); |
| 1359 | } | 1359 | } |
| 1360 | 1360 | ||
| 1361 | if (self.target.isDarwin()) { | 1361 | if (self.target.isDarwin()) { |
| ... | @@ -1651,13 +1651,13 @@ fn make(step: *Step) !void { | ... | @@ -1651,13 +1651,13 @@ fn make(step: *Step) !void { |
| 1651 | const name = entry.key_ptr.*; | 1651 | const name = entry.key_ptr.*; |
| 1652 | const info = entry.value_ptr.*; | 1652 | const info = entry.value_ptr.*; |
| 1653 | if (info.needed) { | 1653 | if (info.needed) { |
| 1654 | zig_args.append("-needed_framework") catch unreachable; | 1654 | try zig_args.append("-needed_framework"); |
| 1655 | } else if (info.weak) { | 1655 | } else if (info.weak) { |
| 1656 | zig_args.append("-weak_framework") catch unreachable; | 1656 | try zig_args.append("-weak_framework"); |
| 1657 | } else { | 1657 | } else { |
| 1658 | zig_args.append("-framework") catch unreachable; | 1658 | try zig_args.append("-framework"); |
| 1659 | } | 1659 | } |
| 1660 | zig_args.append(name) catch unreachable; | 1660 | try zig_args.append(name); |
| 1661 | } | 1661 | } |
| 1662 | } else { | 1662 | } else { |
| 1663 | if (self.framework_dirs.items.len > 0) { | 1663 | if (self.framework_dirs.items.len > 0) { |
| ... | @@ -1748,7 +1748,7 @@ fn make(step: *Step) !void { | ... | @@ -1748,7 +1748,7 @@ fn make(step: *Step) !void { |
| 1748 | // Slow path for arguments that need to be escaped. We'll need to allocate and copy | 1748 | // Slow path for arguments that need to be escaped. We'll need to allocate and copy |
| 1749 | var escaped = try ArrayList(u8).initCapacity(args_arena.allocator(), arg.len + 1); | 1749 | var escaped = try ArrayList(u8).initCapacity(args_arena.allocator(), arg.len + 1); |
| 1750 | const writer = escaped.writer(); | 1750 | const writer = escaped.writer(); |
| 1751 | writer.writeAll(arg[0..arg_idx]) catch unreachable; | 1751 | try writer.writeAll(arg[0..arg_idx]); |
| 1752 | for (arg[arg_idx..]) |to_escape| { | 1752 | for (arg[arg_idx..]) |to_escape| { |
| 1753 | if (to_escape == '\\' or to_escape == '"') try writer.writeByte('\\'); | 1753 | if (to_escape == '\\' or to_escape == '"') try writer.writeByte('\\'); |
| 1754 | try writer.writeByte(to_escape); | 1754 | try writer.writeByte(to_escape); |
| ... | @@ -1874,23 +1874,28 @@ fn findVcpkgRoot(allocator: Allocator) !?[]const u8 { | ... | @@ -1874,23 +1874,28 @@ fn findVcpkgRoot(allocator: Allocator) !?[]const u8 { |
| 1874 | return vcpkg_path; | 1874 | return vcpkg_path; |
| 1875 | } | 1875 | } |
| 1876 | 1876 | ||
| 1877 | pub fn doAtomicSymLinks(allocator: Allocator, output_path: []const u8, filename_major_only: []const u8, filename_name_only: []const u8) !void { | 1877 | pub fn doAtomicSymLinks( |
| 1878 | allocator: Allocator, | ||
| 1879 | output_path: []const u8, | ||
| 1880 | filename_major_only: []const u8, | ||
| 1881 | filename_name_only: []const u8, | ||
| 1882 | ) !void { | ||
| 1878 | const out_dir = fs.path.dirname(output_path) orelse "."; | 1883 | const out_dir = fs.path.dirname(output_path) orelse "."; |
| 1879 | const out_basename = fs.path.basename(output_path); | 1884 | const out_basename = fs.path.basename(output_path); |
| 1880 | // sym link for libfoo.so.1 to libfoo.so.1.2.3 | 1885 | // sym link for libfoo.so.1 to libfoo.so.1.2.3 |
| 1881 | const major_only_path = fs.path.join( | 1886 | const major_only_path = try fs.path.join( |
| 1882 | allocator, | 1887 | allocator, |
| 1883 | &[_][]const u8{ out_dir, filename_major_only }, | 1888 | &[_][]const u8{ out_dir, filename_major_only }, |
| 1884 | ) catch unreachable; | 1889 | ); |
| 1885 | fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { | 1890 | fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { |
| 1886 | log.err("Unable to symlink {s} -> {s}", .{ major_only_path, out_basename }); | 1891 | log.err("Unable to symlink {s} -> {s}", .{ major_only_path, out_basename }); |
| 1887 | return err; | 1892 | return err; |
| 1888 | }; | 1893 | }; |
| 1889 | // sym link for libfoo.so to libfoo.so.1 | 1894 | // sym link for libfoo.so to libfoo.so.1 |
| 1890 | const name_only_path = fs.path.join( | 1895 | const name_only_path = try fs.path.join( |
| 1891 | allocator, | 1896 | allocator, |
| 1892 | &[_][]const u8{ out_dir, filename_name_only }, | 1897 | &[_][]const u8{ out_dir, filename_name_only }, |
| 1893 | ) catch unreachable; | 1898 | ); |
| 1894 | fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { | 1899 | fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { |
| 1895 | log.err("Unable to symlink {s} -> {s}", .{ name_only_path, filename_major_only }); | 1900 | log.err("Unable to symlink {s} -> {s}", .{ name_only_path, filename_major_only }); |
| 1896 | return err; | 1901 | return err; |
lib/std/Build/EmulatableRunStep.zig+4-4| ... | @@ -47,7 +47,7 @@ hide_foreign_binaries_warning: bool, | ... | @@ -47,7 +47,7 @@ hide_foreign_binaries_warning: bool, |
| 47 | /// Asserts given artifact is an executable. | 47 | /// Asserts given artifact is an executable. |
| 48 | pub fn create(builder: *std.Build, name: []const u8, artifact: *CompileStep) *EmulatableRunStep { | 48 | pub fn create(builder: *std.Build, name: []const u8, artifact: *CompileStep) *EmulatableRunStep { |
| 49 | std.debug.assert(artifact.kind == .exe or artifact.kind == .test_exe); | 49 | std.debug.assert(artifact.kind == .exe or artifact.kind == .test_exe); |
| 50 | const self = builder.allocator.create(EmulatableRunStep) catch unreachable; | 50 | const self = builder.allocator.create(EmulatableRunStep) catch @panic("OOM"); |
| 51 | 51 | ||
| 52 | const option_name = "hide-foreign-warnings"; | 52 | const option_name = "hide-foreign-warnings"; |
| 53 | const hide_warnings = if (builder.available_options_map.get(option_name) == null) warn: { | 53 | const hide_warnings = if (builder.available_options_map.get(option_name) == null) warn: { |
| ... | @@ -154,9 +154,9 @@ fn warnAboutForeignBinaries(step: *EmulatableRunStep) void { | ... | @@ -154,9 +154,9 @@ fn warnAboutForeignBinaries(step: *EmulatableRunStep) void { |
| 154 | const builder = step.builder; | 154 | const builder = step.builder; |
| 155 | const artifact = step.exe; | 155 | const artifact = step.exe; |
| 156 | 156 | ||
| 157 | const host_name = builder.host.target.zigTriple(builder.allocator) catch unreachable; | 157 | const host_name = builder.host.target.zigTriple(builder.allocator) catch @panic("unhandled error"); |
| 158 | const foreign_name = artifact.target.zigTriple(builder.allocator) catch unreachable; | 158 | const foreign_name = artifact.target.zigTriple(builder.allocator) catch @panic("unhandled error"); |
| 159 | const target_info = std.zig.system.NativeTargetInfo.detect(artifact.target) catch unreachable; | 159 | const target_info = std.zig.system.NativeTargetInfo.detect(artifact.target) catch @panic("unhandled error"); |
| 160 | const need_cross_glibc = artifact.target.isGnuLibC() and artifact.is_linking_libc; | 160 | const need_cross_glibc = artifact.target.isGnuLibC() and artifact.is_linking_libc; |
| 161 | switch (builder.host.getExternalExecutor(target_info, .{ | 161 | switch (builder.host.getExternalExecutor(target_info, .{ |
| 162 | .qemu_fixes_dl = need_cross_glibc and builder.glibc_runtimes_dir != null, | 162 | .qemu_fixes_dl = need_cross_glibc and builder.glibc_runtimes_dir != null, |
lib/std/Build/FmtStep.zig+2-2| ... | @@ -9,12 +9,12 @@ builder: *std.Build, | ... | @@ -9,12 +9,12 @@ builder: *std.Build, |
| 9 | argv: [][]const u8, | 9 | argv: [][]const u8, |
| 10 | 10 | ||
| 11 | pub fn create(builder: *std.Build, paths: []const []const u8) *FmtStep { | 11 | pub fn create(builder: *std.Build, paths: []const []const u8) *FmtStep { |
| 12 | const self = builder.allocator.create(FmtStep) catch unreachable; | 12 | const self = builder.allocator.create(FmtStep) catch @panic("OOM"); |
| 13 | const name = "zig fmt"; | 13 | const name = "zig fmt"; |
| 14 | self.* = FmtStep{ | 14 | self.* = FmtStep{ |
| 15 | .step = Step.init(.fmt, name, builder.allocator, make), | 15 | .step = Step.init(.fmt, name, builder.allocator, make), |
| 16 | .builder = builder, | 16 | .builder = builder, |
| 17 | .argv = builder.allocator.alloc([]u8, paths.len + 2) catch unreachable, | 17 | .argv = builder.allocator.alloc([]u8, paths.len + 2) catch @panic("OOM"), |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | self.argv[0] = builder.zig_exe; | 20 | self.argv[0] = builder.zig_exe; |
lib/std/Build/InstallArtifactStep.zig+1-1| ... | @@ -16,7 +16,7 @@ h_dir: ?InstallDir, | ... | @@ -16,7 +16,7 @@ h_dir: ?InstallDir, |
| 16 | pub fn create(builder: *std.Build, artifact: *CompileStep) *InstallArtifactStep { | 16 | pub fn create(builder: *std.Build, artifact: *CompileStep) *InstallArtifactStep { |
| 17 | if (artifact.install_step) |s| return s; | 17 | if (artifact.install_step) |s| return s; |
| 18 | 18 | ||
| 19 | const self = builder.allocator.create(InstallArtifactStep) catch unreachable; | 19 | const self = builder.allocator.create(InstallArtifactStep) catch @panic("OOM"); |
| 20 | self.* = InstallArtifactStep{ | 20 | self.* = InstallArtifactStep{ |
| 21 | .builder = builder, | 21 | .builder = builder, |
| 22 | .step = Step.init(.install_artifact, builder.fmt("install {s}", .{artifact.step.name}), builder.allocator, make), | 22 | .step = Step.init(.install_artifact, builder.fmt("install {s}", .{artifact.step.name}), builder.allocator, make), |
lib/std/Build/InstallRawStep.zig+2-2| ... | @@ -44,7 +44,7 @@ pub fn create( | ... | @@ -44,7 +44,7 @@ pub fn create( |
| 44 | dest_filename: []const u8, | 44 | dest_filename: []const u8, |
| 45 | options: CreateOptions, | 45 | options: CreateOptions, |
| 46 | ) *InstallRawStep { | 46 | ) *InstallRawStep { |
| 47 | const self = builder.allocator.create(InstallRawStep) catch unreachable; | 47 | const self = builder.allocator.create(InstallRawStep) catch @panic("OOM"); |
| 48 | self.* = InstallRawStep{ | 48 | self.* = InstallRawStep{ |
| 49 | .step = Step.init(.install_raw, builder.fmt("install raw binary {s}", .{artifact.step.name}), builder.allocator, make), | 49 | .step = Step.init(.install_raw, builder.fmt("install raw binary {s}", .{artifact.step.name}), builder.allocator, make), |
| 50 | .builder = builder, | 50 | .builder = builder, |
| ... | @@ -82,7 +82,7 @@ fn make(step: *Step) !void { | ... | @@ -82,7 +82,7 @@ fn make(step: *Step) !void { |
| 82 | const full_dest_path = b.getInstallPath(self.dest_dir, self.dest_filename); | 82 | const full_dest_path = b.getInstallPath(self.dest_dir, self.dest_filename); |
| 83 | self.output_file.path = full_dest_path; | 83 | self.output_file.path = full_dest_path; |
| 84 | 84 | ||
| 85 | fs.cwd().makePath(b.getInstallPath(self.dest_dir, "")) catch unreachable; | 85 | try fs.cwd().makePath(b.getInstallPath(self.dest_dir, "")); |
| 86 | 86 | ||
| 87 | var argv_list = std.ArrayList([]const u8).init(b.allocator); | 87 | var argv_list = std.ArrayList([]const u8).init(b.allocator); |
| 88 | try argv_list.appendSlice(&.{ b.zig_exe, "objcopy" }); | 88 | try argv_list.appendSlice(&.{ b.zig_exe, "objcopy" }); |
lib/std/Build/OptionsStep.zig+33-29| ... | @@ -19,7 +19,7 @@ artifact_args: std.ArrayList(OptionArtifactArg), | ... | @@ -19,7 +19,7 @@ artifact_args: std.ArrayList(OptionArtifactArg), |
| 19 | file_source_args: std.ArrayList(OptionFileSourceArg), | 19 | file_source_args: std.ArrayList(OptionFileSourceArg), |
| 20 | 20 | ||
| 21 | pub fn create(builder: *std.Build) *OptionsStep { | 21 | pub fn create(builder: *std.Build) *OptionsStep { |
| 22 | const self = builder.allocator.create(OptionsStep) catch unreachable; | 22 | const self = builder.allocator.create(OptionsStep) catch @panic("OOM"); |
| 23 | self.* = .{ | 23 | self.* = .{ |
| 24 | .builder = builder, | 24 | .builder = builder, |
| 25 | .step = Step.init(.options, "options", builder.allocator, make), | 25 | .step = Step.init(.options, "options", builder.allocator, make), |
| ... | @@ -34,44 +34,48 @@ pub fn create(builder: *std.Build) *OptionsStep { | ... | @@ -34,44 +34,48 @@ pub fn create(builder: *std.Build) *OptionsStep { |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: T) void { | 36 | pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: T) void { |
| 37 | return addOptionFallible(self, T, name, value) catch @panic("unhandled error"); | ||
| 38 | } | ||
| 39 | |||
| 40 | fn addOptionFallible(self: *OptionsStep, comptime T: type, name: []const u8, value: T) !void { | ||
| 37 | const out = self.contents.writer(); | 41 | const out = self.contents.writer(); |
| 38 | switch (T) { | 42 | switch (T) { |
| 39 | []const []const u8 => { | 43 | []const []const u8 => { |
| 40 | out.print("pub const {}: []const []const u8 = &[_][]const u8{{\n", .{std.zig.fmtId(name)}) catch unreachable; | 44 | try out.print("pub const {}: []const []const u8 = &[_][]const u8{{\n", .{std.zig.fmtId(name)}); |
| 41 | for (value) |slice| { | 45 | for (value) |slice| { |
| 42 | out.print(" \"{}\",\n", .{std.zig.fmtEscapes(slice)}) catch unreachable; | 46 | try out.print(" \"{}\",\n", .{std.zig.fmtEscapes(slice)}); |
| 43 | } | 47 | } |
| 44 | out.writeAll("};\n") catch unreachable; | 48 | try out.writeAll("};\n"); |
| 45 | return; | 49 | return; |
| 46 | }, | 50 | }, |
| 47 | [:0]const u8 => { | 51 | [:0]const u8 => { |
| 48 | out.print("pub const {}: [:0]const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }) catch unreachable; | 52 | try out.print("pub const {}: [:0]const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }); |
| 49 | return; | 53 | return; |
| 50 | }, | 54 | }, |
| 51 | []const u8 => { | 55 | []const u8 => { |
| 52 | out.print("pub const {}: []const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }) catch unreachable; | 56 | try out.print("pub const {}: []const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }); |
| 53 | return; | 57 | return; |
| 54 | }, | 58 | }, |
| 55 | ?[:0]const u8 => { | 59 | ?[:0]const u8 => { |
| 56 | out.print("pub const {}: ?[:0]const u8 = ", .{std.zig.fmtId(name)}) catch unreachable; | 60 | try out.print("pub const {}: ?[:0]const u8 = ", .{std.zig.fmtId(name)}); |
| 57 | if (value) |payload| { | 61 | if (value) |payload| { |
| 58 | out.print("\"{}\";\n", .{std.zig.fmtEscapes(payload)}) catch unreachable; | 62 | try out.print("\"{}\";\n", .{std.zig.fmtEscapes(payload)}); |
| 59 | } else { | 63 | } else { |
| 60 | out.writeAll("null;\n") catch unreachable; | 64 | try out.writeAll("null;\n"); |
| 61 | } | 65 | } |
| 62 | return; | 66 | return; |
| 63 | }, | 67 | }, |
| 64 | ?[]const u8 => { | 68 | ?[]const u8 => { |
| 65 | out.print("pub const {}: ?[]const u8 = ", .{std.zig.fmtId(name)}) catch unreachable; | 69 | try out.print("pub const {}: ?[]const u8 = ", .{std.zig.fmtId(name)}); |
| 66 | if (value) |payload| { | 70 | if (value) |payload| { |
| 67 | out.print("\"{}\";\n", .{std.zig.fmtEscapes(payload)}) catch unreachable; | 71 | try out.print("\"{}\";\n", .{std.zig.fmtEscapes(payload)}); |
| 68 | } else { | 72 | } else { |
| 69 | out.writeAll("null;\n") catch unreachable; | 73 | try out.writeAll("null;\n"); |
| 70 | } | 74 | } |
| 71 | return; | 75 | return; |
| 72 | }, | 76 | }, |
| 73 | std.builtin.Version => { | 77 | std.builtin.Version => { |
| 74 | out.print( | 78 | try out.print( |
| 75 | \\pub const {}: @import("std").builtin.Version = .{{ | 79 | \\pub const {}: @import("std").builtin.Version = .{{ |
| 76 | \\ .major = {d}, | 80 | \\ .major = {d}, |
| 77 | \\ .minor = {d}, | 81 | \\ .minor = {d}, |
| ... | @@ -84,11 +88,11 @@ pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: | ... | @@ -84,11 +88,11 @@ pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: |
| 84 | value.major, | 88 | value.major, |
| 85 | value.minor, | 89 | value.minor, |
| 86 | value.patch, | 90 | value.patch, |
| 87 | }) catch unreachable; | 91 | }); |
| 88 | return; | 92 | return; |
| 89 | }, | 93 | }, |
| 90 | std.SemanticVersion => { | 94 | std.SemanticVersion => { |
| 91 | out.print( | 95 | try out.print( |
| 92 | \\pub const {}: @import("std").SemanticVersion = .{{ | 96 | \\pub const {}: @import("std").SemanticVersion = .{{ |
| 93 | \\ .major = {d}, | 97 | \\ .major = {d}, |
| 94 | \\ .minor = {d}, | 98 | \\ .minor = {d}, |
| ... | @@ -100,38 +104,38 @@ pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: | ... | @@ -100,38 +104,38 @@ pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: |
| 100 | value.major, | 104 | value.major, |
| 101 | value.minor, | 105 | value.minor, |
| 102 | value.patch, | 106 | value.patch, |
| 103 | }) catch unreachable; | 107 | }); |
| 104 | if (value.pre) |some| { | 108 | if (value.pre) |some| { |
| 105 | out.print(" .pre = \"{}\",\n", .{std.zig.fmtEscapes(some)}) catch unreachable; | 109 | try out.print(" .pre = \"{}\",\n", .{std.zig.fmtEscapes(some)}); |
| 106 | } | 110 | } |
| 107 | if (value.build) |some| { | 111 | if (value.build) |some| { |
| 108 | out.print(" .build = \"{}\",\n", .{std.zig.fmtEscapes(some)}) catch unreachable; | 112 | try out.print(" .build = \"{}\",\n", .{std.zig.fmtEscapes(some)}); |
| 109 | } | 113 | } |
| 110 | out.writeAll("};\n") catch unreachable; | 114 | try out.writeAll("};\n"); |
| 111 | return; | 115 | return; |
| 112 | }, | 116 | }, |
| 113 | else => {}, | 117 | else => {}, |
| 114 | } | 118 | } |
| 115 | switch (@typeInfo(T)) { | 119 | switch (@typeInfo(T)) { |
| 116 | .Enum => |enum_info| { | 120 | .Enum => |enum_info| { |
| 117 | out.print("pub const {} = enum {{\n", .{std.zig.fmtId(@typeName(T))}) catch unreachable; | 121 | try out.print("pub const {} = enum {{\n", .{std.zig.fmtId(@typeName(T))}); |
| 118 | inline for (enum_info.fields) |field| { | 122 | inline for (enum_info.fields) |field| { |
| 119 | out.print(" {},\n", .{std.zig.fmtId(field.name)}) catch unreachable; | 123 | try out.print(" {},\n", .{std.zig.fmtId(field.name)}); |
| 120 | } | 124 | } |
| 121 | out.writeAll("};\n") catch unreachable; | 125 | try out.writeAll("};\n"); |
| 122 | out.print("pub const {}: {s} = {s}.{s};\n", .{ | 126 | try out.print("pub const {}: {s} = {s}.{s};\n", .{ |
| 123 | std.zig.fmtId(name), | 127 | std.zig.fmtId(name), |
| 124 | std.zig.fmtId(@typeName(T)), | 128 | std.zig.fmtId(@typeName(T)), |
| 125 | std.zig.fmtId(@typeName(T)), | 129 | std.zig.fmtId(@typeName(T)), |
| 126 | std.zig.fmtId(@tagName(value)), | 130 | std.zig.fmtId(@tagName(value)), |
| 127 | }) catch unreachable; | 131 | }); |
| 128 | return; | 132 | return; |
| 129 | }, | 133 | }, |
| 130 | else => {}, | 134 | else => {}, |
| 131 | } | 135 | } |
| 132 | out.print("pub const {}: {s} = ", .{ std.zig.fmtId(name), @typeName(T) }) catch unreachable; | 136 | try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(name), @typeName(T) }); |
| 133 | printLiteral(out, value, 0) catch unreachable; | 137 | try printLiteral(out, value, 0); |
| 134 | out.writeAll(";\n") catch unreachable; | 138 | try out.writeAll(";\n"); |
| 135 | } | 139 | } |
| 136 | 140 | ||
| 137 | // TODO: non-recursive? | 141 | // TODO: non-recursive? |
| ... | @@ -189,14 +193,14 @@ pub fn addOptionFileSource( | ... | @@ -189,14 +193,14 @@ pub fn addOptionFileSource( |
| 189 | self.file_source_args.append(.{ | 193 | self.file_source_args.append(.{ |
| 190 | .name = name, | 194 | .name = name, |
| 191 | .source = source.dupe(self.builder), | 195 | .source = source.dupe(self.builder), |
| 192 | }) catch unreachable; | 196 | }) catch @panic("OOM"); |
| 193 | source.addStepDependencies(&self.step); | 197 | source.addStepDependencies(&self.step); |
| 194 | } | 198 | } |
| 195 | 199 | ||
| 196 | /// The value is the path in the cache dir. | 200 | /// The value is the path in the cache dir. |
| 197 | /// Adds a dependency automatically. | 201 | /// Adds a dependency automatically. |
| 198 | pub fn addOptionArtifact(self: *OptionsStep, name: []const u8, artifact: *CompileStep) void { | 202 | pub fn addOptionArtifact(self: *OptionsStep, name: []const u8, artifact: *CompileStep) void { |
| 199 | self.artifact_args.append(.{ .name = self.builder.dupe(name), .artifact = artifact }) catch unreachable; | 203 | self.artifact_args.append(.{ .name = self.builder.dupe(name), .artifact = artifact }) catch @panic("OOM"); |
| 200 | self.step.dependOn(&artifact.step); | 204 | self.step.dependOn(&artifact.step); |
| 201 | } | 205 | } |
| 202 | 206 |
lib/std/Build/RunStep.zig+12-12| ... | @@ -54,7 +54,7 @@ pub const Arg = union(enum) { | ... | @@ -54,7 +54,7 @@ pub const Arg = union(enum) { |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | pub fn create(builder: *std.Build, name: []const u8) *RunStep { | 56 | pub fn create(builder: *std.Build, name: []const u8) *RunStep { |
| 57 | const self = builder.allocator.create(RunStep) catch unreachable; | 57 | const self = builder.allocator.create(RunStep) catch @panic("OOM"); |
| 58 | self.* = RunStep{ | 58 | self.* = RunStep{ |
| 59 | .builder = builder, | 59 | .builder = builder, |
| 60 | .step = Step.init(base_id, name, builder.allocator, make), | 60 | .step = Step.init(base_id, name, builder.allocator, make), |
| ... | @@ -67,19 +67,19 @@ pub fn create(builder: *std.Build, name: []const u8) *RunStep { | ... | @@ -67,19 +67,19 @@ pub fn create(builder: *std.Build, name: []const u8) *RunStep { |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void { | 69 | pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void { |
| 70 | self.argv.append(Arg{ .artifact = artifact }) catch unreachable; | 70 | self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM"); |
| 71 | self.step.dependOn(&artifact.step); | 71 | self.step.dependOn(&artifact.step); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | pub fn addFileSourceArg(self: *RunStep, file_source: std.Build.FileSource) void { | 74 | pub fn addFileSourceArg(self: *RunStep, file_source: std.Build.FileSource) void { |
| 75 | self.argv.append(Arg{ | 75 | self.argv.append(Arg{ |
| 76 | .file_source = file_source.dupe(self.builder), | 76 | .file_source = file_source.dupe(self.builder), |
| 77 | }) catch unreachable; | 77 | }) catch @panic("OOM"); |
| 78 | file_source.addStepDependencies(&self.step); | 78 | file_source.addStepDependencies(&self.step); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | pub fn addArg(self: *RunStep, arg: []const u8) void { | 81 | pub fn addArg(self: *RunStep, arg: []const u8) void { |
| 82 | self.argv.append(Arg{ .bytes = self.builder.dupe(arg) }) catch unreachable; | 82 | self.argv.append(Arg{ .bytes = self.builder.dupe(arg) }) catch @panic("OOM"); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | pub fn addArgs(self: *RunStep, args: []const []const u8) void { | 85 | pub fn addArgs(self: *RunStep, args: []const []const u8) void { |
| ... | @@ -89,7 +89,7 @@ pub fn addArgs(self: *RunStep, args: []const []const u8) void { | ... | @@ -89,7 +89,7 @@ pub fn addArgs(self: *RunStep, args: []const []const u8) void { |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | pub fn clearEnvironment(self: *RunStep) void { | 91 | pub fn clearEnvironment(self: *RunStep) void { |
| 92 | const new_env_map = self.builder.allocator.create(EnvMap) catch unreachable; | 92 | const new_env_map = self.builder.allocator.create(EnvMap) catch @panic("OOM"); |
| 93 | new_env_map.* = EnvMap.init(self.builder.allocator); | 93 | new_env_map.* = EnvMap.init(self.builder.allocator); |
| 94 | self.env_map = new_env_map; | 94 | self.env_map = new_env_map; |
| 95 | } | 95 | } |
| ... | @@ -107,9 +107,9 @@ pub fn addPathDirInternal(step: *Step, builder: *std.Build, search_path: []const | ... | @@ -107,9 +107,9 @@ pub fn addPathDirInternal(step: *Step, builder: *std.Build, search_path: []const |
| 107 | 107 | ||
| 108 | if (prev_path) |pp| { | 108 | if (prev_path) |pp| { |
| 109 | const new_path = builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path }); | 109 | const new_path = builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path }); |
| 110 | env_map.put(key, new_path) catch unreachable; | 110 | env_map.put(key, new_path) catch @panic("OOM"); |
| 111 | } else { | 111 | } else { |
| 112 | env_map.put(key, builder.dupePath(search_path)) catch unreachable; | 112 | env_map.put(key, builder.dupePath(search_path)) catch @panic("OOM"); |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | 115 | ||
| ... | @@ -124,8 +124,8 @@ fn getEnvMapInternal(step: *Step, allocator: Allocator) *EnvMap { | ... | @@ -124,8 +124,8 @@ fn getEnvMapInternal(step: *Step, allocator: Allocator) *EnvMap { |
| 124 | else => unreachable, | 124 | else => unreachable, |
| 125 | }; | 125 | }; |
| 126 | return maybe_env_map orelse { | 126 | return maybe_env_map orelse { |
| 127 | const env_map = allocator.create(EnvMap) catch unreachable; | 127 | const env_map = allocator.create(EnvMap) catch @panic("OOM"); |
| 128 | env_map.* = process.getEnvMap(allocator) catch unreachable; | 128 | env_map.* = process.getEnvMap(allocator) catch @panic("unhandled error"); |
| 129 | switch (step.id) { | 129 | switch (step.id) { |
| 130 | .run => step.cast(RunStep).?.env_map = env_map, | 130 | .run => step.cast(RunStep).?.env_map = env_map, |
| 131 | .emulatable_run => step.cast(RunStep).?.env_map = env_map, | 131 | .emulatable_run => step.cast(RunStep).?.env_map = env_map, |
| ... | @@ -140,7 +140,7 @@ pub fn setEnvironmentVariable(self: *RunStep, key: []const u8, value: []const u8 | ... | @@ -140,7 +140,7 @@ pub fn setEnvironmentVariable(self: *RunStep, key: []const u8, value: []const u8 |
| 140 | env_map.put( | 140 | env_map.put( |
| 141 | self.builder.dupe(key), | 141 | self.builder.dupe(key), |
| 142 | self.builder.dupe(value), | 142 | self.builder.dupe(value), |
| 143 | ) catch unreachable; | 143 | ) catch @panic("unhandled error"); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | pub fn expectStdErrEqual(self: *RunStep, bytes: []const u8) void { | 146 | pub fn expectStdErrEqual(self: *RunStep, bytes: []const u8) void { |
| ... | @@ -234,7 +234,7 @@ pub fn runCommand( | ... | @@ -234,7 +234,7 @@ pub fn runCommand( |
| 234 | 234 | ||
| 235 | switch (stdout_action) { | 235 | switch (stdout_action) { |
| 236 | .expect_exact, .expect_matches => { | 236 | .expect_exact, .expect_matches => { |
| 237 | stdout = child.stdout.?.reader().readAllAlloc(builder.allocator, max_stdout_size) catch unreachable; | 237 | stdout = try child.stdout.?.reader().readAllAlloc(builder.allocator, max_stdout_size); |
| 238 | }, | 238 | }, |
| 239 | .inherit, .ignore => {}, | 239 | .inherit, .ignore => {}, |
| 240 | } | 240 | } |
| ... | @@ -244,7 +244,7 @@ pub fn runCommand( | ... | @@ -244,7 +244,7 @@ pub fn runCommand( |
| 244 | 244 | ||
| 245 | switch (stderr_action) { | 245 | switch (stderr_action) { |
| 246 | .expect_exact, .expect_matches => { | 246 | .expect_exact, .expect_matches => { |
| 247 | stderr = child.stderr.?.reader().readAllAlloc(builder.allocator, max_stdout_size) catch unreachable; | 247 | stderr = try child.stderr.?.reader().readAllAlloc(builder.allocator, max_stdout_size); |
| 248 | }, | 248 | }, |
| 249 | .inherit, .ignore => {}, | 249 | .inherit, .ignore => {}, |
| 250 | } | 250 | } |
lib/std/Build/Step.zig+2-2| ... | @@ -57,7 +57,7 @@ pub fn init( | ... | @@ -57,7 +57,7 @@ pub fn init( |
| 57 | ) Step { | 57 | ) Step { |
| 58 | return Step{ | 58 | return Step{ |
| 59 | .id = id, | 59 | .id = id, |
| 60 | .name = allocator.dupe(u8, name) catch unreachable, | 60 | .name = allocator.dupe(u8, name) catch @panic("OOM"), |
| 61 | .makeFn = makeFn, | 61 | .makeFn = makeFn, |
| 62 | .dependencies = std.ArrayList(*Step).init(allocator), | 62 | .dependencies = std.ArrayList(*Step).init(allocator), |
| 63 | .loop_flag = false, | 63 | .loop_flag = false, |
| ... | @@ -77,7 +77,7 @@ pub fn make(self: *Step) !void { | ... | @@ -77,7 +77,7 @@ pub fn make(self: *Step) !void { |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | pub fn dependOn(self: *Step, other: *Step) void { | 79 | pub fn dependOn(self: *Step, other: *Step) void { |
| 80 | self.dependencies.append(other) catch unreachable; | 80 | self.dependencies.append(other) catch @panic("OOM"); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | fn makeNoOp(self: *Step) anyerror!void { | 83 | fn makeNoOp(self: *Step) anyerror!void { |
lib/std/Build/TranslateCStep.zig+6-6| ... | @@ -28,7 +28,7 @@ pub const Options = struct { | ... | @@ -28,7 +28,7 @@ pub const Options = struct { |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | pub fn create(builder: *std.Build, options: Options) *TranslateCStep { | 30 | pub fn create(builder: *std.Build, options: Options) *TranslateCStep { |
| 31 | const self = builder.allocator.create(TranslateCStep) catch unreachable; | 31 | const self = builder.allocator.create(TranslateCStep) catch @panic("OOM"); |
| 32 | const source = options.source_file.dupe(builder); | 32 | const source = options.source_file.dupe(builder); |
| 33 | self.* = TranslateCStep{ | 33 | self.* = TranslateCStep{ |
| 34 | .step = Step.init(.translate_c, "translate-c", builder.allocator, make), | 34 | .step = Step.init(.translate_c, "translate-c", builder.allocator, make), |
| ... | @@ -67,7 +67,7 @@ pub fn addExecutable(self: *TranslateCStep, options: AddExecutableOptions) *Comp | ... | @@ -67,7 +67,7 @@ pub fn addExecutable(self: *TranslateCStep, options: AddExecutableOptions) *Comp |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | pub fn addIncludeDir(self: *TranslateCStep, include_dir: []const u8) void { | 69 | pub fn addIncludeDir(self: *TranslateCStep, include_dir: []const u8) void { |
| 70 | self.include_dirs.append(self.builder.dupePath(include_dir)) catch unreachable; | 70 | self.include_dirs.append(self.builder.dupePath(include_dir)) catch @panic("OOM"); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) *CheckFileStep { | 73 | pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) *CheckFileStep { |
| ... | @@ -78,12 +78,12 @@ pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) | ... | @@ -78,12 +78,12 @@ pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) |
| 78 | /// `name` and `value` need not live longer than the function call. | 78 | /// `name` and `value` need not live longer than the function call. |
| 79 | pub fn defineCMacro(self: *TranslateCStep, name: []const u8, value: ?[]const u8) void { | 79 | pub fn defineCMacro(self: *TranslateCStep, name: []const u8, value: ?[]const u8) void { |
| 80 | const macro = std.Build.constructCMacro(self.builder.allocator, name, value); | 80 | const macro = std.Build.constructCMacro(self.builder.allocator, name, value); |
| 81 | self.c_macros.append(macro) catch unreachable; | 81 | self.c_macros.append(macro) catch @panic("OOM"); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | /// name_and_value looks like [name]=[value]. If the value is omitted, it is set to 1. | 84 | /// name_and_value looks like [name]=[value]. If the value is omitted, it is set to 1. |
| 85 | pub fn defineCMacroRaw(self: *TranslateCStep, name_and_value: []const u8) void { | 85 | pub fn defineCMacroRaw(self: *TranslateCStep, name_and_value: []const u8) void { |
| 86 | self.c_macros.append(self.builder.dupe(name_and_value)) catch unreachable; | 86 | self.c_macros.append(self.builder.dupe(name_and_value)) catch @panic("OOM"); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | fn make(step: *Step) !void { | 89 | fn make(step: *Step) !void { |
| ... | @@ -129,8 +129,8 @@ fn make(step: *Step) !void { | ... | @@ -129,8 +129,8 @@ fn make(step: *Step) !void { |
| 129 | self.output_dir = fs.path.dirname(output_path).?; | 129 | self.output_dir = fs.path.dirname(output_path).?; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | self.output_file.path = fs.path.join( | 132 | self.output_file.path = try fs.path.join( |
| 133 | self.builder.allocator, | 133 | self.builder.allocator, |
| 134 | &[_][]const u8{ self.output_dir.?, self.out_basename }, | 134 | &[_][]const u8{ self.output_dir.?, self.out_basename }, |
| 135 | ) catch unreachable; | 135 | ); |
| 136 | } | 136 | } |
lib/std/Build/WriteFileStep.zig+3-3| ... | @@ -28,7 +28,7 @@ pub fn init(builder: *std.Build) WriteFileStep { | ... | @@ -28,7 +28,7 @@ pub fn init(builder: *std.Build) WriteFileStep { |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | pub fn add(self: *WriteFileStep, basename: []const u8, bytes: []const u8) void { | 30 | pub fn add(self: *WriteFileStep, basename: []const u8, bytes: []const u8) void { |
| 31 | const node = self.builder.allocator.create(std.TailQueue(File).Node) catch unreachable; | 31 | const node = self.builder.allocator.create(std.TailQueue(File).Node) catch @panic("unhandled error"); |
| 32 | node.* = .{ | 32 | node.* = .{ |
| 33 | .data = .{ | 33 | .data = .{ |
| 34 | .source = std.Build.GeneratedFile{ .step = &self.step }, | 34 | .source = std.Build.GeneratedFile{ .step = &self.step }, |
| ... | @@ -106,10 +106,10 @@ fn make(step: *Step) !void { | ... | @@ -106,10 +106,10 @@ fn make(step: *Step) !void { |
| 106 | }); | 106 | }); |
| 107 | return err; | 107 | return err; |
| 108 | }; | 108 | }; |
| 109 | node.data.source.path = fs.path.join( | 109 | node.data.source.path = try fs.path.join( |
| 110 | self.builder.allocator, | 110 | self.builder.allocator, |
| 111 | &[_][]const u8{ self.output_dir, node.data.basename }, | 111 | &[_][]const u8{ self.output_dir, node.data.basename }, |
| 112 | ) catch unreachable; | 112 | ); |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | } | 115 | } |