diff --git a/build.zig.zon b/build.zig.zon index 1001a30d..539645c1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -26,5 +26,9 @@ .url = "https://github.com/hexops/mach-basisu/archive/831de64fe2d7933d6418440f8558444ca32eeca5.tar.gz", .hash = "1220ead8a15f606d6f0f853fe401460dfe18811e3d5d1aa7e808be825e44f17f0dc3", }, + .direct3d_headers = .{ + .url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz", + .hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12", + }, }, } diff --git a/libs/gpu-dawn/build.zig.zon b/libs/gpu-dawn/build.zig.zon new file mode 100644 index 00000000..4400942f --- /dev/null +++ b/libs/gpu-dawn/build.zig.zon @@ -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", + }, + }, +} diff --git a/libs/gpu-dawn/sdk.zig b/libs/gpu-dawn/sdk.zig index 01c8ca6d..b9b0d841 100644 --- a/libs/gpu-dawn/sdk.zig +++ b/libs/gpu-dawn/sdk.zig @@ -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"); } } diff --git a/libs/gpu/build.zig.zon b/libs/gpu/build.zig.zon new file mode 100644 index 00000000..28ed8242 --- /dev/null +++ b/libs/gpu/build.zig.zon @@ -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", + }, + }, +}