diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/build.gradle | 60 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/gradle.properties | 4 |
2 files changed, 64 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index 6602d919a3..dd25a8d7b4 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -29,6 +29,66 @@ android { buildConfigField "String", "GIT_REVISION_SHORT", String.format("\"%s\"", getGitRevision()) } + defaultPublishConfig project.hasProperty("mapbox.buildtype") ? project.getProperty("mapbox.buildtype") : "debug" + + // We sometimes want to invoke Gradle without building a native dependency, e.g. when we just want + // to invoke the Java tests. When we explicitly specify an ABI of 'none', no native dependencies are + // added. When another ABI is specified explicitly, we're just going to build that ABI. In all other + // cases, all ABIs are built. + // When invoking from the command line, set `-Pmapbox.abis=...` to only build the desired architectures. + // When building from Android Studio, gradle.properties sets `android.buildOnlyTargetAbi=true` so that + // only the architecture for the device you're running on gets built. + def abi = 'all' + if (!project.hasProperty('android.injected.invoked.from.ide')) { + // Errors when the user invokes Gradle from the command line and didn't set mapbox.abis + abi = project.getProperty("mapbox.abis") + } + + if (abi != 'none') { + externalNativeBuild { + cmake { + path "../../../CMakeLists.txt" + } + } + } + + defaultConfig { + if (abi != 'none') { + externalNativeBuild { + cmake { + arguments "-DANDROID_TOOLCHAIN=clang" + arguments "-DANDROID_STL=c++_static" + arguments "-DANDROID_CPP_FEATURES=rtti;exceptions" + arguments "-DMBGL_PLATFORM=android" + arguments "-DMASON_PLATFORM=android" + arguments "-DNodeJS_EXECUTABLE=" + rootProject.ext.node + arguments "-Dnpm_EXECUTABLE=" + rootProject.ext.npm + + // Enable ccache if the user has installed it. + if (rootProject.ext.ccache?.trim()) { + arguments "-DANDROID_CCACHE=" + rootProject.ext.ccache + // ccache splits up the compile command until multiple invocations and uses -E + // with one of them, and clang doesn't like unused arguments in that case. + cFlags "-Qunused-arguments" + cppFlags "-Qunused-arguments" + } + + targets "mapbox-gl" + targets "example-custom-layer" + if (project.hasProperty("mapbox.with_test")) { + targets "mbgl-test" + } + + if (abi != 'all') { + abiFilters abi.split(' ') + } else { + abiFilters "armeabi", "armeabi-v7a", "mips", "x86", "arm64-v8a", "x86_64" + } + } + } + } + } + // avoid naming conflicts, force usage of prefix resourcePrefix 'mapbox_' diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index dac39fa60a..13a5f1032a 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -14,3 +14,7 @@ POM_DEVELOPER_NAME=Mapbox POM_NAME=Mapbox Android SDK POM_ARTIFACT_ID=mapbox-android-sdk POM_PACKAGING=aar + +# Only build native dependencies for the current ABI +# See https://code.google.com/p/android/issues/detail?id=221098#c20 +android.buildOnlyTargetAbi=true |