Browse Source

Merge pull request #43549 from m4gr3d/fix_scons_path

Update the logic to query for the 'scons' command executable path
Rémi Verschelde 4 years ago
parent
commit
f939d9399f
2 changed files with 33 additions and 3 deletions
  1. 0 2
      platform/android/java/build.gradle
  2. 33 1
      platform/android/java/lib/build.gradle

+ 0 - 2
platform/android/java/build.gradle

@@ -22,8 +22,6 @@ allprojects {
 }
 }
 
 
 ext {
 ext {
-    sconsExt = org.gradle.internal.os.OperatingSystem.current().isWindows() ? ".bat" : ""
-
     supportedAbis = ["armv7", "arm64v8", "x86", "x86_64"]
     supportedAbis = ["armv7", "arm64v8", "x86", "x86_64"]
     supportedTargets = ["release", "debug"]
     supportedTargets = ["release", "debug"]
 
 

+ 33 - 1
platform/android/java/lib/build.gradle

@@ -64,10 +64,42 @@ android {
             throw new GradleException("Invalid default abi: " + defaultAbi)
             throw new GradleException("Invalid default abi: " + defaultAbi)
         }
         }
 
 
+        // Find scons' executable path
+        File sconsExecutableFile = null
+        def sconsName = "scons"
+        def sconsExts = (org.gradle.internal.os.OperatingSystem.current().isWindows()
+            ? [".bat", ".exe"]
+            : [""])
+        logger.lifecycle("Looking for $sconsName executable path")
+        for (ext in sconsExts) {
+            String sconsNameExt = sconsName + ext
+            logger.lifecycle("Checking $sconsNameExt")
+
+            sconsExecutableFile = org.gradle.internal.os.OperatingSystem.current().findInPath(sconsNameExt)
+            if (sconsExecutableFile != null) {
+                // We're done!
+                break
+            }
+
+            // Check all the options in path
+            List<File> allOptions = org.gradle.internal.os.OperatingSystem.current().findAllInPath(sconsNameExt)
+            if (!allOptions.isEmpty()) {
+                // Pick the first option and we're done!
+                sconsExecutableFile = allOptions.get(0)
+                break
+            }
+        }
+
+        if (sconsExecutableFile == null) {
+            throw new GradleException("Unable to find executable path for the '$sconsName' command.")
+        } else {
+            logger.lifecycle("Found executable path for $sconsName: ${sconsExecutableFile.absolutePath}")
+        }
+
         // Creating gradle task to generate the native libraries for the default abi.
         // Creating gradle task to generate the native libraries for the default abi.
         def taskName = getSconsTaskName(buildType)
         def taskName = getSconsTaskName(buildType)
         tasks.create(name: taskName, type: Exec) {
         tasks.create(name: taskName, type: Exec) {
-            executable "scons" + sconsExt
+            executable sconsExecutableFile.absolutePath
             args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()
             args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()
         }
         }