(name: &str)
| 1822 | } |
| 1823 | |
| 1824 | fn android_cmdline_tool_path(name: &str) -> PathBuf { |
| 1825 | let root = sdk_root(); |
| 1826 | let latest = android_sdk_tool_path_for_os( |
| 1827 | &root, |
| 1828 | &format!("cmdline-tools/latest/bin/{name}"), |
| 1829 | std::env::consts::OS, |
| 1830 | ); |
| 1831 | if latest.exists() { |
| 1832 | return latest; |
| 1833 | } |
| 1834 | let cmdline_tools = root.join("cmdline-tools"); |
| 1835 | if let Ok(entries) = std::fs::read_dir(&cmdline_tools) { |
| 1836 | let mut candidates = entries |
| 1837 | .filter_map(Result::ok) |
| 1838 | .map(|entry| { |
| 1839 | android_sdk_tool_path_for_os( |
| 1840 | entry.path().join("bin").as_path(), |
| 1841 | name, |
| 1842 | std::env::consts::OS, |
| 1843 | ) |
| 1844 | }) |
| 1845 | .filter(|path| path.exists()) |
| 1846 | .collect::<Vec<_>>(); |
| 1847 | candidates.sort(); |
| 1848 | if let Some(path) = candidates.pop() { |
| 1849 | return path; |
| 1850 | } |
| 1851 | } |
| 1852 | let tools_bin = |
| 1853 | android_sdk_tool_path_for_os(&root, &format!("tools/bin/{name}"), std::env::consts::OS); |
| 1854 | if tools_bin.exists() { |
| 1855 | return tools_bin; |
| 1856 | } |
| 1857 | latest |
| 1858 | } |
| 1859 | |
| 1860 | fn java_home() -> Option<OsString> { |
| 1861 | env::var_os("JAVA_HOME") |
no test coverage detected