Bug 1955358 - Allow Android Studio to read from local mozconfig. r=geckoview-reviewers,saschanaz,nalexander,ohall
Differential Revision: https://phabricator.services.mozilla.com/D242463
This commit is contained in:
@@ -13,13 +13,12 @@ ext.machEnv = { topsrcdir ->
|
||||
}
|
||||
|
||||
def localMozconfig = localProperties.getProperty("mozilla-central.mozconfig")
|
||||
|
||||
def env = System.env.collect { k, v -> "${k}=${v}" }
|
||||
def env = new HashMap(System.env)
|
||||
if (localMozconfig) {
|
||||
def envMozconfig = System.env.get('FOUND_MOZCONFIG')
|
||||
if (!envMozconfig || localMozconfig == envMozconfig) {
|
||||
logger.lifecycle("settings.gradle> Setting mozconfig from local.properties: ${localMozconfig}")
|
||||
env << "MOZCONFIG=${localMozconfig}"
|
||||
env.MOZCONFIG = localMozconfig
|
||||
} else {
|
||||
logger.lifecycle("settings.gradle> Preferring mozconfig set in mach environment to mozconfig set in local.properties: ${envMozconfig}")
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ if (System.env.GRADLE_MACH_PYTHON) {
|
||||
}
|
||||
|
||||
def proc = providers.exec {
|
||||
commandLine(command)
|
||||
workingDir = new File(topsrcdir)
|
||||
environment = machEnv(topsrcdir)
|
||||
commandLine = command
|
||||
ignoreExitValue = true
|
||||
}
|
||||
|
||||
|
||||
@@ -49,24 +49,26 @@ def loadMozconfig() {
|
||||
// Cribbed from https://hg.mozilla.org/mozilla-central/file/tip/settings.gradle. When run in
|
||||
// topobjdir, `mach environment` correctly finds the mozconfig corresponding to that object
|
||||
// directory.
|
||||
def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
|
||||
def proc = commandLine.execute(
|
||||
machEnv(topsrcdir),
|
||||
new File(ext.has('topobjdir') ? ext.get('topobjdir') : topsrcdir))
|
||||
def standardOutput = new ByteArrayOutputStream()
|
||||
def standardError = new ByteArrayOutputStream()
|
||||
proc.consumeProcessOutput(standardOutput, standardError)
|
||||
proc.waitFor()
|
||||
def command = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
|
||||
def proc = providers.exec {
|
||||
workingDir = new File(ext.has('topobjdir') ? ext.get('topobjdir') : topsrcdir)
|
||||
environment = machEnv(topsrcdir)
|
||||
commandLine = command
|
||||
ignoreExitValue = true
|
||||
}
|
||||
def result = proc.result.get().exitValue
|
||||
def standardOutput = proc.standardOutput.asText.get()
|
||||
def standardError = proc.standardError.asText.get()
|
||||
|
||||
// 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"
|
||||
+ "stdout:\n${standardOutput.toString()}\n\n"
|
||||
+ "stderr:\n${standardError.toString()}")
|
||||
if (result != 0) {
|
||||
throw new GradleException("Process '${command}' finished with non-zero exit value ${result}:\n\n"
|
||||
+ "stdout:\n${standardOutput}\n\n"
|
||||
+ "stderr:\n${standardError}")
|
||||
}
|
||||
|
||||
def slurper = new JsonSlurper()
|
||||
def mozconfig = slurper.parseText(standardOutput.toString())
|
||||
def mozconfig = slurper.parseText(standardOutput)
|
||||
|
||||
if (topsrcdir != mozconfig.topsrcdir) {
|
||||
throw new GradleException("Specified topsrcdir ('${topsrcdir}') is not mozconfig topsrcdir ('${mozconfig.topsrcdir}')")
|
||||
|
||||
Reference in New Issue
Block a user