gpu-dawn: add CURL_INSECURE=true option to workaround windows SSL issues

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-09-12 20:45:24 -07:00
parent 23f9e9fb65
commit 98d929611c
2 changed files with 24 additions and 5 deletions

View file

@ -149,10 +149,9 @@ pub fn Sdk(comptime deps: anytype) type {
}
fn ensureSubmodules(allocator: std.mem.Allocator) !void {
if (std.process.getEnvVarOwned(allocator, "NO_ENSURE_SUBMODULES")) |no_ensure_submodules| {
defer allocator.free(no_ensure_submodules);
if (std.mem.eql(u8, no_ensure_submodules, "true")) return;
} else |_| {}
if (isEnvVarTruthy(allocator, "NO_ENSURE_SUBMODULES")) {
return;
}
var child = std.ChildProcess.init(&.{ "git", "submodule", "update", "--init", "--recursive" }, allocator);
child.cwd = comptime thisDir();
child.stderr = std.io.getStdErr();
@ -160,6 +159,16 @@ pub fn Sdk(comptime deps: anytype) type {
_ = try child.spawnAndWait();
}
fn isEnvVarTruthy(allocator: std.mem.Allocator, name: []const u8) bool {
if (std.process.getEnvVarOwned(allocator, name)) |truthy| {
defer allocator.free(truthy);
if (std.mem.eql(u8, truthy, "true")) return true;
return false;
} else |_| {
return false;
}
}
pub fn linkFromBinary(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
const target = step.target_info.target;
const binaries_available = switch (target.os.tag) {
@ -448,7 +457,13 @@ pub fn Sdk(comptime deps: anytype) type {
fn downloadFile(allocator: std.mem.Allocator, target_file: []const u8, url: []const u8) !void {
std.debug.print("downloading {s}..\n", .{url});
var child = std.ChildProcess.init(&.{ "curl", "-L", "-o", target_file, url }, allocator);
// Some Windows users experience `SSL certificate problem: unable to get local issuer certificate`
// so we give them the option to disable SSL if they desire / don't want to debug the issue.
var child = if (isEnvVarTruthy(allocator, "CURL_INSECURE"))
std.ChildProcess.init(&.{ "curl", "--insecure", "-L", "-o", target_file, url }, allocator)
else
std.ChildProcess.init(&.{ "curl", "-L", "-o", target_file, url }, allocator);
child.cwd = comptime thisDir();
child.stderr = std.io.getStdErr();
child.stdout = std.io.getStdOut();