diff --git a/gpu-dawn/build.zig b/gpu-dawn/build.zig index 38142329..328da9e3 100644 --- a/gpu-dawn/build.zig +++ b/gpu-dawn/build.zig @@ -7,6 +7,12 @@ pub fn build(b: *Builder) void { const mode = b.standardReleaseOptions(); const target = b.standardTargetOptions(.{}); + // TODO(build-system): remove dependency on GLFW (Dawn no longer requires it / we can + // eliminate it.) + if (!dirExists("libs/mach-glfw")) { + try gitClone(b.allocator, "https://github.com/hexops/mach-glfw", "libs/mach-glfw"); + } + const lib = b.addStaticLibrary("gpu", "src/main.zig"); lib.setBuildMode(mode); lib.setTarget(target); @@ -306,6 +312,15 @@ fn getCurrentGitCommit(allocator: std.mem.Allocator) ![]const u8 { return result.stdout; } +fn gitClone(allocator: std.mem.Allocator, repository: []const u8, dir: []const u8) !bool { + const result = try std.ChildProcess.exec(.{ + .allocator = allocator, + .argv = &.{ "git", "clone", repository, dir }, + .cwd = thisDir(), + }); + return result.term.Exited == 0; +} + fn downloadFile(allocator: std.mem.Allocator, target_file: []const u8, url: []const u8) !void { std.debug.print("downloading {s}..\n", .{url}); const child = try std.ChildProcess.init(&.{ "curl", "-L", "-o", target_file, url }, allocator);