Bug 1527796 - Part 5. Add python.exe path of mozilla-build to call mach command from gradle. r=nalexander
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 29 Mar 2019 18:11:09 +0900
changeset 1940890 b698ba8b6e2454bd18dbe5b03fb98f8f6ff47df6
parent 1940889 3f50c0fa29d8fdc07cb57d79fe971f4b6394d5c5
child 1940891 6e20e4acf4e555afa89bbf42bdb288e5761e53bb
push id346175
push usermpalmgren@mozilla.com
push dateFri, 29 Mar 2019 11:19:40 +0000
treeherdertry@fef6a83f0be1 [default view] [failures only]
reviewersnalexander
bugs1527796
milestone68.0a1
Bug 1527796 - Part 5. Add python.exe path of mozilla-build to call mach command from gradle. r=nalexander Since gradle doesn't run on sh.exe, it requires python path to run mach command. But gradle doesn't have a way to detect python.exe. When using MozillaBuild, it sets MOZILLABUILD environment value, so we can detect python path in MozillaBuild using it if available. Differential Revision: https://phabricator.services.mozilla.com/D20454
settings.gradle
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,13 +1,23 @@
 // You might think topsrcdir is '.', but that's not true when the Gradle build
 // is launched from within IntelliJ.
 def topsrcdir = rootProject.projectDir.absolutePath
 
 def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
+if (System.properties['os.name'].toLowerCase().contains('windows')) {
+    // gradle is called before parsing config.status, we cannot use PYTHON
+    // value.
+    if (System.env.MOZILLABUILD) {
+        def mozillabuild = System.env.MOZILLABUILD
+        if (mozillabuild) {
+            commandLine.addAll(0, ["${mozillabuild}/python/python.exe"])
+        }
+    }
+}
 def proc = commandLine.execute(null, new File(topsrcdir))
 def standardOutput = new ByteArrayOutputStream()
 proc.consumeProcessOutput(standardOutput, standardOutput)
 proc.waitFor()
 
 // Only show the output if something went wrong.
 if (proc.exitValue() != 0) {
     throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n${standardOutput.toString()}")