From 256fea8e5fd1c03b3ca01e4ca1b8848fbb56efbf Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 28 Nov 2021 20:19:23 -0700 Subject: [PATCH] glfw: do not pin SDK version when using custom dev SDK path Signed-off-by: Stephen Gutekanst --- glfw/system_sdk.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glfw/system_sdk.zig b/glfw/system_sdk.zig index a24128e5..d4f16e8c 100644 --- a/glfw/system_sdk.zig +++ b/glfw/system_sdk.zig @@ -119,7 +119,9 @@ fn getSdkRoot(allocator: *std.mem.Allocator, org: []const u8, name: []const u8, // Where `` is the name of the SDK, e.g. `sdk-macos-12.0`. var sdk_root_dir: []const u8 = undefined; var sdk_path_dir: []const u8 = undefined; + var custom_sdk_path = false; if (std.process.getEnvVarOwned(allocator, "SDK_PATH")) |sdk_path| { + custom_sdk_path = true; sdk_path_dir = sdk_path; sdk_root_dir = try std.fs.path.join(allocator, &.{ sdk_path, name }); } else |err| switch (err) { @@ -133,7 +135,7 @@ fn getSdkRoot(allocator: *std.mem.Allocator, org: []const u8, name: []const u8, // If the SDK exists, return it. Otherwise, clone it. if (std.fs.openDirAbsolute(sdk_root_dir, .{})) { exec(allocator, &[_][]const u8{ "git", "fetch" }, sdk_root_dir) catch |err| std.debug.print("warning: failed to check for updates to {s}/{s}: {s}\n", .{ org, name, @errorName(err) }); - try exec(allocator, &[_][]const u8{ "git", "reset", "--quiet", "--hard", revision }, sdk_root_dir); + if (!custom_sdk_path) try exec(allocator, &[_][]const u8{ "git", "reset", "--quiet", "--hard", revision }, sdk_root_dir); return sdk_root_dir; } else |err| return switch (err) {