gpu-dawn: use direct3d-headers via package manager

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-07-03 06:27:52 -07:00
parent 2f3c58faf9
commit 65adec7453
4 changed files with 43 additions and 13 deletions

View file

@ -63,7 +63,8 @@ pub fn Sdk(comptime deps: anytype) type {
const opt = options.detectDefaults(step.target_info.target);
// TODO(build-system): pass system SDK options through
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag == .windows) @import("direct3d_headers").addLibraryPath(step);
try if (options.from_source)
linkFromSource(b, step, opt)
@ -543,7 +544,7 @@ pub fn Sdk(comptime deps: anytype) type {
fn linkLibDawnCommonDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options;
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag == .macos) {
step.linkSystemLibraryName("objc");
step.linkFramework("Foundation");
@ -601,7 +602,7 @@ pub fn Sdk(comptime deps: anytype) type {
fn linkLibDawnPlatformDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options;
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
}
// Build dawn platform sources; derived from src/dawn/platform/BUILD.gn
@ -675,10 +676,12 @@ pub fn Sdk(comptime deps: anytype) type {
fn linkLibDawnNativeDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
if (options.d3d12.?) {
step.linkSystemLibraryName("dxgi");
step.linkSystemLibraryName("dxguid");
step.linkLibrary(b.dependency("direct3d_headers", .{
.target = step.target,
.optimize = step.optimize,
}).artifact("direct3d-headers"));
}
if (options.metal.?) {
step.linkSystemLibraryName("objc");
@ -974,7 +977,7 @@ pub fn Sdk(comptime deps: anytype) type {
fn linkLibTintDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options;
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
}
// Builds tint sources; derived from src/tint/BUILD.gn
@ -1141,7 +1144,7 @@ pub fn Sdk(comptime deps: anytype) type {
fn linkLibSPIRVToolsDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options;
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
}
// Builds third_party/vulkan-deps/spirv-tools sources; derived from third_party/vulkan-deps/spirv-tools/src/BUILD.gn
@ -1207,7 +1210,7 @@ pub fn Sdk(comptime deps: anytype) type {
fn linkLibAbseilCppDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options;
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
const target = step.target_info.target;
if (target.os.tag == .macos) {
step.linkSystemLibraryName("objc");
@ -1285,7 +1288,7 @@ pub fn Sdk(comptime deps: anytype) type {
fn linkLibDawnWireDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options;
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (step.target_info.target.os.tag != .windows) deps.system_sdk.include(b, step, .{});
}
// Buids dawn wire sources; derived from src/dawn/wire/BUILD.gn
@ -1323,13 +1326,16 @@ pub fn Sdk(comptime deps: anytype) type {
}
fn linkLibDxcompilerDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (options.d3d12.?) {
step.linkLibCpp();
step.linkLibrary(b.dependency("direct3d_headers", .{
.target = step.target,
.optimize = step.optimize,
}).artifact("direct3d-headers"));
step.linkSystemLibraryName("oleaut32");
step.linkSystemLibraryName("ole32");
step.linkSystemLibraryName("dbghelp");
step.linkSystemLibraryName("dxguid");
}
}