std.Build: avoid use of catch unreachable

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.
This commit is contained in:
Andrew Kelley
2023-01-31 14:02:32 -07:00
parent 13a9616540
commit 90e48d4b34
13 changed files with 169 additions and 161 deletions

View File

@@ -44,7 +44,7 @@ pub fn create(
dest_filename: []const u8,
options: CreateOptions,
) *InstallRawStep {
const self = builder.allocator.create(InstallRawStep) catch unreachable;
const self = builder.allocator.create(InstallRawStep) catch @panic("OOM");
self.* = InstallRawStep{
.step = Step.init(.install_raw, builder.fmt("install raw binary {s}", .{artifact.step.name}), builder.allocator, make),
.builder = builder,
@@ -82,7 +82,7 @@ fn make(step: *Step) !void {
const full_dest_path = b.getInstallPath(self.dest_dir, self.dest_filename);
self.output_file.path = full_dest_path;
fs.cwd().makePath(b.getInstallPath(self.dest_dir, "")) catch unreachable;
try fs.cwd().makePath(b.getInstallPath(self.dest_dir, ""));
var argv_list = std.ArrayList([]const u8).init(b.allocator);
try argv_list.appendSlice(&.{ b.zig_exe, "objcopy" });