diff --git a/build.zig b/build.zig index 87ee8223..8f6eca6b 100644 --- a/build.zig +++ b/build.zig @@ -1,5 +1,7 @@ const std = @import("std"); +const log = std.log.scoped(.mach_gpu_dawn); + pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); @@ -88,7 +90,7 @@ pub const Options = struct { install_libs: bool = false, /// The binary release version to use from https://github.com/hexops/mach-gpu-dawn/releases - binary_version: []const u8 = "release-1cce80c", + binary_version: []const u8 = "release-1cce80c", /// Detects the default options to use for the given target. pub fn detectDefaults(self: Options, target: std.Target) Options { @@ -519,7 +521,9 @@ fn downloadBinary( downloadFile(allocator, gz_target_file, download_url) catch @panic(gz_target_file); const target_file = try std.fs.path.join(allocator, &.{ target_cache_dir, lib_file_name }); defer allocator.free(target_file); + log.info("extracting {s}\n", .{gz_target_file}); try gzipDecompress(allocator, gz_target_file, target_file); + log.info("finished\n", .{}); // If we don't yet have the headers (these are shared across architectures), download them. const include_dir = try std.fs.path.join(allocator, &.{ commit_cache_dir, "include" }); @@ -580,11 +584,10 @@ fn gzipDecompress(allocator: std.mem.Allocator, src_absolute_path: []const u8, d defer file.close(); var buf_stream = std.io.bufferedReader(file.reader()); - var gzip_stream = try std.compress.gzip.decompress(allocator, buf_stream.reader()); - defer gzip_stream.deinit(); + var decompressor = std.compress.gzip.decompressor(buf_stream.reader()); // Read and decompress the whole file - const buf = try gzip_stream.reader().readAllAlloc(allocator, std.math.maxInt(usize)); + const buf = try decompressor.reader().readAllAlloc(allocator, std.math.maxInt(usize)); defer allocator.free(buf); var new_file = try std.fs.createFileAbsolute(dst_absolute_path, .{}); @@ -631,17 +634,25 @@ fn gitClone(allocator: std.mem.Allocator, repository: []const u8, dir: []const u } fn downloadFile(allocator: std.mem.Allocator, target_file_path: []const u8, url: []const u8) !void { - std.debug.print("downloading {s}..\n", .{url}); - - const target_file = try std.fs.cwd().createFile(target_file_path, .{}); + log.info("downloading {s}\n", .{url}); var client: std.http.Client = .{ .allocator = allocator }; defer client.deinit(); - var fetch_res = try client.fetch(allocator, .{ + var resp = std.ArrayList(u8).init(allocator); + defer resp.deinit(); + var fetch_res = try client.fetch(.{ .location = .{ .url = url }, - .response_strategy = .{ .file = target_file }, + .response_storage = .{ .dynamic = &resp }, + .max_append_size = 50 * 1024 * 1024, }); - fetch_res.deinit(); + if (fetch_res.status.class() != .success) { + log.err("unable to fetch: HTTP {}", .{fetch_res.status}); + return error.FetchFailed; + } + log.info("finished\n", .{}); + + const target_file = try std.fs.cwd().createFile(target_file_path, .{}); + try target_file.writeAll(resp.items); } fn isLinuxDesktopLike(tag: std.Target.Os.Tag) bool { diff --git a/build.zig.zon b/build.zig.zon index 34290df8..6f27b178 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -13,20 +13,20 @@ }, .dependencies = .{ .xcode_frameworks = .{ - .url = "https://pkg.machengine.org/xcode-frameworks/e7c2abbe28efbb5ae7f04e6c1ac6578a6d75bb67.tar.gz", - .hash = "1220432df3c74dc28bd6cc299e5c8317bc65a95219e6ebf40450c157d8c7a3ac54c0", + .url = "https://pkg.machengine.org/xcode-frameworks/2fca968efa90a4060803c56dd0f027890353f0a9.tar.gz", + .hash = "122010c1a745ea06dee3012fbd3b311bd3d75ec39ded6bf566b36ebe3cd8da482347", }, .direct3d_headers = .{ - .url = "https://pkg.machengine.org/direct3d-headers/74e2cdaf3a7f9485155bd22ea8e6bc5442d3cddb.tar.gz", - .hash = "1220d3db004f3ae6ed6e4ad00e59e1b88c4090a152ea19c21ce6e4ead5b702c980e2", + .url = "https://pkg.machengine.org/direct3d-headers/bc2fafe176dbd36bff6d1c036488c015bd4c0f7b.tar.gz", + .hash = "12201f3096410a22af7978c7c57636f251669c335919740e42fc1785180435f63f1c", }, .vulkan_headers = .{ - .url = "https://pkg.machengine.org/vulkan-headers/2fd311329a36ccd4df5672b09a212b3073a44353.tar.gz", - .hash = "1220db08ac1f2712cb0ad0abc09d819b50776012f3fdab2cfe585dbd9db32a26550c", + .url = "https://pkg.machengine.org/vulkan-headers/e33f2e482893a90bb36d67649ab30d5236ac21ab.tar.gz", + .hash = "122017098e4ca00dac1a9d30d152a6e6e9522843219c6df4489210fb7c8a6e4c7c1a", }, .x11_headers = .{ - .url = "https://pkg.machengine.org/x11-headers/39d69153febf15537a33b425c57a3831e4a0ab2a.tar.gz", - .hash = "1220e83ec1e5addab76d30aad3adbbb02ee44fef30d90425c898670e48b495e42027", + .url = "https://pkg.machengine.org/x11-headers/ad1c4891f70302c61ba956cfd565758dc1ca9d28.tar.gz", + .hash = "1220ce35d8f1556afd5bf4796a7899d459f9c628b989f247eaf6aa00fbad10a88c9f", }, }, }