build: simplify link() usage
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
2c77c16356
commit
9a96820926
1 changed files with 26 additions and 26 deletions
18
build.zig
18
build.zig
|
|
@ -270,7 +270,7 @@ pub fn build(b: *std.Build) !void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
example_exe.root_module.addImport("mach", module);
|
example_exe.root_module.addImport("mach", module);
|
||||||
link(b, example_exe, &example_exe.root_module);
|
link(b, example_exe);
|
||||||
|
|
||||||
if (b.lazyDependency("mach_glfw", .{
|
if (b.lazyDependency("mach_glfw", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|
@ -302,7 +302,7 @@ pub fn build(b: *std.Build) !void {
|
||||||
unit_tests.root_module.addImport(e.key_ptr.*, e.value_ptr.*);
|
unit_tests.root_module.addImport(e.key_ptr.*, e.value_ptr.*);
|
||||||
}
|
}
|
||||||
addPaths(&unit_tests.root_module);
|
addPaths(&unit_tests.root_module);
|
||||||
link(b, unit_tests, &unit_tests.root_module);
|
link(b, unit_tests);
|
||||||
|
|
||||||
// Linux gamemode requires libc.
|
// Linux gamemode requires libc.
|
||||||
if (target.result.os.tag == .linux) unit_tests.root_module.link_libc = true;
|
if (target.result.os.tag == .linux) unit_tests.root_module.link_libc = true;
|
||||||
|
|
@ -440,7 +440,7 @@ pub const CoreApp = struct {
|
||||||
|
|
||||||
// Link dependencies
|
// Link dependencies
|
||||||
if (platform != .web) {
|
if (platform != .web) {
|
||||||
link(mach_builder, compile, &compile.root_module);
|
link(mach_builder, compile);
|
||||||
}
|
}
|
||||||
|
|
||||||
const run = app_builder.addRunArtifact(compile);
|
const run = app_builder.addRunArtifact(compile);
|
||||||
|
|
@ -460,9 +460,10 @@ pub const CoreApp = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(sysgpu): remove this once we switch to sysgpu fully
|
// TODO(sysgpu): remove this once we switch to sysgpu fully
|
||||||
pub fn link(mach_builder: *std.Build, step: *std.Build.Step.Compile, mod: *std.Build.Module) void {
|
pub fn link(mach_builder: *std.Build, step: *std.Build.Step.Compile) void {
|
||||||
const target = mod.resolved_target.?.result;
|
const target = step.root_module.resolved_target.?.result;
|
||||||
if (target.cpu.arch != .wasm32) {
|
if (target.cpu.arch == .wasm32) return;
|
||||||
|
|
||||||
if (mach_builder.lazyDependency("mach_gpu_dawn", .{
|
if (mach_builder.lazyDependency("mach_gpu_dawn", .{
|
||||||
.target = step.root_module.resolved_target.?,
|
.target = step.root_module.resolved_target.?,
|
||||||
.optimize = step.root_module.optimize.?,
|
.optimize = step.root_module.optimize.?,
|
||||||
|
|
@ -477,14 +478,13 @@ pub fn link(mach_builder: *std.Build, step: *std.Build.Step.Compile, mod: *std.B
|
||||||
gpu_dawn.link(
|
gpu_dawn.link(
|
||||||
mach_builder,
|
mach_builder,
|
||||||
step,
|
step,
|
||||||
mod,
|
&step.root_module,
|
||||||
options.gpu_dawn_options,
|
options.gpu_dawn_options,
|
||||||
);
|
);
|
||||||
step.addCSourceFile(.{ .file = .{ .path = sdkPath("/src/gpu/mach_dawn.cpp") }, .flags = &.{"-std=c++17"} });
|
step.addCSourceFile(.{ .file = .{ .path = sdkPath("/src/gpu/mach_dawn.cpp") }, .flags = &.{"-std=c++17"} });
|
||||||
step.addIncludePath(.{ .path = sdkPath("/src/gpu") });
|
step.addIncludePath(.{ .path = sdkPath("/src/gpu") });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn linkSysgpu(b: *std.Build, module: *std.Build.Module) void {
|
fn linkSysgpu(b: *std.Build, module: *std.Build.Module) void {
|
||||||
const resolved_target = module.resolved_target orelse b.host;
|
const resolved_target = module.resolved_target orelse b.host;
|
||||||
|
|
@ -583,7 +583,7 @@ fn buildExamples(
|
||||||
});
|
});
|
||||||
exe.root_module.addImport("mach", mach_mod);
|
exe.root_module.addImport("mach", mach_mod);
|
||||||
addPaths(&exe.root_module);
|
addPaths(&exe.root_module);
|
||||||
link(b, exe, &exe.root_module);
|
link(b, exe);
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
for (example.deps) |d| {
|
for (example.deps) |d| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue