webgpu: build dawn-utils into a library
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
9793bb7de0
commit
b2ad2f4f21
1 changed files with 17 additions and 9 deletions
|
|
@ -42,6 +42,9 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
|
||||||
const lib_dawn_wire = buildLibDawnWire(b, step);
|
const lib_dawn_wire = buildLibDawnWire(b, step);
|
||||||
step.linkLibrary(lib_dawn_wire);
|
step.linkLibrary(lib_dawn_wire);
|
||||||
|
|
||||||
|
const lib_dawn_utils = buildLibDawnUtils(b, step, options);
|
||||||
|
step.linkLibrary(lib_dawn_utils);
|
||||||
|
|
||||||
const lib = buildLibDawn(b, step, options);
|
const lib = buildLibDawn(b, step, options);
|
||||||
step.linkLibrary(lib);
|
step.linkLibrary(lib);
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +57,6 @@ fn buildLibDawn(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *
|
||||||
lib.linkLibCpp();
|
lib.linkLibCpp();
|
||||||
|
|
||||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||||
addDawnUtilsSources(b, lib, options, target);
|
|
||||||
addThirdPartyTintSources(b, lib, options, target);
|
addThirdPartyTintSources(b, lib, options, target);
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
@ -1264,11 +1266,15 @@ fn buildLibDawnWire(b: *Builder, step: *std.build.LibExeObjStep) *std.build.LibE
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds dawn utils sources; derived from src/utils/BUILD.gn
|
// Builds dawn utils sources; derived from src/utils/BUILD.gn
|
||||||
fn addDawnUtilsSources(b: *Builder, step: *std.build.LibExeObjStep, options: Options, target: std.Target) void {
|
fn buildLibDawnUtils(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||||
_ = options;
|
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||||
_ = target;
|
const lib = b.addStaticLibrary("dawn-utils", main_abs);
|
||||||
glfw.link(b, step, .{ .system_sdk = .{ .set_sysroot = false } });
|
lib.setBuildMode(step.build_mode);
|
||||||
|
lib.setTarget(step.target);
|
||||||
|
lib.linkLibCpp();
|
||||||
|
|
||||||
|
glfw.link(b, lib, .{ .system_sdk = .{ .set_sysroot = false } });
|
||||||
const flags = &.{
|
const flags = &.{
|
||||||
"-DDAWN_ENABLE_BACKEND_METAL",
|
"-DDAWN_ENABLE_BACKEND_METAL",
|
||||||
//"-DDAWN_ENABLE_BACKEND_NULL",
|
//"-DDAWN_ENABLE_BACKEND_NULL",
|
||||||
|
|
@ -1283,9 +1289,10 @@ fn addDawnUtilsSources(b: *Builder, step: *std.build.LibExeObjStep, options: Opt
|
||||||
"src/utils/NullBinding.cpp",
|
"src/utils/NullBinding.cpp",
|
||||||
}) |path| {
|
}) |path| {
|
||||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||||
step.addCSourceFile(abs_path, flags);
|
lib.addCSourceFile(abs_path, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||||
switch (target.os.tag) {
|
switch (target.os.tag) {
|
||||||
.windows => {
|
.windows => {
|
||||||
if (options.d3d12) {
|
if (options.d3d12) {
|
||||||
|
|
@ -1293,7 +1300,7 @@ fn addDawnUtilsSources(b: *Builder, step: *std.build.LibExeObjStep, options: Opt
|
||||||
"src/utils/D3D12Binding.cpp",
|
"src/utils/D3D12Binding.cpp",
|
||||||
}) |path| {
|
}) |path| {
|
||||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||||
step.addCSourceFile(abs_path, flags);
|
lib.addCSourceFile(abs_path, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -1303,7 +1310,7 @@ fn addDawnUtilsSources(b: *Builder, step: *std.build.LibExeObjStep, options: Opt
|
||||||
"src/utils/MetalBinding.mm",
|
"src/utils/MetalBinding.mm",
|
||||||
}) |path| {
|
}) |path| {
|
||||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||||
step.addCSourceFile(abs_path, flags);
|
lib.addCSourceFile(abs_path, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -1319,6 +1326,7 @@ fn addDawnUtilsSources(b: *Builder, step: *std.build.LibExeObjStep, options: Opt
|
||||||
// if (dawn_enable_vulkan) {
|
// if (dawn_enable_vulkan) {
|
||||||
// sources += [ "VulkanBinding.cpp" ]
|
// sources += [ "VulkanBinding.cpp" ]
|
||||||
// }
|
// }
|
||||||
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn include(comptime rel: []const u8) []const u8 {
|
fn include(comptime rel: []const u8) []const u8 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue