glfw: use cross-platform getEnvVarOwned

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-07-10 21:19:25 -07:00 committed by Stephen Gutekanst
parent 7cf35c54e9
commit c4d4953f28

View file

@ -225,7 +225,7 @@ fn getSdkRoot(allocator: *std.mem.Allocator, comptime name: []const u8) ![]const
error.FileNotFound => { error.FileNotFound => {
std.log.info("cloning required sdk..\ngit clone https://github.com/hexops/{s} '{s}'..\n", .{ name, sdk_root_dir }); std.log.info("cloning required sdk..\ngit clone https://github.com/hexops/{s} '{s}'..\n", .{ name, sdk_root_dir });
if (std.mem.eql(u8, name, "sdk-macos-11.3")) { if (std.mem.eql(u8, name, "sdk-macos-11.3")) {
if (!try confirmAppleSDKAgreement()) @panic("cannot continue"); if (!try confirmAppleSDKAgreement(allocator)) @panic("cannot continue");
} }
try std.fs.cwd().makePath(app_data_dir); try std.fs.cwd().makePath(app_data_dir);
const argv = &[_][]const u8{ "git", "clone", "https://github.com/hexops/" ++ name }; const argv = &[_][]const u8{ "git", "clone", "https://github.com/hexops/" ++ name };
@ -242,8 +242,15 @@ fn getSdkRoot(allocator: *std.mem.Allocator, comptime name: []const u8) ![]const
}; };
} }
fn confirmAppleSDKAgreement() !bool { fn confirmAppleSDKAgreement(allocator: *std.mem.Allocator) !bool {
if (std.mem.eql(u8, std.os.getenv("AGREE") orelse "", "true")) return true; if (std.process.getEnvVarOwned(allocator, "AGREE")) |agree| {
defer allocator.free(agree);
return std.mem.eql(u8, agree, "true");
} else |err| switch (err) {
error.EnvironmentVariableNotFound => {},
else => |e| return e,
}
const stdin = std.io.getStdIn().reader(); const stdin = std.io.getStdIn().reader();
const stdout = std.io.getStdOut().writer(); const stdout = std.io.getStdOut().writer();
var buf: [10]u8 = undefined; var buf: [10]u8 = undefined;