mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.Build: add more explicit error sets to some functions
Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
This commit is contained in:
parent
738d813619
commit
3179961854
1 changed files with 9 additions and 9 deletions
|
|
@ -250,7 +250,7 @@ pub fn create(
|
||||||
build_root: Cache.Directory,
|
build_root: Cache.Directory,
|
||||||
cache_root: Cache.Directory,
|
cache_root: Cache.Directory,
|
||||||
available_deps: AvailableDeps,
|
available_deps: AvailableDeps,
|
||||||
) !*Build {
|
) error{OutOfMemory}!*Build {
|
||||||
const arena = graph.arena;
|
const arena = graph.arena;
|
||||||
|
|
||||||
const b = try arena.create(Build);
|
const b = try arena.create(Build);
|
||||||
|
|
@ -318,7 +318,7 @@ fn createChild(
|
||||||
pkg_hash: []const u8,
|
pkg_hash: []const u8,
|
||||||
pkg_deps: AvailableDeps,
|
pkg_deps: AvailableDeps,
|
||||||
user_input_options: UserInputOptionsMap,
|
user_input_options: UserInputOptionsMap,
|
||||||
) !*Build {
|
) error{OutOfMemory}!*Build {
|
||||||
const child = try createChildOnly(parent, dep_name, build_root, pkg_hash, pkg_deps, user_input_options);
|
const child = try createChildOnly(parent, dep_name, build_root, pkg_hash, pkg_deps, user_input_options);
|
||||||
try determineAndApplyInstallPrefix(child);
|
try determineAndApplyInstallPrefix(child);
|
||||||
return child;
|
return child;
|
||||||
|
|
@ -331,7 +331,7 @@ fn createChildOnly(
|
||||||
pkg_hash: []const u8,
|
pkg_hash: []const u8,
|
||||||
pkg_deps: AvailableDeps,
|
pkg_deps: AvailableDeps,
|
||||||
user_input_options: UserInputOptionsMap,
|
user_input_options: UserInputOptionsMap,
|
||||||
) !*Build {
|
) error{OutOfMemory}!*Build {
|
||||||
const allocator = parent.allocator;
|
const allocator = parent.allocator;
|
||||||
const child = try allocator.create(Build);
|
const child = try allocator.create(Build);
|
||||||
child.* = .{
|
child.* = .{
|
||||||
|
|
@ -623,7 +623,7 @@ fn hashUserInputOptionsMap(allocator: Allocator, user_input_options: UserInputOp
|
||||||
user_option.hash(hasher);
|
user_option.hash(hasher);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn determineAndApplyInstallPrefix(b: *Build) !void {
|
fn determineAndApplyInstallPrefix(b: *Build) error{OutOfMemory}!void {
|
||||||
// Create an installation directory local to this package. This will be used when
|
// Create an installation directory local to this package. This will be used when
|
||||||
// dependant packages require a standard prefix, such as include directories for C headers.
|
// dependant packages require a standard prefix, such as include directories for C headers.
|
||||||
var hash = b.graph.cache.hash;
|
var hash = b.graph.cache.hash;
|
||||||
|
|
@ -1684,7 +1684,7 @@ pub fn standardTargetOptionsQueryOnly(b: *Build, args: StandardTargetOptionsArgs
|
||||||
return args.default_target;
|
return args.default_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addUserInputOption(b: *Build, name_raw: []const u8, value_raw: []const u8) !bool {
|
pub fn addUserInputOption(b: *Build, name_raw: []const u8, value_raw: []const u8) error{OutOfMemory}!bool {
|
||||||
const name = b.dupe(name_raw);
|
const name = b.dupe(name_raw);
|
||||||
const value = b.dupe(value_raw);
|
const value = b.dupe(value_raw);
|
||||||
const gop = try b.user_input_options.getOrPut(name);
|
const gop = try b.user_input_options.getOrPut(name);
|
||||||
|
|
@ -1736,7 +1736,7 @@ pub fn addUserInputOption(b: *Build, name_raw: []const u8, value_raw: []const u8
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addUserInputFlag(b: *Build, name_raw: []const u8) !bool {
|
pub fn addUserInputFlag(b: *Build, name_raw: []const u8) error{OutOfMemory}!bool {
|
||||||
const name = b.dupe(name_raw);
|
const name = b.dupe(name_raw);
|
||||||
const gop = try b.user_input_options.getOrPut(name);
|
const gop = try b.user_input_options.getOrPut(name);
|
||||||
if (!gop.found_existing) {
|
if (!gop.found_existing) {
|
||||||
|
|
@ -1808,7 +1808,7 @@ pub fn validateUserInputDidItFail(b: *Build) bool {
|
||||||
return b.invalid_user_input;
|
return b.invalid_user_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocPrintCmd(ally: Allocator, opt_cwd: ?[]const u8, argv: []const []const u8) ![]u8 {
|
fn allocPrintCmd(ally: Allocator, opt_cwd: ?[]const u8, argv: []const []const u8) error{OutOfMemory}![]u8 {
|
||||||
var buf = ArrayList(u8).init(ally);
|
var buf = ArrayList(u8).init(ally);
|
||||||
if (opt_cwd) |cwd| try buf.writer().print("cd {s} && ", .{cwd});
|
if (opt_cwd) |cwd| try buf.writer().print("cd {s} && ", .{cwd});
|
||||||
for (argv) |arg| {
|
for (argv) |arg| {
|
||||||
|
|
@ -1903,7 +1903,7 @@ pub fn addCheckFile(
|
||||||
return Step.CheckFile.create(b, file_source, options);
|
return Step.CheckFile.create(b, file_source, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn truncateFile(b: *Build, dest_path: []const u8) !void {
|
pub fn truncateFile(b: *Build, dest_path: []const u8) (fs.Dir.MakeError || fs.Dir.StatFileError)!void {
|
||||||
if (b.verbose) {
|
if (b.verbose) {
|
||||||
log.info("truncate {s}", .{dest_path});
|
log.info("truncate {s}", .{dest_path});
|
||||||
}
|
}
|
||||||
|
|
@ -1990,7 +1990,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn findProgram(b: *Build, names: []const []const u8, paths: []const []const u8) ![]const u8 {
|
pub fn findProgram(b: *Build, names: []const []const u8, paths: []const []const u8) error{FileNotFound}![]const u8 {
|
||||||
// TODO report error for ambiguous situations
|
// TODO report error for ambiguous situations
|
||||||
for (b.search_prefixes.items) |search_prefix| {
|
for (b.search_prefixes.items) |search_prefix| {
|
||||||
for (names) |name| {
|
for (names) |name| {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue