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 466819 b698ba8b6e2454bd18dbe5b03fb98f8f6ff47df6
parent 466818 3f50c0fa29d8fdc07cb57d79fe971f4b6394d5c5
child 466820 6e20e4acf4e555afa89bbf42bdb288e5761e53bb
push id35781
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 21:56:26 +0000
treeherdermozilla-central@4526b65c502e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1527796
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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()}")