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

@ -26,5 +26,9 @@
.url = "https://github.com/hexops/mach-basisu/archive/831de64fe2d7933d6418440f8558444ca32eeca5.tar.gz", .url = "https://github.com/hexops/mach-basisu/archive/831de64fe2d7933d6418440f8558444ca32eeca5.tar.gz",
.hash = "1220ead8a15f606d6f0f853fe401460dfe18811e3d5d1aa7e808be825e44f17f0dc3", .hash = "1220ead8a15f606d6f0f853fe401460dfe18811e3d5d1aa7e808be825e44f17f0dc3",
}, },
.direct3d_headers = .{
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
},
}, },
} }

View file

@ -0,0 +1,10 @@
.{
.name = "mach-gpu-dawn",
.version = "0.2.0",
.dependencies = .{
.direct3d_headers = .{
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
},
},
}

View file

@ -63,7 +63,8 @@ pub fn Sdk(comptime deps: anytype) type {
const opt = options.detectDefaults(step.target_info.target); const opt = options.detectDefaults(step.target_info.target);
// TODO(build-system): pass system SDK options through // 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) try if (options.from_source)
linkFromSource(b, step, opt) 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 { fn linkLibDawnCommonDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options; _ = options;
step.linkLibCpp(); 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) { if (step.target_info.target.os.tag == .macos) {
step.linkSystemLibraryName("objc"); step.linkSystemLibraryName("objc");
step.linkFramework("Foundation"); 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 { fn linkLibDawnPlatformDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options; _ = options;
step.linkLibCpp(); 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 // 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 { fn linkLibDawnNativeDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
step.linkLibCpp(); 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.?) { if (options.d3d12.?) {
step.linkSystemLibraryName("dxgi"); step.linkLibrary(b.dependency("direct3d_headers", .{
step.linkSystemLibraryName("dxguid"); .target = step.target,
.optimize = step.optimize,
}).artifact("direct3d-headers"));
} }
if (options.metal.?) { if (options.metal.?) {
step.linkSystemLibraryName("objc"); 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 { fn linkLibTintDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options; _ = options;
step.linkLibCpp(); 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 // 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 { fn linkLibSPIRVToolsDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options; _ = options;
step.linkLibCpp(); 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 // 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 { fn linkLibAbseilCppDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options; _ = options;
step.linkLibCpp(); 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; const target = step.target_info.target;
if (target.os.tag == .macos) { if (target.os.tag == .macos) {
step.linkSystemLibraryName("objc"); 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 { fn linkLibDawnWireDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
_ = options; _ = options;
step.linkLibCpp(); 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 // 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 { fn linkLibDxcompilerDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
step.linkLibCpp();
deps.system_sdk.include(b, step, .{});
if (options.d3d12.?) { 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("oleaut32");
step.linkSystemLibraryName("ole32"); step.linkSystemLibraryName("ole32");
step.linkSystemLibraryName("dbghelp"); step.linkSystemLibraryName("dbghelp");
step.linkSystemLibraryName("dxguid");
} }
} }

10
libs/gpu/build.zig.zon Normal file
View file

@ -0,0 +1,10 @@
.{
.name = "mach-gpu",
.version = "0.2.0",
.dependencies = .{
.direct3d_headers = .{
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
},
},
}