gpu-dawn: clone mach-glfw if needed (temporary)

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-02-11 15:28:45 -07:00 committed by Stephen Gutekanst
parent e6e5c7f14a
commit 8035e30ad8

View file

@ -7,6 +7,12 @@ pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions(); const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{}); 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"); const lib = b.addStaticLibrary("gpu", "src/main.zig");
lib.setBuildMode(mode); lib.setBuildMode(mode);
lib.setTarget(target); lib.setTarget(target);
@ -306,6 +312,15 @@ fn getCurrentGitCommit(allocator: std.mem.Allocator) ![]const u8 {
return result.stdout; 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 { fn downloadFile(allocator: std.mem.Allocator, target_file: []const u8, url: []const u8) !void {
std.debug.print("downloading {s}..\n", .{url}); std.debug.print("downloading {s}..\n", .{url});
const child = try std.ChildProcess.init(&.{ "curl", "-L", "-o", target_file, url }, allocator); const child = try std.ChildProcess.init(&.{ "curl", "-L", "-o", target_file, url }, allocator);