all: build: organize build files and reduce unreachables (#567)
This commit is contained in:
parent
cc301493ca
commit
fcb82345d4
10 changed files with 434 additions and 419 deletions
|
|
@ -4,7 +4,7 @@ const gpu_dawn_sdk = @import("libs/mach-gpu-dawn/sdk.zig");
|
|||
const gpu_sdk = @import("sdk.zig");
|
||||
const system_sdk = @import("libs/mach-glfw/system_sdk.zig");
|
||||
|
||||
pub fn build(b: *std.build.Builder) void {
|
||||
pub fn build(b: *std.build.Builder) !void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const gpu_dawn = gpu_dawn_sdk.Sdk(.{
|
||||
|
|
@ -23,14 +23,14 @@ pub fn build(b: *std.build.Builder) void {
|
|||
};
|
||||
|
||||
const test_step = b.step("test", "Run library tests");
|
||||
test_step.dependOn(&gpu.testStep(b, mode, target, .{ .gpu_dawn_options = gpu_dawn_options }).step);
|
||||
test_step.dependOn(&(try gpu.testStep(b, mode, target, .{ .gpu_dawn_options = gpu_dawn_options })).step);
|
||||
|
||||
const example = b.addExecutable("gpu-hello-triangle", "examples/main.zig");
|
||||
example.setBuildMode(mode);
|
||||
example.setTarget(target);
|
||||
example.addPackage(gpu.pkg);
|
||||
example.addPackage(glfw.pkg);
|
||||
gpu.link(b, example, .{ .gpu_dawn_options = gpu_dawn_options });
|
||||
try gpu.link(b, example, .{ .gpu_dawn_options = gpu_dawn_options });
|
||||
example.install();
|
||||
|
||||
const example_run_cmd = example.run();
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ const std = @import("std");
|
|||
|
||||
pub fn Sdk(comptime deps: anytype) type {
|
||||
return struct {
|
||||
pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget, options: Options) *std.build.RunStep {
|
||||
pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget, options: Options) !*std.build.RunStep {
|
||||
const main_tests = b.addTestExe("gpu-tests", (comptime thisDir()) ++ "/src/main.zig");
|
||||
main_tests.setBuildMode(mode);
|
||||
main_tests.setTarget(target);
|
||||
link(b, main_tests, options);
|
||||
try link(b, main_tests, options);
|
||||
main_tests.install();
|
||||
return main_tests.run();
|
||||
}
|
||||
|
|
@ -22,10 +22,10 @@ pub fn Sdk(comptime deps: anytype) type {
|
|||
.dependencies = &.{deps.glfw.pkg},
|
||||
};
|
||||
|
||||
pub fn link(b: *std.build.Builder, step: *std.build.LibExeObjStep, options: Options) void {
|
||||
pub fn link(b: *std.build.Builder, step: *std.build.LibExeObjStep, options: Options) !void {
|
||||
if (step.target.toTarget().cpu.arch != .wasm32) {
|
||||
deps.glfw.link(b, step, options.glfw_options);
|
||||
deps.gpu_dawn.link(b, step, options.gpu_dawn_options);
|
||||
try deps.glfw.link(b, step, options.glfw_options);
|
||||
try deps.gpu_dawn.link(b, step, options.gpu_dawn_options);
|
||||
step.addCSourceFile((comptime thisDir()) ++ "/src/mach_dawn.cpp", &.{"-std=c++17"});
|
||||
step.addIncludePath((comptime thisDir()) ++ "/src");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue