Bug 1894737 - Building geckoview spends time evaluating unrelated gradle projects. r=firefox-build-system-reviewers,geckoview-reviewers,android-reviewers,nalexander,ohall,jonalmeida

Add option to run specific subprojects (fenix/focus/geckoview_example) by adding one of the following to mozconfig:

```
ac_add_options --enable-android-subproject=fenix
ac_add_options --enable-android-subproject=focus
ac_add_options --enable-android-subproject=geckoview_example
```

Differential Revision: https://phabricator.services.mozilla.com/D218564
This commit is contained in:
Aaditya Dhingra 2024-11-06 17:36:23 +00:00
parent 2c69c8e636
commit 622339ba46
4 changed files with 113 additions and 23 deletions

View File

@ -72,6 +72,12 @@ def gradle_android_build_config():
geckoview_example=namespace(
variant=variant("debug"),
),
fenix=namespace(
variant=variant("debug"),
),
focus=namespace(
variant=variant("debug"),
),
)
@ -340,8 +346,8 @@ option(
imply_option("--disable-android-bundle", False, when="--enable-address-sanitizer")
@depends(gradle_android_build_config, "--disable-android-bundle")
def gradle_android_archive_geckoview_tasks(build_config, aab_enabled):
@depends(gradle_android_build_config)
def gradle_android_archive_geckoview_tasks(build_config):
"""Gradle tasks run by |mach android archive-geckoview|."""
tasks = [
"geckoview:assemble{geckoview.variant.name}".format(
@ -350,12 +356,6 @@ def gradle_android_archive_geckoview_tasks(build_config, aab_enabled):
"geckoview:assemble{geckoview.variant.name}AndroidTest".format(
geckoview=build_config.geckoview
),
"test_runner:assemble{geckoview_example.variant.name}".format(
geckoview_example=build_config.geckoview_example
),
"geckoview_example:assemble{geckoview_example.variant.name}".format(
geckoview_example=build_config.geckoview_example
),
"messaging_example:assemble{geckoview_example.variant.name}".format(
geckoview_example=build_config.geckoview_example
),
@ -367,6 +367,25 @@ def gradle_android_archive_geckoview_tasks(build_config, aab_enabled):
),
"exoplayer2:publishDebugPublicationToMavenRepository",
]
return tasks
set_config(
"GRADLE_ANDROID_ARCHIVE_GECKOVIEW_TASKS", gradle_android_archive_geckoview_tasks
)
@depends(gradle_android_build_config, "--disable-android-bundle")
def gradle_android_archive_geckoview_subproject_tasks(build_config, aab_enabled):
"""Gradle tasks run by |mach android archive-geckoview| if just building geckoview."""
tasks = [
"test_runner:assemble{geckoview_example.variant.name}".format(
geckoview_example=build_config.geckoview_example
),
"geckoview_example:assemble{geckoview_example.variant.name}".format(
geckoview_example=build_config.geckoview_example
),
]
if aab_enabled:
tasks += [
@ -381,7 +400,47 @@ def gradle_android_archive_geckoview_tasks(build_config, aab_enabled):
set_config(
"GRADLE_ANDROID_ARCHIVE_GECKOVIEW_TASKS", gradle_android_archive_geckoview_tasks
"GRADLE_ANDROID_ARCHIVE_GECKOVIEW_SUBPROJECT_TASKS",
gradle_android_archive_geckoview_subproject_tasks,
)
@depends(gradle_android_build_config, "--disable-android-bundle")
def gradle_android_archive_fenix_subproject_tasks(build_config, aab_enabled):
"""Gradle tasks run by |mach android archive-geckoview| if just building fenix."""
tasks = [
"fenix:assemble{fenix.variant.name}".format(fenix=build_config.fenix),
]
if aab_enabled:
tasks += [
"fenix:bundle{fenix.variant.name}".format(fenix=build_config.fenix),
]
return tasks
set_config(
"GRADLE_ANDROID_ARCHIVE_FENIX_SUBPROJECT_TASKS",
gradle_android_archive_fenix_subproject_tasks,
)
@depends(gradle_android_build_config, "--disable-android-bundle")
def gradle_android_archive_focus_subproject_tasks(build_config, aab_enabled):
"""Gradle tasks run by |mach android archive-geckoview| if just building focus."""
tasks = [
"focus-android:assemble{focus.variant.name}".format(focus=build_config.focus),
]
if aab_enabled:
tasks += [
"focus-android:bundle{focus.variant.name}".format(focus=build_config.focus),
]
return tasks
set_config(
"GRADLE_ANDROID_ARCHIVE_FOCUS_SUBPROJECT_TASKS",
gradle_android_archive_focus_subproject_tasks,
)

View File

@ -214,9 +214,15 @@ def create_maven_archive(topobjdir):
)
@CommandArgument("args", nargs=argparse.REMAINDER)
def android_archive_geckoview(command_context, args):
tasks = command_context.substs["GRADLE_ANDROID_ARCHIVE_GECKOVIEW_TASKS"]
subproject = command_context.substs.get("MOZ_ANDROID_SUBPROJECT")
if subproject in (None, "geckoview_example"):
tasks += command_context.substs[
"GRADLE_ANDROID_ARCHIVE_GECKOVIEW_SUBPROJECT_TASKS"
]
ret = gradle(
command_context,
command_context.substs["GRADLE_ANDROID_ARCHIVE_GECKOVIEW_TASKS"] + args,
tasks + args,
verbose=True,
)

View File

@ -57,6 +57,26 @@ option(
set_config("MOZ_ANDROID_GECKOVIEW_LITE", True, when="--enable-geckoview-lite")
option(
"--enable-android-subproject",
choices=(
"fenix",
"focus",
"geckoview_example",
),
nargs="?",
help="Build a subproject of android. Possible options: fenix/focus/geckoview_example",
)
@depends("--enable-android-subproject")
def android_subproject(value):
if value:
return value[0]
set_config("MOZ_ANDROID_SUBPROJECT", android_subproject)
imply_option("MOZ_NORMANDY", False)
imply_option("MOZ_SERVICES_HEALTHREPORT", True)
imply_option("MOZ_GECKOVIEW_HISTORY", True)

View File

@ -46,26 +46,31 @@ System.setProperty('android.home', gradle.mozconfig.substs.ANDROID_SDK_ROOT)
include ':annotations', ':messaging_example', ':port_messaging_example'
include ':geckoview'
include ':geckoview_example'
include ':test_runner'
include ':exoplayer2'
include ':android-components'
include ':samples-browser'
include ':fenix'
include ':mozilla-lint-rules'
include ':focus-android'
include ':service-telemetry'
include ':android-components'
project(':annotations').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/annotations")
project(':geckoview').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/geckoview")
project(':geckoview_example').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/geckoview_example")
project(':test_runner').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/test_runner")
project(':exoplayer2').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/exoplayer2")
project(':android-components').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/android-components")
project(':samples-browser').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/android-components/samples/browser")
project(':fenix').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/fenix/app")
project(':service-telemetry').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/focus-android/service-telemetry")
project(':focus-android').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/focus-android/app")
if (!gradle.mozconfig.substs.MOZ_ANDROID_SUBPROJECT || gradle.mozconfig.substs.MOZ_ANDROID_SUBPROJECT == "fenix") {
include ':fenix'
project(':fenix').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/fenix/app")
}
if (!gradle.mozconfig.substs.MOZ_ANDROID_SUBPROJECT || gradle.mozconfig.substs.MOZ_ANDROID_SUBPROJECT == "focus") {
include ':focus-android'
project(':focus-android').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/focus-android/app")
}
if (!gradle.mozconfig.substs.MOZ_ANDROID_SUBPROJECT || gradle.mozconfig.substs.MOZ_ANDROID_SUBPROJECT == "geckoview_example") {
include ':samples-browser'
include ':geckoview_example'
include ':test_runner'
project(':test_runner').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/test_runner")
project(':geckoview_example').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/geckoview_example")
project(':samples-browser').projectDir = new File("${gradle.mozconfig.topsrcdir}/mobile/android/android-components/samples/browser")
}
if (hasProperty("androidFormatLintTest")) {
include ':androidFormatLintTest'