{mach,core}: use inferred error sets during build

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-07-03 08:54:42 -07:00
parent 7a03a73ee0
commit 906cdc19a1
2 changed files with 4 additions and 10 deletions

View file

@ -149,9 +149,6 @@ pub const App = struct {
core: core.App, core: core.App,
use_freetype: ?[]const u8 = null, use_freetype: ?[]const u8 = null,
pub const InitError = core.App.InitError;
pub const LinkError = core.App.LinkError;
pub fn init( pub fn init(
b: *std.Build, b: *std.Build,
options: struct { options: struct {
@ -167,7 +164,7 @@ pub const App = struct {
// TODO(build-system): name is currently not used / always "freetype" // TODO(build-system): name is currently not used / always "freetype"
use_freetype: ?[]const u8 = null, use_freetype: ?[]const u8 = null,
}, },
) InitError!App { ) !App {
var deps = std.ArrayList(std.build.ModuleDependency).init(b.allocator); var deps = std.ArrayList(std.build.ModuleDependency).init(b.allocator);
if (options.deps) |v| try deps.appendSlice(v); if (options.deps) |v| try deps.appendSlice(v);
try deps.append(.{ .name = "mach", .module = module(b, options.optimize, options.target) }); try deps.append(.{ .name = "mach", .module = module(b, options.optimize, options.target) });
@ -193,7 +190,7 @@ pub const App = struct {
}; };
} }
pub fn link(app: *const App, options: Options) LinkError!void { pub fn link(app: *const App, options: Options) !void {
try app.core.link(options.core); try app.core.link(options.core);
sysaudio.link(app.b, app.step, options.sysaudio); sysaudio.link(app.b, app.step, options.sysaudio);
if (app.use_freetype) |_| freetype.link(app.b, app.step, options.freetype); if (app.use_freetype) |_| freetype.link(app.b, app.step, options.freetype);

View file

@ -91,9 +91,6 @@ pub fn Sdk(comptime deps: anytype) type {
const web_install_dir = std.build.InstallDir{ .custom = "www" }; const web_install_dir = std.build.InstallDir{ .custom = "www" };
pub const InitError = error{OutOfMemory} || std.zig.system.NativeTargetInfo.DetectError;
pub const LinkError = deps.glfw.LinkError;
pub const Platform = enum { pub const Platform = enum {
native, native,
web, web,
@ -115,7 +112,7 @@ pub fn Sdk(comptime deps: anytype) type {
res_dirs: ?[]const []const u8 = null, res_dirs: ?[]const []const u8 = null,
watch_paths: ?[]const []const u8 = null, watch_paths: ?[]const []const u8 = null,
}, },
) InitError!App { ) !App {
const target = (try std.zig.system.NativeTargetInfo.detect(options.target)).target; const target = (try std.zig.system.NativeTargetInfo.detect(options.target)).target;
const platform = Platform.fromTarget(target); const platform = Platform.fromTarget(target);
@ -179,7 +176,7 @@ pub fn Sdk(comptime deps: anytype) type {
}; };
} }
pub fn link(app: *const App, options: Options) LinkError!void { pub fn link(app: *const App, options: Options) !void {
if (app.platform != .web) { if (app.platform != .web) {
try deps.glfw.link(app.b, app.step, options.glfw_options); try deps.glfw.link(app.b, app.step, options.glfw_options);
deps.gpu.link(app.b, app.step, options.gpuOptions()) catch return error.FailedToLinkGPU; deps.gpu.link(app.b, app.step, options.gpuOptions()) catch return error.FailedToLinkGPU;