mach: ensure git present
This commit is contained in:
parent
5549388e57
commit
866acd5535
1 changed files with 21 additions and 0 deletions
21
build.zig
21
build.zig
|
|
@ -27,6 +27,7 @@ pub fn build(b: *std.build.Builder) void {
|
||||||
test_step.dependOn(&main_tests.step);
|
test_step.dependOn(&main_tests.step);
|
||||||
|
|
||||||
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
||||||
|
ensureGit(b.allocator);
|
||||||
ensureDependencySubmodule(b.allocator, "examples/libs/zmath") catch unreachable;
|
ensureDependencySubmodule(b.allocator, "examples/libs/zmath") catch unreachable;
|
||||||
ensureDependencySubmodule(b.allocator, "examples/libs/zigimg") catch unreachable;
|
ensureDependencySubmodule(b.allocator, "examples/libs/zigimg") catch unreachable;
|
||||||
ensureDependencySubmodule(b.allocator, "examples/assets") catch unreachable;
|
ensureDependencySubmodule(b.allocator, "examples/assets") catch unreachable;
|
||||||
|
|
@ -285,3 +286,23 @@ fn ensureDependencySubmodule(allocator: std.mem.Allocator, path: []const u8) !vo
|
||||||
|
|
||||||
_ = try child.spawnAndWait();
|
_ = try child.spawnAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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