Skip to content

Commit

Permalink
ci: fix ubuntu-latest based emulator runs
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon committed Sep 27, 2024
1 parent a28d3a5 commit e9d401a
Showing 1 changed file with 62 additions and 4 deletions.
66 changes: 62 additions & 4 deletions android/env/env.v
Original file line number Diff line number Diff line change
Expand Up @@ -754,13 +754,71 @@ pub fn has_avdmanager() bool {

// avdmanager returns the full path to the `avdmanager` tool, if found. An empty string otherwise.
pub fn avdmanager() string {
mut avdmanager_path := os.getenv('AVDMANAGER')
if !os.exists(avdmanager_path) {
mut avdmanager_exe := cache.get_string(@MOD + '.' + @FN)
if avdmanager_exe != '' {
return avdmanager_exe
}

avdmanager_exe = os.getenv('AVDMANAGER')
// Check in cache
if !os.is_executable(avdmanager_exe) {
avdmanager_exe = os.join_path(util.cache_dir(), 'avdmanager')
if !os.is_executable(avdmanager_exe) {
avdmanager_exe = os.join_path(sdk.cache_dir(), 'cmdline-tools', '3.0', 'bin',
'avdmanager')
}
if !os.is_executable(avdmanager_exe) {
avdmanager_exe = os.join_path(sdk.cache_dir(), 'cmdline-tools', '2.1', 'bin',
'avdmanager')
}
if !os.is_executable(avdmanager_exe) {
avdmanager_exe = os.join_path(sdk.cache_dir(), 'cmdline-tools', 'tools', 'bin',
'avdmanager')
}
}
// Try if one is in PATH
if !os.is_executable(avdmanager_exe) {
if os.exists_in_system_path('avdmanager') {
avdmanager_path = os.find_abs_path_of_executable('avdmanager') or { '' }
avdmanager_exe = os.find_abs_path_of_executable('avdmanager') or { '' }
}
}
// Try detecting it in the SDK
if sdk.found() {
if !os.is_executable(avdmanager_exe) {
avdmanager_exe = os.join_path(sdk.root(), 'cmdline-tools', 'tools', 'bin',
'avdmanager')
}
if !os.is_executable(avdmanager_exe) {
avdmanager_exe = os.join_path(sdk.tools_root(), 'bin', 'avdmanager')
}
// It's often found next to `sdkmanager`
if !os.is_executable(avdmanager_exe) {
for relative_path in possible_relative_to_sdk_sdkmanager_paths {
avdmanager_exe = os.join_path(sdk.root(), relative_path, 'avdmanager')
if os.is_executable(avdmanager_exe) {
break
}
}
}
if !os.is_executable(avdmanager_exe) {
version_dirs := util.ls_sorted(os.join_path(sdk.root(), 'cmdline-tools')).filter(fn (a string) bool {
return util.is_version(a)
})
for version_dir in version_dirs {
avdmanager_exe = os.join_path(sdk.root(), 'cmdline-tools', version_dir,
'bin', 'avdmanager')
if os.is_executable(avdmanager_exe) {
break
}
}
}
}
return avdmanager_path
// Give up
if !os.is_executable(avdmanager_exe) {
avdmanager_exe = ''
}
cache.set_string(@MOD + '.' + @FN, avdmanager_exe)
return avdmanager_exe
}

// has_emulator returns `true` if `emulator` can be located on the system.
Expand Down

0 comments on commit e9d401a

Please sign in to comment.