@@ -190,7 +190,7 @@ fn ensureSubmodules(allocator: std.mem.Allocator) !void {
190
190
pub fn linkFromBinary (b : * Builder , step : * std.build.LibExeObjStep , options : Options ) void {
191
191
const target = (std .zig .system .NativeTargetInfo .detect (b .allocator , step .target ) catch unreachable ).target ;
192
192
const binaries_available = switch (target .os .tag ) {
193
- .windows = > false , // TODO(build-system): add Windows binaries
193
+ .windows = > target . abi . isGnu (),
194
194
.linux = > target .cpu .arch .isX86 () and (target .abi .isGnu () or target .abi .isMusl ()),
195
195
.macos = > blk : {
196
196
if (! target .cpu .arch .isX86 () and ! target .cpu .arch .isAARCH64 ()) break :blk false ;
@@ -220,7 +220,7 @@ pub fn linkFromBinary(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
220
220
binary_target .os_version_max = .{ .none = .{} };
221
221
binary_target .glibc_version = null ;
222
222
const zig_triple = binary_target .zigTriple (b .allocator ) catch unreachable ;
223
- ensureBinaryDownloaded (b .allocator , zig_triple , b .is_release , options .binary_version );
223
+ ensureBinaryDownloaded (b .allocator , zig_triple , b .is_release , target . os . tag == .windows , options .binary_version );
224
224
225
225
const current_git_commit = getCurrentGitCommit (b .allocator ) catch unreachable ;
226
226
const base_cache_dir_rel = std .fs .path .join (b .allocator , &.{ "zig-cache" , "mach" , "gpu-dawn" }) catch unreachable ;
@@ -249,9 +249,13 @@ pub fn linkFromBinary(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
249
249
step .linkFramework ("IOSurface" );
250
250
step .linkFramework ("QuartzCore" );
251
251
}
252
+ if (options .d3d12 .? ) {
253
+ step .linkSystemLibrary ("ole32" );
254
+ step .linkSystemLibrary ("dxguid" );
255
+ }
252
256
}
253
257
254
- pub fn ensureBinaryDownloaded (allocator : std.mem.Allocator , zig_triple : []const u8 , is_release : bool , version : []const u8 ) void {
258
+ pub fn ensureBinaryDownloaded (allocator : std.mem.Allocator , zig_triple : []const u8 , is_release : bool , is_windows : bool , version : []const u8 ) void {
255
259
// If zig-cache/mach/gpu-dawn/<git revision> does not exist:
256
260
// If on a commit in the main branch => rm -r zig-cache/mach/gpu-dawn/
257
261
// else => noop
@@ -293,20 +297,25 @@ pub fn ensureBinaryDownloaded(allocator: std.mem.Allocator, zig_triple: []const
293
297
294
298
// Compose the download URL, e.g.:
295
299
// https://github.com/hexops/mach-gpu-dawn/releases/download/release-6b59025/libdawn_x86_64-macos-gnu_debug.a.gz
300
+ const lib_prefix = if (is_windows ) "dawn_" else "libdawn_" ;
301
+ const lib_ext = if (is_windows ) ".lib" else ".a" ;
302
+ const lib_file_name = if (is_windows ) "dawn.lib" else "libdawn.a" ;
296
303
const download_url = std .mem .concat (allocator , u8 , &.{
297
304
"https://github.com/hexops/mach-gpu-dawn/releases/download/" ,
298
305
version ,
299
- "/libdawn_" ,
306
+ "/" ,
307
+ lib_prefix ,
300
308
github_triple ,
301
309
"_" ,
302
310
release_tag ,
303
- ".a.gz" ,
311
+ lib_ext ,
312
+ ".gz" ,
304
313
}) catch unreachable ;
305
314
306
315
// Download and decompress libdawn
307
316
const gz_target_file = std .fs .path .join (allocator , &.{ download_dir , "compressed.gz" }) catch unreachable ;
308
317
downloadFile (allocator , gz_target_file , download_url ) catch unreachable ;
309
- const target_file = std .fs .path .join (allocator , &.{ target_cache_dir , "libdawn.a" }) catch unreachable ;
318
+ const target_file = std .fs .path .join (allocator , &.{ target_cache_dir , lib_file_name }) catch unreachable ;
310
319
gzipDecompress (allocator , gz_target_file , target_file ) catch unreachable ;
311
320
312
321
// If we don't yet have the headers (these are shared across architectures), download them.
0 commit comments