Skip to content

Commit 72af2b4

Browse files
committed
Fix for mac
1 parent 7b4cc4e commit 72af2b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/androidbuild/tools.zig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub const Tools = struct {
228228
// - 1st: $ANDROID_HOME/cmdline-tools/bin
229229
// - 2nd: $ANDROID_HOME/tools/bin
230230
const cmdline_tools_path = cmdlineblk: {
231-
const cmdline_tools = b.pathResolve(&[_][]const u8{ android_sdk_path, "cmdline-tools", "bin" });
231+
const cmdline_tools = b.pathResolve(&[_][]const u8{ android_sdk_path, "cmdline-tools", "latest", "bin" });
232232
std.fs.accessAbsolute(cmdline_tools, .{}) catch |cmderr| switch (cmderr) {
233233
error.FileNotFound => {
234234
const tools = b.pathResolve(&[_][]const u8{ android_sdk_path, "tools", "bin" });
@@ -563,7 +563,15 @@ fn getAndroidSDKPath(allocator: std.mem.Allocator) error{OutOfMemory}![]const u8
563563
// NOTE(jae): 2024-09-15
564564
// Look into auto-discovery of Android SDK for Mac
565565
// Mac: /Users/<username>/Library/Android/sdk
566-
// .macos => {},
566+
.macos => {
567+
const user = std.process.getEnvVarOwned(allocator, "USER") catch |err| switch (err) {
568+
error.OutOfMemory => return error.OutOfMemory,
569+
error.EnvironmentVariableNotFound => &[0]u8{},
570+
error.InvalidWtf8 => @panic("USER environment variable is invalid UTF-8"),
571+
};
572+
defer allocator.free(user);
573+
return try std.fmt.allocPrint(allocator, "/Users/{s}/Library/Android/sdk", .{user});
574+
},
567575
else => {},
568576
}
569577
return &[0]u8{};

0 commit comments

Comments
 (0)