glfw: ensure git present
This commit is contained in:
parent
7de0776f38
commit
5549388e57
1 changed files with 21 additions and 0 deletions
|
|
@ -216,6 +216,7 @@ fn determineSdkRoot(allocator: std.mem.Allocator, org: []const u8, name: []const
|
|||
return sdk_root_dir;
|
||||
} else |err| return switch (err) {
|
||||
error.FileNotFound => {
|
||||
ensureGit(allocator);
|
||||
std.log.info("cloning required sdk..\ngit clone https://github.com/{s}/{s} '{s}'..\n", .{ org, name, sdk_root_dir });
|
||||
if (std.mem.startsWith(u8, name, "sdk-macos-")) {
|
||||
if (!try confirmAppleSDKAgreement(allocator)) @panic("cannot continue");
|
||||
|
|
@ -270,3 +271,23 @@ fn confirmAppleSDKAgreement(allocator: std.mem.Allocator) !bool {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fn ensureGit(allocator: std.mem.Allocator) void {
|
||||
const argv = &[_][]const u8{ "git", "--version" };
|
||||
const result = std.ChildProcess.exec(.{
|
||||
.allocator = allocator,
|
||||
.argv = argv,
|
||||
.cwd = ".",
|
||||
}) catch { // e.g. FileNotFound
|
||||
std.log.err("mach: error: 'git --version' failed. Is git not installed?", .{});
|
||||
std.process.exit(1);
|
||||
};
|
||||
defer {
|
||||
allocator.free(result.stderr);
|
||||
allocator.free(result.stdout);
|
||||
}
|
||||
if (result.term.Exited != 0) {
|
||||
std.log.err("mach: error: 'git --version' failed. Is git not installed?", .{});
|
||||
std.process.exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue