File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,10 +7,30 @@ tasks.register("setupRustAndroidLocal") {
77 }
88
99 // Detect existence of rustup.
10- def rustupExists = exec {
11- commandLine(" which" , " rustup" )
12- ignoreExitValue true
13- }. exitValue == 0
10+ def rustupExists = {
11+
12+ // First check common installation path
13+ def isWindows = System . getProperty(" os.name" ). toLowerCase(). contains(" windows" )
14+ def home = System . getProperty(" user.home" )
15+ def rustupPath = isWindows
16+ ? new File (home, " .cargo/bin/rustup.exe" )
17+ : new File (home, " .cargo/bin/rustup" )
18+
19+ if (rustupPath. exists() && rustupPath. canExecute()) {
20+ return true
21+ }
22+
23+ // If not, check on user $PATH/%PATH%
24+ try {
25+ def process = new ProcessBuilder (" rustup" )
26+ .redirectErrorStream(true )
27+ .start()
28+ process. waitFor()
29+ return process. exitValue() == 0
30+ } catch (IOException ignored) {
31+ return false
32+ }
33+ }()
1434
1535 if (! rustupExists) {
1636 println (" rustup not found. Installing rustup..." )
You can’t perform that action at this time.
0 commit comments