Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/SkipBuild/Commands/DoctorCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ extension ToolOptionsCommand where Self : StreamingCommand {
try await checkVersion(title: "Gradle version", cmd: ["gradle", "-version"], min: Version("8.6.0"), pattern: "Gradle ([0-9.]+)", hint: " (install with: brew install gradle)")
try await checkVersion(title: "Java version", cmd: ["java", "-version"], min: Version("17.0.0"), pattern: "version \"([0-9._]+)\"", hint: ProcessInfo.processInfo.environment["JAVA_HOME"] == nil ? nil : " (check JAVA_HOME environment: \(ProcessInfo.processInfo.environment["JAVA_HOME"] ?? "unset"))") // we don't necessarily need java in the path (which it doesn't seem to be by default with Homebrew)
try await checkVersion(title: "Android Debug Bridge version", cmd: ["adb", "version"], min: Version("1.0.40"), pattern: "version ([0-9.]+)")
if let androidHome = ProcessInfo.androidHome {
let exists = FileManager.default.fileExists(atPath: androidHome)
if !exists {
if ProcessInfo.processInfo.environment["ANDROID_HOME"] == nil {
await out.yield(MessageBlock(status: .fail, "Android SDK version: Not found. $ANDROID_HOME is not set and default SDK location does not exist: \(androidHome) (install from https://developer.android.com/studio)"))
} else {
await out.yield(MessageBlock(status: .fail, "Android SDK version: Not found. $ANDROID_HOME is set to \(androidHome) but the directory does not exist"))
}
} else {
let sdkAdbPath = "\(androidHome)/platform-tools/adb"
try await checkVersion(title: "Android SDK version", cmd: [sdkAdbPath, "--version"], min: Version("29.0.0"), pattern: "Version ([0-9.]+)", hint: " (install from https://developer.android.com/studio)")
}
} else {
await out.yield(MessageBlock(status: .fail, "Android SDK version: Not found. $ANDROID_HOME is not set (install from https://developer.android.com/studio)"))
}
#if os(macOS)
// we no longer require that Android Studio be installed with the advent of `skip android emulator create`
//await checkAndroidStudioVersion(with: out)
Expand Down
25 changes: 18 additions & 7 deletions Sources/SkipBuild/SkipCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -773,18 +773,29 @@ extension ProcessInfo {
#endif
}()

public static let androidHome: String? = {
if let e = ProcessInfo.processInfo.environment["ANDROID_HOME"], !e.isEmpty {
return e
}
#if os(macOS)
return ("~/Library/Android/sdk" as NSString).expandingTildeInPath
#elseif os(Windows)
return ("~/AppData/Local/Android/Sdk" as NSString).expandingTildeInPath
#elseif os(Linux)
return ("~/Android/Sdk" as NSString).expandingTildeInPath
#else
return nil
#endif
}()

/// The current process environment along with the default paths to various tools set
public var environmentWithDefaultToolPaths: [String: String] {
var env = self.environment
let ANDROID_HOME = "ANDROID_HOME"
if (env[ANDROID_HOME] ?? "").isEmpty {
#if os(macOS)
env[ANDROID_HOME] = ("~/Library/Android/sdk" as NSString).expandingTildeInPath
#elseif os(Windows)
env[ANDROID_HOME] = ("~/AppData/Local/Android/Sdk" as NSString).expandingTildeInPath
#elseif os(Linux)
env[ANDROID_HOME] = ("~/Android/Sdk" as NSString).expandingTildeInPath
#endif
if let androidHome = ProcessInfo.androidHome {
env[ANDROID_HOME] = androidHome
}
}

return env
Expand Down
Loading