commit fc61b3ec36ed86a3f6252172f3774bd51f004080
parent 5692b1b549030f7788a56ce3a95cf836e06c2115
Author: Mark Hammond <mhammond@skippinet.com.au>
Date: Tue, 25 Nov 2025 20:56:29 +0000
Bug 1960941 - Update m-c gradle files to optionally work with a local app-services. r=nalexander,geckoview-reviewers,android-reviewers
This will allow mozilla-central to build app services locally when it
is inside mozilla-central. It adds a new config option, `--with-appservices-in-tree`,
which takes a bool, default value is based on whether app-services is actually on
the file system. This provides a MOZ_APPSERVICES_IN_TREE config value.
Differential Revision: https://phabricator.services.mozilla.com/D245762
Diffstat:
12 files changed, 103 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -238,6 +238,10 @@ mobile/android/**/.kotlin
mobile/android/**/bin
mobile/android/**/generated
+# app-services build artifacts.
+services/app-services/tools/nimbus-gradle-plugin/.gradle
+services/app-services/tools/nimbus-gradle-plugin/build
+
# Android local.properties
mobile/android/**/local.properties
diff --git a/.hgignore b/.hgignore
@@ -235,6 +235,10 @@ _OPT\.OBJ/
^mobile/android/.*/bin
^mobile/android/.*/generated
+# app-services build artifacts.
+services/app-services/tools/nimbus-gradle-plugin/.gradle
+services/app-services/tools/nimbus-gradle-plugin/build
+
# Android local.properties
^mobile/android/.*/local.properties
diff --git a/mobile/android/android-components/settings.gradle b/mobile/android/android-components/settings.gradle
@@ -39,6 +39,10 @@ dependencyResolutionManagement {
ext.topsrcdir = rootProject.projectDir.absolutePath.minus("mobile/android/android-components")
+if (gradle.ext.mozconfig.substs.MOZ_APPSERVICES_IN_TREE) {
+ apply from: file("${topsrcdir}/services/app-services/settings.gradle")
+}
+
apply from: file('../shared-settings.gradle')
apply from: file('../autopublish-settings.gradle')
diff --git a/mobile/android/autopublish-settings.gradle b/mobile/android/autopublish-settings.gradle
@@ -71,10 +71,40 @@ gradle.settingsEvaluated {
gradle.projectsLoaded { ->
gradle.rootProject.allprojects {
- // Allow local appservices substitution in each project.
- if (gradle.hasProperty("localProperties.autoPublish.application-services.dir")) {
- def appServicesSrcDir = gradle."localProperties.autoPublish.application-services.dir"
- apply from: rootProject.file("${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle")
+ if (gradle.ext.mozconfig.substs.MOZ_APPSERVICES_IN_TREE) {
+ // in tree, so we update our legacy "external" dep name to a local project.
+ // ie, `"${ApplicationServicesConfig.groupId}:syncmanager:${ApplicationServicesConfig.version}"`
+ // becomes `project(':syncmanager')`
+ configurations.all { config ->
+ if (config.isCanBeResolved()) {
+ config.resolutionStrategy { strategy ->
+ dependencySubstitution {
+ all { dependency ->
+ // We only care about substituting for a module, not a project.
+ if (!(dependency.requested instanceof ModuleComponentSelector)) {
+ return
+ }
+ def group = dependency.requested.group
+ if (group == 'org.mozilla.appservices' || group == 'org.mozilla.appservices.nightly') {
+ def name = dependency.requested.module
+ // What to do about full-megazord-libsForTests is tbd - it's a convenience;
+ // but we don't lose test coverage, just local test convience.
+ if (name == "full-megazord-libsForTests") {
+ name = "full-megazord"
+ }
+ dependency.useTarget(project(":${name}"))
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // Allow local appservices substitution in each project.
+ if (gradle.hasProperty("localProperties.autoPublish.application-services.dir")) {
+ def appServicesSrcDir = gradle."localProperties.autoPublish.application-services.dir"
+ apply from: rootProject.file("${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle")
+ }
}
// Allow local Glean substitution in each project.
diff --git a/mobile/android/fenix/settings.gradle b/mobile/android/fenix/settings.gradle
@@ -44,6 +44,10 @@ ext.topsrcdir = rootProject.projectDir.absolutePath.minus("mobile/android/fenix"
apply from: file('../shared-settings.gradle')
apply from: file('../autopublish-settings.gradle')
+if (gradle.ext.mozconfig.substs.MOZ_APPSERVICES_IN_TREE) {
+ apply from: file("${topsrcdir}/services/app-services/settings.gradle")
+}
+
include ':app'
include ':mozilla-detekt-rules'
include ':benchmark'
diff --git a/mobile/android/focus-android/settings.gradle b/mobile/android/focus-android/settings.gradle
@@ -43,6 +43,10 @@ ext.topsrcdir = rootProject.projectDir.absolutePath.minus("mobile/android/focus-
apply from: file('../shared-settings.gradle')
apply from: file('../autopublish-settings.gradle')
+if (gradle.ext.mozconfig.substs.MOZ_APPSERVICES_IN_TREE) {
+ apply from: file("${topsrcdir}/services/app-services/settings.gradle")
+}
+
include ':app'
gradle.projectsLoaded { ->
diff --git a/mobile/android/installer/Makefile.in b/mobile/android/installer/Makefile.in
@@ -84,3 +84,7 @@ endif
ifdef MOZ_CLANG_RT_ASAN_LIB_PATH
DEFINES += -DMOZ_CLANG_RT_ASAN_LIB=$(notdir $(MOZ_CLANG_RT_ASAN_LIB_PATH))
endif
+
+ifdef MOZ_APPSERVICES_IN_TREE
+DEFINES += -DMOZ_APPSERVICES_IN_TREE=1
+endif
diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in
@@ -71,6 +71,13 @@
# This should be MOZ_CHILD_PROCESS_NAME, but that has a "lib/" prefix.
@BINPATH@/@MOZ_CHILD_PROCESS_NAME@
+#ifdef MOZ_APPSERVICES_IN_TREE
+; This is mis-placed as it will cause the megazord to be shipped with geckoview, which
+; isn't what we want in general, but seems fine for now.
+; TODO: work out a better way of shipping the megazord where we need it, but not where we do not.
+@BINPATH@/@DLL_PREFIX@megazord@DLL_SUFFIX@
+#endif
+
#ifdef MOZ_ANDROID_GOOGLE_VR
@BINPATH@/@DLL_PREFIX@gvr@DLL_SUFFIX@
#endif
diff --git a/mobile/android/moz.configure b/mobile/android/moz.configure
@@ -139,6 +139,20 @@ imply_option("MOZ_APP_VENDOR", "Mozilla")
imply_option("MOZ_APP_ID", "{aa3c5121-dab2-40e2-81ca-7ea25febc110}")
imply_option("BROWSER_CHROME_URL", "chrome://geckoview/content/geckoview.xhtml")
+option(
+ "--enable-appservices-in-tree",
+ help="Enables building from an in-tree app-services",
+)
+
+
+@depends("--enable-appservices-in-tree")
+def enable_appservices_in_tree(value):
+ if value:
+ return True
+
+
+set_config("MOZ_APPSERVICES_IN_TREE", enable_appservices_in_tree)
+
@depends(target)
def check_target(target):
diff --git a/mobile/android/shared-settings.gradle b/mobile/android/shared-settings.gradle
@@ -45,6 +45,8 @@ class Config {
public final Integer compileSdkVersion
public final Integer minSdkVersion
public final Integer targetSdkVersion
+ public final String ndkVersion
+
Config(
String componentsVersion,
@@ -52,7 +54,8 @@ class Config {
Integer jvmTargetCompatibility,
Integer compileSdkVersion,
Integer minSdkVersion,
- Integer targetSdkVersion
+ Integer targetSdkVersion,
+ String ndkVersion
) {
this.componentsVersion = componentsVersion
this.componentsGroupId = componentsGroupId
@@ -60,6 +63,7 @@ class Config {
this.compileSdkVersion = compileSdkVersion
this.minSdkVersion = minSdkVersion
this.targetSdkVersion = targetSdkVersion
+ this.ndkVersion = ndkVersion
}
}
@@ -141,6 +145,8 @@ gradle.projectsLoaded { ->
} else if (gradle.hasProperty("localProperties.branchBuild.android-components.version")) {
version = gradle.getProperty("localProperties.branchBuild.android-components.version")
}
+ // get the ndk version from the external build environment.
+ def ndkVersion = "${gradle.mozconfig.substs.ANDROID_NDK_MAJOR_VERSION}.${gradle.mozconfig.substs.ANDROID_NDK_MINOR_VERSION}"
// Wait until root project is "loaded" before we set "config"
// Note that since this is set on "rootProject.ext", it will be "in scope" during the evaluation of all projects'
@@ -151,7 +157,8 @@ gradle.projectsLoaded { ->
configData.jvmTargetCompatibility,
configData.compileSdkVersion,
configData.minSdkVersion,
- configData.targetSdkVersion
+ configData.targetSdkVersion,
+ ndkVersion
)
gradle.rootProject.ext.buildConfig = buildconfig
diff --git a/services/moz.build b/services/moz.build
@@ -14,6 +14,17 @@ DIRS += [
"settings",
]
+# A bit of a chicken-and-egg situation here - MOZ_APPSERVICES_IN_TREE allows
+# us to reference files not yet in the tree. Other monorepo related patches
+# actually adds them, after which it is possible to enable the flag.
+if CONFIG["MOZ_APPSERVICES_IN_TREE"]:
+ DIRS += [
+ "app-services/components/support/nimbus-fml",
+ "app-services/megazords/full",
+ "app-services/megazords/fenix-dylib",
+ "app-services/tools/embedded-uniffi-bindgen",
+ ]
+
# The automation dir is only included in nightlies and debug
if not CONFIG["RELEASE_OR_BETA"] or CONFIG["MOZ_DEBUG"]:
DIRS += ["automation"]
diff --git a/settings.gradle b/settings.gradle
@@ -38,6 +38,10 @@ ext.topsrcdir = rootProject.projectDir.absolutePath
apply from: "${topsrcdir}/mobile/android/shared-settings.gradle"
apply from: "${topsrcdir}/mobile/android/autopublish-settings.gradle"
+if (gradle.ext.mozconfig.substs.MOZ_APPSERVICES_IN_TREE) {
+ apply from: "${topsrcdir}/services/app-services/settings.gradle"
+}
+
// Set the Android SDK location. This is the *least specific* mechanism, which
// is unfortunate: we'd prefer to use the *most specific* mechanism. That is,
// local.properties (first 'sdk.dir', then 'android.dir') and then the