summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-05-29 09:44:25 +0200
committerTobrun <tobrun.van.nuland@gmail.com>2019-05-29 11:51:39 +0200
commit05e194614fff1527f812c73aa0f28d4205908013 (patch)
treea9a5912fac9516a2e8456b656302986f98c155a5 /platform
parentff980010d71fed4e7787f32e50da86d0d4db45cb (diff)
downloadqtlocation-mapboxgl-05e194614fff1527f812c73aa0f28d4205908013.tar.gz
[android] - consolidate native build setup into one gradle configuration file
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/build.gradle83
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/build.gradle66
-rw-r--r--platform/android/gradle/native-build.gradle70
3 files changed, 81 insertions, 138 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index 7909148ff4..0a4f4147d0 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -1,6 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: "com.jaredsburrows.license"
apply plugin: 'kotlin-android'
+apply from: "${rootDir}/gradle/native-build.gradle"
dependencies {
lintChecks project(":MapboxGLAndroidSDKLint")
@@ -32,83 +33,18 @@ android {
buildConfigField "String", "MAPBOX_SDK_VERSION", String.format("\"%s\"", project.VERSION_NAME)
buildConfigField "String", "MAPBOX_VERSION_STRING", String.format("\"Mapbox/%s\"", project.VERSION_NAME)
buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT", String.format("\"mapbox-maps-android/%s\"", project.VERSION_NAME)
+ consumerProguardFiles 'proguard-rules.pro'
}
- 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 or to override the device default, 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') || project.hasProperty("mapbox.abis")) {
- // 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"
- version "3.10.2"
- }
- }
+ // build native libraries
+ List nativeTargets = ["mapbox-gl"]
+ if (project.hasProperty("mapbox.with_test")) {
+ nativeTargets.add("mbgl-test")
}
-
- // Allow determining the C++ STL we're using when building Mapbox GL.
- def stl = 'c++_static'
- if (project.hasProperty("mapbox.stl")) {
- stl = project.getProperty("mapbox.stl")
- }
-
- defaultConfig {
- if (abi != 'none') {
- externalNativeBuild {
- cmake {
- arguments "-DANDROID_TOOLCHAIN=clang"
- arguments "-DANDROID_STL=" + stl
- arguments "-DANDROID_CPP_FEATURES=exceptions"
- arguments "-DMBGL_PLATFORM=android"
- arguments "-DMASON_PLATFORM=android"
- arguments "-DNodeJS_EXECUTABLE=" + node
- arguments "-Dnpm_EXECUTABLE=" + npm
-
- // Enable ccache if the user has installed it.
- if (ccache?.trim()) {
- arguments "-DANDROID_CCACHE=" + ccache
- }
-
- cFlags "-Qunused-arguments"
- cppFlags "-Qunused-arguments"
-
- targets "mapbox-gl"
-
- if (project.hasProperty("mapbox.with_test")) {
- targets "mbgl-test"
- }
-
- if (project.hasProperty("mapbox.with_benchmark")) {
- targets "mbgl-benchmark"
- }
-
- if (abi != 'all') {
- abiFilters abi.split(' ')
- } else {
- abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
- }
- }
- }
- }
-
- // proguard config for .aar
- consumerProguardFiles 'proguard-rules.pro'
+ if (project.hasProperty("mapbox.with_benchmark")) {
+ nativeTargets.add("mbgl-benchmark")
}
+ nativeBuild(nativeTargets)
// avoid naming conflicts, force usage of prefix
resourcePrefix 'mapbox_'
@@ -160,7 +96,6 @@ configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
all*.exclude group: 'commons-collections', module: 'commons-collections'
}
-
apply from: "${rootDir}/gradle/gradle-javadoc.gradle"
apply from: "${rootDir}/gradle/gradle-checkstyle.gradle"
apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index 827f568540..ca280436ea 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
+apply from: "${rootDir}/gradle/native-build.gradle"
android {
compileSdkVersion androidVersions.compileSdkVersion
@@ -17,70 +18,7 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
- 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 or to override the device default, 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') || project.hasProperty("mapbox.abis")) {
- // 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"
- version "3.10.2"
- }
- }
- }
-
- // Allow determining the C++ STL we're using when building Mapbox GL.
- def stl = 'c++_static'
- if (project.hasProperty("mapbox.stl")) {
- stl = project.getProperty("mapbox.stl")
- }
-
- defaultConfig {
- if (abi != 'none') {
- externalNativeBuild {
- cmake {
- arguments "-DANDROID_TOOLCHAIN=clang"
- arguments "-DANDROID_STL=" + stl
- arguments "-DANDROID_CPP_FEATURES=exceptions"
- arguments "-DMBGL_PLATFORM=android"
- arguments "-DMASON_PLATFORM=android"
- arguments "-DNodeJS_EXECUTABLE=" + node
- arguments "-Dnpm_EXECUTABLE=" + npm
-
- // Enable ccache if the user has installed it.
- if (ccache?.trim()) {
- arguments "-DANDROID_CCACHE=" + ccache
- }
-
- cFlags "-Qunused-arguments"
- cppFlags "-Qunused-arguments"
-
- targets "example-custom-layer"
-
- if (abi != 'all') {
- abiFilters abi.split(' ')
- } else {
- abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
- }
- }
- }
- }
- }
+ nativeBuild(["example-custom-layer"])
packagingOptions {
exclude 'META-INF/LICENSE.txt'
diff --git a/platform/android/gradle/native-build.gradle b/platform/android/gradle/native-build.gradle
new file mode 100644
index 0000000000..0c16c379dd
--- /dev/null
+++ b/platform/android/gradle/native-build.gradle
@@ -0,0 +1,70 @@
+ext.nativeBuild = { nativeTargets ->
+ android {
+ 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 or to override the device default, 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') || project.hasProperty("mapbox.abis")) {
+ // 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"
+ version "3.10.2"
+ }
+ }
+ }
+
+ // Allow determining the C++ STL we're using when building Mapbox GL.
+ def stl = 'c++_static'
+ if (project.hasProperty("mapbox.stl")) {
+ stl = project.getProperty("mapbox.stl")
+ }
+
+ defaultConfig {
+ if (abi != 'none') {
+ externalNativeBuild {
+ cmake {
+ arguments "-DANDROID_TOOLCHAIN=clang"
+ arguments "-DANDROID_STL=" + stl
+ arguments "-DANDROID_CPP_FEATURES=exceptions"
+ arguments "-DMBGL_PLATFORM=android"
+ arguments "-DMASON_PLATFORM=android"
+ arguments "-DNodeJS_EXECUTABLE=" + node
+ arguments "-Dnpm_EXECUTABLE=" + npm
+
+ // Enable ccache if the user has installed it.
+ if (ccache?.trim()) {
+ arguments "-DANDROID_CCACHE=" + ccache
+ }
+
+ cFlags "-Qunused-arguments"
+ cppFlags "-Qunused-arguments"
+
+ for (target in nativeTargets) {
+ targets target
+ }
+
+ if (abi != 'all') {
+ abiFilters abi.split(' ')
+ } else {
+ abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file