Skip to content

Commit 2c2a69e

Browse files
ncalexanbluemarvin
authored andcommitted
Use substitute-local-geckoview.gradle from Bug 1533465 for local Ge… (Igalia#1579)
* Use `substitute-local-geckoview.gradle` from Bug 1533465 for local GeckoView substitutions. (Igalia#987) See discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1533465. * Handle dependencies substitution in a more standard way Move geckoViewLocalTopobjdir and geckoViewLocalTopsrcdir to local.properties and handle user.properties the same way. * Fix servo variable name
1 parent 1ce2c16 commit 2c2a69e

File tree

5 files changed

+68
-108
lines changed

5 files changed

+68
-108
lines changed

README.md

+11-16
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,19 @@ cp ./extra/wavesdk/build.gradle ./third_party/wavesdk
100100

101101
Make certain to set the build flavor to `wavevrDebug` in Android Studio before building the project.
102102

103-
## Using a custom GeckoView
103+
## Local Development
104104

105-
Create a file called `user.properties` in the top-level project directory. Add a variable called `geckoViewLocalArm` and `geckoViewLocalX86` and set it to the location of your locally built AAR:
105+
### Dependency substitutions
106+
107+
You might be interested in building this project against local versions of some of the dependencies.
108+
This could be done either by using a [local maven repository](https://mozilla-mobile.github.io/android-components/contributing/testing-components-inside-app) (quite cumbersome), or via Gradle's [dependency substitutions](https://docs.gradle.org/current/userguide/customizing_dependency_resolution_behavior.html) (not at all cumbersome!).
109+
110+
Currently, the substitution flow is streamlined for some of the core dependencies via configuration flags in `local.properties`. You can build against a local checkout of the following dependencies by specifying their local paths:
111+
- [GeckoView](https://hg.mozilla.org/mozilla-central), specifying its path via `dependencySubstitutions.geckoviewTopsrcdir=/path/to/mozilla-central` (and, optionally, `dependencySubstitutions.geckoviewTopobjdir=/path/to/topobjdir`). See [Bug 1533465](https://bugzilla.mozilla.org/show_bug.cgi?id=1533465).
112+
- This assumes that you have built, packaged, and published your local GeckoView -- but don't worry, the dependency substitution script has the latest instructions for doing that.
113+
114+
Do not forget to run a Gradle sync in Android Studio after changing `local.properties`. If you specified any substitutions, they will be reflected in the modules list, and you'll be able to modify them from a single Android Studio window.
106115

107-
```ini
108-
geckoViewLocalArm=/path/to/your/build/geckoview-nightly-armeabi-v7a-64.0.20180924100359.aar
109-
geckoViewLocalX86=/path/to/your/build/geckoview-nightly-x86-64.0.20180924100359.aar
110-
```
111116

112117
## Install dev and production builds on device simultaneously
113118

@@ -142,16 +147,6 @@ npm run compress
142147

143148
Enable [USB Remote Debugging](https://github.com/MozillaReality/FirefoxReality/wiki/Developer-Info#remote-debugging) on the device.
144149

145-
### `Could not get unknown property 'geckoViewLocal' for build 'FirefoxReality'[...]`
146-
147-
```bash
148-
./mach build
149-
./mach package
150-
./mach android archive-geckoview
151-
find $objdir -name *.aar
152-
echo "geckoViewLocalArm=$objdir/gradle/build/mobile/android/geckoview/outputs/aar/geckoview-official-withGeckoBinaries-noMinApi-release.aar" > $FirefoxReality/user.properties
153-
```
154-
155150
### **`Firefox > Web Developer > WebIDE > Performance`** gets stuck with greyed out "stop and show profile"
156151

157152
Restart FxR and close and re-open the WebIDE page.

app/build.gradle

+25-21
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ def getGitHash = { ->
1212
}
1313

1414
def getCrashRestartDisabled = { ->
15-
if (gradle.hasProperty("disableCrashRestart")) {
16-
return gradle.disableCrashRestart
15+
if (gradle.hasProperty("userProperties.disableCrashRestart")) {
16+
return gradle."userProperties.disableCrashRestart"
1717
}
1818
return "false"
1919
}
2020

2121
def getDevApplicationIdSuffix = { ->
22-
if (gradle.hasProperty("simultaneousDevProduction")) {
23-
return gradle.simultaneousDevProduction == "true" ? ".dev" : ""
22+
if (gradle.hasProperty("userProperties.simultaneousDevProduction")) {
23+
return gradle."userProperties.simultaneousDevProduction" == "true" ? ".dev" : ""
2424
}
2525
return ""
2626
}
2727

2828
def getUseDebugSigningOnRelease = { ->
29-
if (gradle.hasProperty("useDebugSigningOnRelease")) {
30-
return gradle.useDebugSigningOnRelease == "true"
29+
if (gradle.hasProperty("userProperties.useDebugSigningOnRelease")) {
30+
return gradle."userProperties.useDebugSigningOnRelease" == "true"
3131
}
3232
return false
3333
}
@@ -59,7 +59,7 @@ android {
5959
}
6060
}
6161

62-
if (gradle.hasProperty('taskclusterBuild')) {
62+
if (gradle.hasProperty('userProperties.taskclusterBuild')) {
6363
project.archivesBaseName = "FirefoxReality-$defaultConfig.versionName-$generatedVersionCode"
6464
defaultConfig.versionCode = generatedVersionCode
6565
} else {
@@ -476,29 +476,33 @@ if (findProject(':wavesdk')) {
476476
}
477477
}
478478

479-
if (findProject(':geckoview-local')) {
480-
dependencies {
481-
implementation project(':geckoview-local')
482-
implementation deps.snakeyaml
483-
}
484-
} else {
485-
dependencies {
486-
// To see what the latest geckoview-nightly version is go here:
487-
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/geckoview-nightly-armeabi-v7a/
488-
armImplementation deps.gecko_view.nightly_armv7a
489-
arm64Implementation deps.gecko_view.nightly_arm64
490-
x86_64Implementation deps.gecko_view.nightly_x86_64
491-
}
479+
dependencies {
480+
// To see what the latest geckoview-nightly version is go here:
481+
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/geckoview-nightly-armeabi-v7a/
482+
armImplementation deps.gecko_view.nightly_armv7a
483+
arm64Implementation deps.gecko_view.nightly_arm64
484+
x86_64Implementation deps.gecko_view.nightly_x86_64
492485
}
493486

487+
if (gradle.hasProperty('geckoViewLocalArm') || gradle.hasProperty('geckoViewLocalX86')) {
488+
throw new GradleException("geckoViewLocal{Arm,X86} are deprecated: use geckoViewLocalTopsrcdir and geckoViewLocalTopobjdir")
489+
}
490+
491+
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopsrcdir')) {
492+
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopobjdir')) {
493+
ext.topobjdir = gradle."localProperties.dependencySubstitutions.geckoviewTopobjdir"
494+
}
495+
ext.topsrcdir = gradle."localProperties.dependencySubstitutions.geckoviewTopsrcdir"
496+
apply from: "${topsrcdir}/substitute-local-geckoview.gradle"
497+
}
494498

495499
// -------------------------------------------------------------------------------------------------
496500
// Dynamically set versionCode (See tools/build/versionCode.gradle
497501
// -------------------------------------------------------------------------------------------------
498502

499503
android.applicationVariants.all { variant ->
500504
def buildType = variant.buildType.name
501-
if (gradle.hasProperty('taskclusterBuild')) {
505+
if (gradle.hasProperty('userProperties.taskclusterBuild')) {
502506
def versionCode = generatedVersionCode
503507

504508
// The Google Play Store does not allow multiple APKs for the same app that all have the

geckoview-local/build.gradle

-45
This file was deleted.

servo/build.gradle

+2-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,8 @@ dependencies {
2424
implementation fileTree(include: ['*.jar'], dir: 'libs')
2525
}
2626

27-
if (findProject(':geckoview-local')) {
28-
dependencies {
29-
compileOnly project(':geckoview-local')
30-
}
31-
} else {
32-
dependencies {
33-
compileOnly deps.gecko_view.nightly_armv7a
34-
}
27+
dependencies {
28+
compileOnly deps.gecko_view.nightly_armv7a
3529
}
3630

3731
if (gradle.hasProperty('servoViewLocal')) {

settings.gradle

+30-18
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,38 @@ if (wavebuild.exists()) {
77
project(':wavesdk').projectDir = new File('third_party/wavesdk/')
88
}
99

10-
def userPropertiesFile = new File('user.properties')
11-
if (userPropertiesFile.exists()) {
12-
println("Loading user.properties")
13-
def props = new Properties()
14-
userPropertiesFile.withInputStream {
15-
props.load(it)
16-
}
17-
props.each { prop ->
18-
println(prop.key + " = " + prop.value)
19-
gradle.ext.set(prop.key, prop.value)
20-
}
21-
if (gradle.hasProperty('geckoViewLocalArm') || gradle.hasProperty('geckoViewLocalX86')) {
22-
println("Using local build of geckoview")
23-
include ':geckoview-local'
24-
project(':geckoview-local').projectDir = new File('geckoview-local')
10+
Properties userProperties = null;
11+
if (file('user.properties').canRead()) {
12+
userProperties = new Properties()
13+
userProperties.load(file('user.properties').newDataInputStream())
14+
logger.lifecycle('Local configuration: loaded user.properties')
15+
} else {
16+
logger.lifecycle('Local configuration: absent user.properties; proceeding as normal.')
17+
}
18+
19+
if (userProperties != null) {
20+
userProperties.each { prop ->
21+
gradle.ext.set("userProperties.${prop.key}", prop.value)
22+
logger.lifecycle("\tuserProperties.${prop.key}" + '=' + prop.value)
2523
}
26-
if (gradle.hasProperty('enableServo')) {
27-
println("Including :servo")
24+
if (gradle.hasProperty('userProperties.enableServo')) {
25+
logger.lifecycle('Including Servo.')
2826
include ':servo'
2927
}
28+
}
29+
30+
Properties localProperties = null;
31+
if (file('local.properties').canRead()) {
32+
localProperties = new Properties()
33+
localProperties.load(file('local.properties').newDataInputStream())
34+
logger.lifecycle('Local configuration: loaded local.properties')
3035
} else {
31-
println("FILE DOESN'T EXIST")
36+
logger.lifecycle('Local configuration: absent local.properties; proceeding as normal.')
37+
}
38+
39+
if (localProperties != null) {
40+
localProperties.each { prop ->
41+
gradle.ext.set("localProperties.${prop.key}", prop.value)
42+
logger.lifecycle("\tlocalProperties.${prop.key}" + '=' + prop.value)
43+
}
3244
}

0 commit comments

Comments
 (0)