зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557796 - Custom mozconfig for gradle build. r=nalexander,owlish
This patch introduces a new local.settings field: mozilla-central.mozconfig. This field can be used to set a custom mozconfig file for the gradle build (and for Android Studio). The environment variable MOZCONFIG will take precedence over what is defined in local.settings to allow Gecko engineers to use multiple mozconfig files. Co-Authored-By: Nick Alexander <nalexander@mozilla.com> Differential Revision: https://phabricator.services.mozilla.com/D124830
This commit is contained in:
Родитель
09ff3640b9
Коммит
1f930e4253
|
@ -167,6 +167,7 @@ class MachExec extends Exec {
|
|||
// $topsrcdir/settings.gradle.
|
||||
project.ext.mozconfig.mozconfig.env.unmodified.each { k, v -> environment.remove(k) }
|
||||
environment project.ext.mozconfig.orig_mozconfig.env.unmodified
|
||||
environment 'MOZCONFIG', project.ext.mozconfig.substs.MOZCONFIG
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,30 @@ native code. `Bug
|
|||
1509539 <https://bugzilla.mozilla.org/show_bug.cgi?id=1509539>`_ tracks
|
||||
making Android Studio and Gradle do this automatically.
|
||||
|
||||
Custom mozconfig with Android Studio
|
||||
------------------------------------
|
||||
|
||||
Out of the box, Android Studio will use the default mozconfig file, normally
|
||||
located at ``mozconfig`` in the root directory of your ``mozilla-central``
|
||||
checkout.
|
||||
|
||||
To make Android Studio use a mozconfig in a custom location, you can add the
|
||||
following to your ``local.properties``:
|
||||
|
||||
::
|
||||
|
||||
mozilla-central.mozconfig=relative/path/to/mozconfig
|
||||
|
||||
Note that, when running mach from the command line, this value will be ignored,
|
||||
and the mozconfig from the mach environment will be used instead.
|
||||
|
||||
To override the mozconfig used by mach, you can use the `MOZCONFIG` environment
|
||||
variable, for example:
|
||||
|
||||
::
|
||||
|
||||
MOZCONFIG=debug.mozconfig ./mach build
|
||||
|
||||
Performing a bug fix
|
||||
--------------------
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
ext.machEnv = { topsrcdir ->
|
||||
// Allow to specify mozconfig in `local.properties` via
|
||||
// `mozilla-central.mozconfig=/path/to/mozconfig`. This can't be an environment
|
||||
// variable because it's not feasible to specify environment variables under
|
||||
// Android Studio on some platforms including macOS.
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = new File(topsrcdir, 'local.properties')
|
||||
if (localPropertiesFile.canRead()) {
|
||||
localPropertiesFile.withInputStream {
|
||||
localProperties.load(it)
|
||||
logger.lifecycle("settings.gradle> Read local.properties: ${localPropertiesFile}")
|
||||
}
|
||||
}
|
||||
|
||||
def localMozconfig = localProperties.getProperty("mozilla-central.mozconfig")
|
||||
|
||||
def env = System.env.collect { k, v -> "${k}=${v}" }
|
||||
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}"
|
||||
} else {
|
||||
logger.lifecycle("settings.gradle> Preferring mozconfig set in mach environment to mozconfig set in local.properties: ${envMozconfig}")
|
||||
}
|
||||
}
|
||||
|
||||
return env
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
// is launched from within IntelliJ.
|
||||
def topsrcdir = rootProject.projectDir.absolutePath
|
||||
|
||||
apply from: "${topsrcdir}/mobile/android/gradle/mach_env.gradle"
|
||||
|
||||
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
|
||||
|
@ -13,7 +15,8 @@ if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
|||
}
|
||||
}
|
||||
}
|
||||
def proc = commandLine.execute(null, new File(topsrcdir))
|
||||
|
||||
def proc = commandLine.execute(machEnv(topsrcdir), new File(topsrcdir))
|
||||
def standardOutput = new ByteArrayOutputStream()
|
||||
def standardError = new ByteArrayOutputStream()
|
||||
proc.consumeProcessOutput(standardOutput, standardError)
|
||||
|
@ -75,4 +78,4 @@ gradle.ext.mozconfig = json
|
|||
def orig = slurper.parse(new File(json.topobjdir, '.mozconfig.json'))
|
||||
gradle.ext.mozconfig.orig_mozconfig = orig.mozconfig
|
||||
project(':messaging_example').projectDir = new File('mobile/android/examples/messaging_example/app')
|
||||
project(':port_messaging_example').projectDir = new File('mobile/android/examples/port_messaging_example/app')
|
||||
project(':port_messaging_example').projectDir = new File('mobile/android/examples/port_messaging_example/app')
|
||||
|
|
|
@ -36,11 +36,15 @@ if (!project.ext.has('topsrcdir')) {
|
|||
throw new GradleException("ext.topsrcdir must be specified to substitute for a local GeckoView")
|
||||
}
|
||||
|
||||
apply from: "${topsrcdir}/mobile/android/gradle/mach_env.gradle"
|
||||
|
||||
// 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(null, new File(ext.has('topobjdir') ? ext.get('topobjdir') : topsrcdir))
|
||||
def proc = commandLine.execute(
|
||||
machEnv(topsrcdir),
|
||||
new File(ext.has('topobjdir') ? ext.get('topobjdir') : topsrcdir))
|
||||
def standardOutput = new ByteArrayOutputStream()
|
||||
proc.consumeProcessOutput(standardOutput, standardOutput)
|
||||
proc.waitFor()
|
||||
|
|
Загрузка…
Ссылка в новой задаче