Commit 468e3e2
Adopt root CMakeLists.txt for builds on Android. (#7289)
Create experimental Gradle plugin using [root
CMakeLists](mapbox/mapbox-sdk#5451) and speeding
up Android builds with mapbox-sdk.
Core optimization lies in using the same build directory for all the
cmake builds invoked by gradle.
To enable the plugin composite build should declare
`BUILD_WITH_EXPERIMENTAL_MAPBOX_SDK_PLUGIN` in the local.properties.
Example of adoption is in
mapbox/navigation#10656.
**Important note** - plugin is only applied when it's enabled in
local.properties of the compositing project (e.g. qa-test-app). Normal
builds are not changed yet. Example of succesful CD.yml job running
current configuration :
https://github.com/mapbox/mapbox-sdk/actions/runs/18402724251 / [Slack
notification](https://mapbox.slack.com/archives/C081UT1PV99/p1760092050026619).
Plugin also consolidates all the other cmake externalNative settings
currently set in build.gradle.kts. After full migration all the settings
will be removed.
With the plugin qa-test-app composite build with mapbox-sdk compiles
3775 files according to ccache : `Cacheable calls: 3775 / 3921
(96.28%)`.
Without the plugin total number of compiled files is much larger, around
17000, due to every mapbox-sdk module compiling all of its dependencies
in a separate build directories. Hence common/gl-native/nav-native are
build multiple times in nav-sdk-cpp.
It fully works for composite builds building mapbox-sdk from source,
e.g. qa-test-app or Dash (builds in Dash are broken currently due to
other reasons, tracked in
https://mapbox.atlassian.net/browse/NAVAND-6335).
**Build time** :
Build time of qa-test-app (single ABI arm64) with the empty ccache :
`BUILD SUCCESSFUL in 16m 1s`.
ccache -s : `Cacheable calls: 3775 / 3921 (96.28%)`
Build time of qa-test-app (full ABI set) with the empty ccache : `BUILD
SUCCESSFUL in 53m 10s`
ccaches -s : `Cacheable calls: 15105 / 15689 (96.28%)`
**Implementation details** :
Plugin sets single build directory under `mapbox-sdk/build/.cxx/` for
all modules, builds create subdirectories formatted as
`BUILD_TYPE/BUILD_HASH/ABI/`. Output binaries are placed under
`BUILD_TYPE/BUILD_HASH/obj/ABI`. Cmake is invoked by gradle multiple
times for different modules - consecutive invokations reuse already
compiled targets and this is the root cause of the optimization.
For optimization to work several conditions **must be met** :
- projects should **not** declare different cmake arguments in gradle
configs. Otherwise, Gradle creates different HASH for the build thus
breaking the optimization. Currently some of the projects actually do
that - to migrate library builds fully to the new plugin we need to move
all the arguments to projects CMakeLists.
- parallel Gradle invokations of tasks configuring cmake does not work.
I've disabled `org.gradle.parallel` for common / maps-android to avoid
this. Other projects did not have parallelism enabled. Alternative and
better solution will be to disable parallelism only to the cmake
configuration tasks, it's possible to do with [Gradle Build
Services](https://docs.gradle.org/current/userguide/build_services.html),
[example](https://kantis.github.io/posts/preventing-gradle-task-parallelism/).
This will speed builds even further.
Next steps (TODO - cut tickets) :
- align cmake arguments that projects configure thru build.gradle files
- test the plugin for several weeks to make sure there are no
runtime/build issues (we test frequently working on Coordination layer
with @dzinad @kiryldz and @anhnguyen1618)
- migrate projects one by one, starting from nav-sdk-cpp as it's
building all the other libraries and build times are the longest of all
projects
Supersedes mapbox/mapbox-sdk#5767, solves
https://mapbox.atlassian.net/browse/SDKCI-410.
cc @mapbox/robocar
cc @mapbox/sdk-ci
cc @mapbox/core-sdk
cc @mapbox/nav-core-sdk
cc @mapbox/cpp-guild
cc @mapbox/3d-live-navigation
cc @mapbox/search-sdk-native
cc @mapbox/gl-native
cc @mapbox/maps-android
cc @mapbox/navnative
---------
Co-authored-by: Aliaksei Charkes <[email protected]>
GitOrigin-RevId: b45ac596a8aec2c562dd7c7ed5d1793d91952ec11 parent 8c247e4 commit 468e3e2
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments