From 8035e30ad83167c682c46405adc7746b2d5096b3 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 11 Feb 2022 15:28:45 -0700 Subject: [PATCH] gpu-dawn: clone mach-glfw if needed (temporary) Signed-off-by: Stephen Gutekanst --- gpu-dawn/build.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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);