[android] move build to Android Studio

This commit is contained in:
Konstantin Käfer
2017-03-10 19:14:10 -08:00
parent aed3869cfa
commit 9544dcc483
13 changed files with 213 additions and 317 deletions

193
Makefile
View File

@@ -6,6 +6,8 @@ else
$(error BUILDTYPE must be Debug or Release)
endif
buildtype := $(shell echo "$(BUILDTYPE)" | tr "[A-Z]" "[a-z]")
ifeq ($(shell uname -s), Darwin)
HOST_PLATFORM = macos
HOST_PLATFORM_VERSION = $(shell uname -m)
@@ -450,39 +452,36 @@ test-node: node
#### Android targets ###########################################################
MBGL_ANDROID_ABIS = arm-v5;armeabi;9
MBGL_ANDROID_ABIS += arm-v7;armeabi-v7a;9
MBGL_ANDROID_ABIS += arm-v8;arm64-v8a;21
MBGL_ANDROID_ABIS += x86;x86;9
MBGL_ANDROID_ABIS += x86-64;x86_64;21
MBGL_ANDROID_ABIS += mips;mips;9
MBGL_ANDROID_ABIS = arm-v5;armeabi
MBGL_ANDROID_ABIS += arm-v7;armeabi-v7a
MBGL_ANDROID_ABIS += arm-v8;arm64-v8a
MBGL_ANDROID_ABIS += x86;x86
MBGL_ANDROID_ABIS += x86-64;x86_64
MBGL_ANDROID_ABIS += mips;mips
MBGL_ANDROID_BUILD_DIR = build/android-$1-$3/$(BUILDTYPE)
MBGL_ANDROID_LOCAL_WORK_DIR = /data/local/tmp/core-tests
MBGL_ANDROID_LIBDIR = lib$(if $(filter arm-v8 x86-64,$1),64)
MBGL_ANDROID_DALVIKVM = dalvikvm$(if $(filter arm-v8 x86-64,$1),64,32)
MBGL_ANDROID_APK_SUFFIX = $(if $(filter Release,$(BUILDTYPE)),release-unsigned,debug)
MBGL_ANDROID_CORE_TEST_DIR = $(MBGL_ANDROID_BUILD_DIR)/core-tests
MBGL_ANDROID_CORE_TEST_DIR = platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/$(buildtype)/$2/core-tests
MBGL_ANDROID_GRADLE = ./gradlew --parallel --max-workers=$(JOBS) -Pmapbox.buildtype=$(buildtype)
# Lists all devices, and extracts the identifiers, then obtains the ABI for every one.
# Some devices return \r\n, so we'll have to remove the carriage return before concatenating.
MBGL_ANDROID_ACTIVE_ARCHS = $(shell adb devices | sed '1d;/^\*/d;s/[[:space:]].*//' | xargs -n 1 -I DEV `type -P adb` -s DEV shell getprop ro.product.cpu.abi | tr -d '\r')
.PHONY: android-help
android-help:
@echo
@echo "Available Android architecture targets:"
@echo
@echo " make android-arm-v5-9"
@echo " (android-arm-v5)"
@echo " make android-arm-v7-9"
@echo " (android, android-arm-v7)"
@echo " make android-arm-v8-21"
@echo " (android-arm-v8)"
@echo " make android-mips-9"
@echo " (android-mips)"
@echo " make android-mips-64-21"
@echo " (android-mips-64)"
@echo " make android-x86-9"
@echo " (android-x86)"
@echo " make android-x86-64-21"
@echo " (android-x86-64)"
@echo " make android-arm-v5"
@echo " make android-arm-v7, make android"
@echo " make android-arm-v8"
@echo " make android-mips"
@echo " make android-mips-64"
@echo " make android-x86"
@echo " make android-x86-64"
@echo " make apackage"
@echo
@@ -491,50 +490,30 @@ android-style-code:
node platform/android/scripts/generate-style-code.js
style-code: android-style-code
# Configuration file for running CMake from Gradle within Android Studio.
platform/android/configuration.gradle:
@echo "ext {\n node = '`which node`'\n npm = '`which npm`'\n ccache = '`which ccache`'\n}" > $@
define ANDROID_RULES
# $1 = arm-v7 (short arch)
# $2 = armeabi-v7a (internal arch)
# $3 = 9 (platform version)
$(MBGL_ANDROID_BUILD_DIR)/env.sh: $(BUILD_DEPS) platform/android/scripts/ndk.sh
@mkdir -p $(MBGL_ANDROID_BUILD_DIR)
platform/android/scripts/ndk.sh $1 $2 $3 > $(MBGL_ANDROID_BUILD_DIR)/env.sh.tmp && \
mv $(MBGL_ANDROID_BUILD_DIR)/env.sh.tmp $(MBGL_ANDROID_BUILD_DIR)/env.sh
$(MBGL_ANDROID_BUILD_DIR)/build.ninja: $(MBGL_ANDROID_BUILD_DIR)/env.sh platform/android/config.cmake
# Invoke CMake twice to fix issues from double inclusion of toolchain.cmake on the first run.
. $(MBGL_ANDROID_BUILD_DIR)/env.sh && \
([ -f $(MBGL_ANDROID_BUILD_DIR)/build.ninja ] || $$$${CMAKE} \
-H. \
-B"$(MBGL_ANDROID_BUILD_DIR)" \
-G"$$$${CMAKE_GENERATOR}" \
$$$${CMAKE_ARGS} \
-DCMAKE_BUILD_TYPE=$(BUILDTYPE) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DMBGL_PLATFORM=android \
-DMASON_PLATFORM=android) && \
$$$${CMAKE} \
-H. \
-B"$(MBGL_ANDROID_BUILD_DIR)"
.PHONY: android-test-lib-$1
android-test-lib-$1: $(MBGL_ANDROID_BUILD_DIR)/build.ninja
. $(MBGL_ANDROID_BUILD_DIR)/env.sh && $$$${CMAKE} --build $(MBGL_ANDROID_BUILD_DIR) -- $(NINJA_ARGS) -j$(JOBS) mbgl-test
android-test-lib-$1: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 -Pmapbox.with_test=true :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
.PHONY: android-lib-$1
android-lib-$1: $(MBGL_ANDROID_BUILD_DIR)/build.ninja
. $(MBGL_ANDROID_BUILD_DIR)/env.sh && $$$${CMAKE} --build $(MBGL_ANDROID_BUILD_DIR) -- $(NINJA_ARGS) -j$(JOBS) mapbox-gl example-custom-layer
android-lib-$1: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDK:assemble$(BUILDTYPE)
.PHONY: android-$1
android-$1: android-lib-$1
cd platform/android && ./gradlew --parallel --max-workers=$(JOBS) :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
android-$1: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
.PHONY: android-core-test-$1
android-core-test-$1: android-test-lib-$1
mkdir -p $(MBGL_ANDROID_CORE_TEST_DIR)
# Compile main sources and extract the classes (using the test app to get all transitive dependencies in one place)
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
mkdir -p $(MBGL_ANDROID_CORE_TEST_DIR)
unzip -o platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-$(MBGL_ANDROID_APK_SUFFIX).apk classes.dex -d $(MBGL_ANDROID_CORE_TEST_DIR)
# Compile Test runner
@@ -555,8 +534,8 @@ run-android-core-test-$1-%: android-core-test-$1
# Push all needed files to the device
adb push $(MBGL_ANDROID_CORE_TEST_DIR)/test.jar $(MBGL_ANDROID_LOCAL_WORK_DIR) > /dev/null 2>&1
adb push test/fixtures $(MBGL_ANDROID_LOCAL_WORK_DIR)/test > /dev/null 2>&1
adb push $(MBGL_ANDROID_BUILD_DIR)/stripped/libmapbox-gl.so $(MBGL_ANDROID_LOCAL_WORK_DIR) > /dev/null 2>&1
adb push $(MBGL_ANDROID_BUILD_DIR)/stripped/libmbgl-test.so $(MBGL_ANDROID_LOCAL_WORK_DIR) > /dev/null 2>&1
adb push platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/$2/libmapbox-gl.so $(MBGL_ANDROID_LOCAL_WORK_DIR) > /dev/null 2>&1
adb push platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/$2/libmbgl-test.so $(MBGL_ANDROID_LOCAL_WORK_DIR) > /dev/null 2>&1
# Kick off the tests
adb shell "export LD_LIBRARY_PATH=/system/$(MBGL_ANDROID_LIBDIR):$(MBGL_ANDROID_LOCAL_WORK_DIR) && cd $(MBGL_ANDROID_LOCAL_WORK_DIR) && $(MBGL_ANDROID_DALVIKVM) -cp $(MBGL_ANDROID_LOCAL_WORK_DIR)/test.jar Main --gtest_filter=$$*"
@@ -571,16 +550,29 @@ run-android-core-test-$1-%: android-core-test-$1
run-android-core-test-$1: run-android-core-test-$1-*
.PHONY: run-android-$1
run-android-$1: android-$1
run-android-$1: platform/android/configuration.gradle
adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:install$(BUILDTYPE) && adb shell am start -n com.mapbox.mapboxsdk.testapp/.activity.FeatureOverviewActivity
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:install$(BUILDTYPE) && adb shell am start -n com.mapbox.mapboxsdk.testapp/.activity.FeatureOverviewActivity
.PHONY: android-ui-test-$1
android-ui-test-$1: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:assembleDebug :MapboxGLAndroidSDKTestApp:assembleAndroidTest
# This test assumes that you have Android Simulator started locally.
.PHONY: run-android-ui-test-$1
run-android-ui-test-$1: platform/android/configuration.gradle
adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:connectedAndroidTest
run-android-ui-test-$1-%: platform/android/configuration.gradle
adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class="$*"
apackage: android-lib-$1
endef
# Explodes the arguments into individual variables
define ANDROID_RULES_INVOKER
$(call ANDROID_RULES,$(word 1,$1),$(word 2,$1),$(word 3,$1))
$(call ANDROID_RULES,$(word 1,$1),$(word 2,$1))
endef
$(foreach abi,$(MBGL_ANDROID_ABIS),$(eval $(call ANDROID_RULES_INVOKER,$(subst ;, ,$(abi)))))
@@ -588,67 +580,70 @@ $(foreach abi,$(MBGL_ANDROID_ABIS),$(eval $(call ANDROID_RULES_INVOKER,$(subst ;
.PHONY: android
android: android-arm-v7
.PHONY: android-lib
android-lib: android-lib-arm-v7
.PHONY: run-android
run-android: run-android-arm-v7
.PHONY: run-android-unit-test
run-android-unit-test:
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:testDebugUnitTest --continue
run-android-unit-test-%:
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:testDebugUnitTest --tests "$*"
.PHONY: run-android-wear-unit-test
run-android-wear-unit-test:
cd platform/android && ./gradlew :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest --continue
.PHONY: android-ui-test
android-ui-test:
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:assembleDebug --continue && ./gradlew :MapboxGLAndroidSDKTestApp:assembleAndroidTest --continue
.PHONY: run-android-ui-test
run-android-ui-test:
adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:connectedAndroidTest -i
run-android-ui-test: run-android-ui-test-arm-v7
run-android-ui-test-%: run-android-ui-test-arm-v7-%
run-android-ui-test-%:
adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class="$*"
# Java-only test
.PHONY: run-android-unit-test
run-android-unit-test: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDKTestApp:testDebugUnitTest
run-android-unit-test-%: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDKTestApp:testDebugUnitTest --tests "$*"
# Java-only test
.PHONY: run-android-wear-unit-test
run-android-wear-unit-test: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest
run-android-wear-unit-test-%: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest --tests "$*"
.PHONY: run-android-ui-test-aws
run-android-ui-test-aws:
cd platform/android && ./gradlew devicefarmUpload
.PHONY: run-android-ui-test-spoon
run-android-ui-test-spoon:
cd platform/android && ./gradlew spoon
run-android-ui-test-aws: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all devicefarmUpload
.PHONY: apackage
apackage:
cd platform/android && ./gradlew --parallel --max-workers=$(JOBS) assemble$(BUILDTYPE)
apackage: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all assemble$(BUILDTYPE)
# Uploads the compiled Android SDK to Maven
.PHONY: run-android-upload-archives
run-android-upload-archives: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all :MapboxGLAndroidSDK:uploadArchives
# Runs Android UI tests on all connected devices using Spoon
.PHONY: run-android-ui-test-spoon
run-android-ui-test-spoon: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis="$(MBGL_ANDROID_ACTIVE_ARCHS)" spoon
.PHONY: test-code-android
test-code-android:
node platform/android/scripts/generate-test-code.js
.PHONY: android-ndk-stack
android-ndk-stack:
adb logcat | ndk-stack -sym build/android-arm-v7-9/Debug
.PHONY: android-checkstyle
android-checkstyle:
cd platform/android && ./gradlew checkstyle
android-checkstyle: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none checkstyle
.PHONY: android-javadoc
android-javadoc:
cd platform/android && ./gradlew :MapboxGLAndroidSDK:javadocrelease
android-javadoc: platform/android/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDK:javadocrelease
ifeq ($(HOST_PLATFORM), macos)
.PHONY: aproj
aproj:
aproj: platform/android/configuration.gradle
open -b com.google.android.studio platform/android
endif
.PHONY: android-configuration
android-configuration: platform/android/configuration.gradle
cat platform/android/configuration.gradle
#### Miscellaneous targets #####################################################
.PHONY: style-code
@@ -663,12 +658,12 @@ codestyle:
.PHONY: clean
clean:
-rm -rf ./build \
./platform/android/configuration.gradle \
./platform/android/MapboxGLAndroidSDK/build \
./platform/android/MapboxGLAndroidSDK/.externalNativeBuild \
./platform/android/MapboxGLAndroidSDKTestApp/build \
./platform/android/MapboxGLAndroidSDKWearTestApp/build \
./platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen \
./platform/android/MapboxGLAndroidSDK/src/main/jniLibs \
./platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs \
./platform/android/MapboxGLAndroidSDK/src/main/assets
.PHONY: distclean

View File

@@ -7,17 +7,16 @@
# Build files
build/
.externalNativeBuild
*.so
*.apk
# JNI
MapboxGLAndroidSDK/src/main/jniLibs/
# Lib assets
MapboxGLAndroidSDK/src/main/assets/
# Local settings
local.properties
/configuration.gradle
# Token file
MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml

View File

@@ -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_'

View File

@@ -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

View File

@@ -1,5 +1,15 @@
# Mapbox GL Test App
## Building
To be able to run any Gradle commands, you'll need to create the configuration file by running
```
$ make android-configuration
```
from the root folder.
## Testing
### Running Espresso tests on a device
@@ -28,7 +38,7 @@ On a terminal, within `mapbox-gl-native/android/java`,
run the tests (`cC` stands for `connectedCheck`):
```
$ ./gradlew cC -p MapboxGLAndroidSDKTestApp
$ ./gradlew -Pmapbox.abis=all cC -p MapboxGLAndroidSDKTestApp
```
Then:
@@ -63,7 +73,7 @@ You can also have a run configuration:
You can also run the tests from the command line with:
```
$ ./gradlew test --continue -p MapboxGLAndroidSDKTestApp
$ ./gradlew -Pmapbox.abis=none test -p MapboxGLAndroidSDKTestApp
```
### Running the UI/Application Exerciser Monkey

View File

@@ -13,13 +13,6 @@ trigger_map:
workflows:
primary:
steps:
- script:
title: Run Checkstyle
inputs:
- content: |-
#!/bin/bash
# Run checkstyle gradle task on all modules
cd platform/android && ./gradlew checkstyle
- script:
title: Configure Google Cloud SDK
inputs:
@@ -45,9 +38,12 @@ workflows:
inputs:
- content: |-
#!/bin/bash
# Accept Android SDK license
echo "Accepting Android SDK license..."
mkdir -p "${ANDROID_HOME}/licenses"
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
echo "Compile libmapbox-gl.so for armeabi-v7a abi:"
export BUILDTYPE=Debug
make android-lib-arm-v7
BUILDTYPE=Debug make android-lib-arm-v7
- script:
title: Compile Core tests
inputs:
@@ -76,6 +72,13 @@ workflows:
#!/bin/bash
echo "Generate these test locally by executing:"
make test-code-android
- script:
title: Run Checkstyle
inputs:
- content: |-
#!/bin/bash
# Run checkstyle gradle task on all modules
make android-checkstyle
- script:
title: Run Firebase instrumentation tests
inputs:
@@ -85,7 +88,7 @@ workflows:
wget -O platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml "$BITRISEIO_TEST_ACCESS_TOKEN_UI_TEST_URL"
echo "Build seperate test apk:"
make android-ui-test
make android-ui-test-arm-v7
echo "Run tests on firebase:"
gcloud auth activate-service-account --key-file secret.json --project android-gl-native
@@ -156,17 +159,20 @@ workflows:
inputs:
- content: |-
#!/bin/bash
# Accept Android SDK license
echo "Accepting Android SDK license..."
mkdir -p "${ANDROID_HOME}/licenses"
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
echo "Compile libmapbox-gl.so for all supportd abi's:"
export BUILDTYPE=Release
make apackage
cd platform/android && ./gradlew :MapboxGLAndroidSDK:assembleRelease
- script:
title: Publish to maven
inputs:
- content: |-
#!/bin/bash
echo "Upload aar file to maven:"
cd platform/android && ./gradlew :MapboxGLAndroidSDK:uploadArchives
make run-android-upload-archives
- slack:
title: Post to Slack
inputs:
@@ -185,6 +191,10 @@ workflows:
inputs:
- content: |-
#!/bin/bash
# Accept Android SDK license
echo "Accepting Android SDK license..."
mkdir -p "${ANDROID_HOME}/licenses"
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
echo "Compile libmapbox-gl.so for all supportd abi's:"
export BUILDTYPE=Release
make apackage
@@ -208,7 +218,7 @@ workflows:
- content: |-
#!/bin/bash
echo "Run tests on device farm:"
cd platform/android && ./gradlew devicefarmUpload
make run-android-ui-test-aws
- slack:
title: Post to Slack
inputs:
@@ -234,10 +244,13 @@ workflows:
inputs:
- content: |-
#!/bin/bash
# Accept Android SDK license
echo "Accepting Android SDK license..."
mkdir -p "${ANDROID_HOME}/licenses"
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
echo "Compile libmapbox-gl.so for all supportd abi's:"
export BUILDTYPE=Release
make apackage
cd platform/android && ./gradlew :MapboxGLAndroidSDK:assembleRelease
- script:
title: Log metrics
inputs:

View File

@@ -21,3 +21,6 @@ task wrapper(type: Wrapper) {
apply from: rootProject.file('dependencies.gradle')
// Load build system information. If this file does not exist, run
// `make platform/android/configuration.gradle`
apply from: rootProject.file('configuration.gradle')

View File

@@ -22,15 +22,6 @@ mason_use(sqlite VERSION 3.14.2)
mason_use(gtest VERSION 1.8.0)
mason_use(icu VERSION 58.1-min-size)
set(ANDROID_SDK_PROJECT_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDK)
set(ANDROID_JNI_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/jniLibs/${ANDROID_ABI})
set(ANDROID_ASSETS_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/assets)
set(ANDROID_TEST_APP_JNI_TARGET_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs/${ANDROID_ABI})
if (NOT DEFINED ANDROID_TOOLCHAIN_PREFIX)
set(ANDROID_TOOLCHAIN_PREFIX "${MASON_XC_ROOT}/bin/${ANDROID_TOOLCHAIN}-")
endif()
## mbgl core ##
macro(mbgl_platform_core)
@@ -251,11 +242,6 @@ target_link_libraries(mapbox-gl
PUBLIC -Wl,--version-script=${CMAKE_SOURCE_DIR}/platform/android/version-script
)
# Create a stripped version of the library and copy it to the JNIDIR.
add_custom_command(TARGET mapbox-gl POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_JNI_TARGET_DIR}
COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:mapbox-gl> -o ${ANDROID_JNI_TARGET_DIR}/$<TARGET_FILE_NAME:mapbox-gl>)
## Test library ##
add_library(mbgl-test SHARED
@@ -312,11 +298,6 @@ target_add_mason_package(mbgl-test PRIVATE boost)
target_add_mason_package(mbgl-test PRIVATE geojson)
target_add_mason_package(mbgl-test PRIVATE geojsonvt)
add_custom_command(TARGET mbgl-test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/stripped
COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:mapbox-gl> -o ${CMAKE_CURRENT_BINARY_DIR}/stripped/$<TARGET_FILE_NAME:mapbox-gl>
COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:mbgl-test> -o ${CMAKE_CURRENT_BINARY_DIR}/stripped/$<TARGET_FILE_NAME:mbgl-test>)
## Custom layer example ##
add_library(example-custom-layer SHARED
@@ -334,7 +315,3 @@ target_link_libraries(example-custom-layer
PUBLIC -Wl,--gc-sections
PUBLIC -Wl,--version-script=${CMAKE_SOURCE_DIR}/platform/android/version-script
)
add_custom_command(TARGET example-custom-layer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_TEST_APP_JNI_TARGET_DIR}
COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:example-custom-layer> -o ${ANDROID_TEST_APP_JNI_TARGET_DIR}/$<TARGET_FILE_NAME:example-custom-layer>)

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env bash
set -e
set -o pipefail
# Automation of https://github.com/mapbox/mapbox-gl-native/wiki/Android-debugging-with-remote-GDB
export MASON_ANDROID_ARCH=x86
export MASON_ANDROID_PLATFORM=9
export MASON_ANDROID_NDK_VERSION=r14
export MASON_XC_ROOT=`scripts/mason.sh PREFIX android-ndk VERSION ${MASON_ANDROID_ARCH}-${MASON_ANDROID_PLATFORM}-${MASON_ANDROID_NDK_VERSION}`
source ${MASON_XC_ROOT}/toolchain.sh
if [[ $1 == '--prepare' ]]; then
mkdir -p ~/.android/debugging/{vendor,system}_lib
adb pull /system/lib ~/.android/debugging/system_lib
adb pull /vendor/lib ~/.android/debugging/vendor_lib
adb pull /system/bin/app_process ~/.android/debugging
adb pull /system/bin/app_process32 ~/.android/debugging
adb pull /system/bin/linker ~/.android/debugging
if [[ ${MASON_ANDROID_ARCH} == 'arm-v8' || ${MASON_ANDROID_ARCH} == 'x86-64' || ${MASON_ANDROID_ARCH} == 'mips-64' ]]; then
adb pull /system/bin/app_process64 ~/.android/debugging
adb pull /system/bin/linker64 ~/.android/debugging
fi
cp ${MASON_XC_ROOT}/prebuilt/gdbserver/gdbserver \
platform/android/MapboxGLAndroidSDK/src/main/jniLibs/${ANDROID_ABI}/gdbserver.so
fi
adb install -r -t -d -g platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug.apk
adb shell am start -n "com.mapbox.mapboxsdk.testapp/com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity" \
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER
adb forward tcp:5039 tcp:5039
adb shell run-as com.mapbox.mapboxsdk.testapp '/data/data/com.mapbox.mapboxsdk.testapp/lib/gdbserver.so \
--attach :5039 `pgrep com.mapbox.mapboxsdk.testapp`' &
${MASON_XC_ROOT}/bin/gdb \
-ex "target remote :5039" \
-ex "set solib-search-path ~/.android/debugging:~/.android/debugging/system_lib:~/.android/debugging/vendor_lib:~/.android/debugging/vendor_lib/egl:./build/android-${MASON_ANDROID_ARCH}-${MASON_ANDROID_PLATFORM}/Debug/lib.target/"

View File

@@ -4,12 +4,12 @@ set -e
set -o pipefail
# Track individual architectures
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/armeabi/libmapbox-gl.so" "Platform=Android,Arch=arm-v5"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/armeabi-v7a/libmapbox-gl.so" "Platform=Android,Arch=arm-v7"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/arm64-v8a/libmapbox-gl.so" "Platform=Android,Arch=arm-v8"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/x86/libmapbox-gl.so" "Platform=Android,Arch=x86"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/x86_64/libmapbox-gl.so" "Platform=Android,Arch=x86_64"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/mips/libmapbox-gl.so" "Platform=Android,Arch=mips"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/armeabi/libmapbox-gl.so" "Platform=Android,Arch=arm-v5"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/armeabi-v7a/libmapbox-gl.so" "Platform=Android,Arch=arm-v7"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/arm64-v8a/libmapbox-gl.so" "Platform=Android,Arch=arm-v8"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/x86/libmapbox-gl.so" "Platform=Android,Arch=x86"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/x86_64/libmapbox-gl.so" "Platform=Android,Arch=x86_64"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/mips/libmapbox-gl.so" "Platform=Android,Arch=mips"
# Track overall library size
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar" "Platform=Android,Arch=Archive"
scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar" "Platform=Android,Arch=Archive"

View File

@@ -1,123 +0,0 @@
#!/usr/bin/env bash
set -e
set -o pipefail
set -u
# This script produces an env.sh file, which contains the paths to CMake, and the flags required to
# create a build. It first tries to use the Android NDK, but falls back to installing it via Mason.
function error { >&2 echo -e "\033[1m\033[31m$@\033[0m"; }
function warning { >&2 echo -e "\033[1m\033[33m$@\033[0m"; }
function status { >&2 echo -e "\033[1m\033[36m$@\033[0m"; }
function info { >&2 echo -e "\033[1m\033[32m$@\033[0m"; }
if [ "$#" -ne 3 ]; then
error "Usage: $0 <short arch> <long arch> <api level>"
fi
NDK_ANDROID_VERSION=$1-$3
ANDROID_NATIVE_API_LEVEL=$3
ANDROID_ABI=$2
MASON_NDK_VERSION=r14
function is_supported_ndk_version {
[ "$1" = "13.1.3345770" ] || [ "$1" = "14.0.3770861" ]
}
function mason_ndk {
local CMAKE=${CMAKE:-cmake}
MASON_XC_ROOT="`${CMAKE} -P cmake/mason.cmake PREFIX android-ndk VERSION ${NDK_ANDROID_VERSION}-${MASON_NDK_VERSION}`"
local TOOLCHAIN="${MASON_XC_ROOT}/toolchain.cmake"
if [ ! -f "${TOOLCHAIN}" ]; then
error "Can't find CMake toolchain file at ${TOOLCHAIN}."
exit 1
fi
info "Using Mason-provided Android NDK ${MASON_NDK_VERSION} at ${MASON_XC_ROOT}"
echo CMAKE=\"${CMAKE}\"
echo CMAKE_GENERATOR=\"Ninja\"
echo CMAKE_ARGS=\" \
-DCMAKE_MAKE_PROGRAM=`pwd`/${NINJA} \
-DMASON_XC_ROOT=${MASON_XC_ROOT} \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} \
\"
}
function system_ndk {
if [[ ${USE_MASON_NDK:-} ]]; then
return 1
fi
if [ -f platform/android/local.properties ]; then
local SDK_DIR=$(sed -n -e 's/^sdk.dir=\(.*\)$/\1/p' platform/android/local.properties)
fi
if [ ! -d "${SDK_DIR:-}" ]; then
if [ ! -z "${ANDROID_HOME:-}" ]; then
local SDK_DIR="${ANDROID_HOME}"
else
error "Can't find the Android SDK. Set \$ANDROID_HOME to the SDK path."
exit 1
fi
fi
local NDK_DIR="${ANDROID_NDK_HOME:-${SDK_DIR}/ndk-bundle}"
if [ ! -d "${NDK_DIR}" ]; then
warning "Can't find the Android NDK. If it is installed, set \$ANDROID_NDK_HOME to the NDK path."
return 1
fi
local SYSTEM_NDK_VERSION=$(sed -n 's/^Pkg.Revision *= *//p' "${NDK_DIR}/source.properties")
if ! is_supported_ndk_version "${SYSTEM_NDK_VERSION}"; then
warning "Android NDK version '${SYSTEM_NDK_VERSION}' doesn't match required version."
return 1
fi
# Try to install CMake if it's not installed yet.
mkdir -p "${SDK_DIR}/cmake"
local CMAKE_VERSION=/$(ls "${SDK_DIR}/cmake" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)
local CMAKE="${SDK_DIR}/cmake${CMAKE_VERSION:-}/bin/cmake"
if [ ! -f "${CMAKE}" ]; then
status "Trying to install CMake..."
mkdir -p "${SDK_DIR}/licenses"
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${SDK_DIR}/licenses/android-sdk-license"
"${SDK_DIR}/tools/bin/sdkmanager" --list | grep cmake | tail -n 1 | cut -d \| -f 1 | xargs "${SDK_DIR}/tools/bin/sdkmanager" >&2
CMAKE_VERSION=/$(ls "${SDK_DIR}/cmake" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)
CMAKE="${SDK_DIR}/cmake${CMAKE_VERSION:-}/bin/cmake"
if [ ! -f "${CMAKE}" ]; then
error "Can't find CMake at ${CMAKE}."
return 1
fi
fi
local NINJA="${SDK_DIR}/cmake${CMAKE_VERSION:-}/bin/ninja"
if [ ! -f "${NINJA}" ]; then
error "Can't find Ninja at ${NINJA}."
return 1
fi
local TOOLCHAIN="${NDK_DIR}/build/cmake/android.toolchain.cmake"
if [ ! -f "${TOOLCHAIN}" ]; then
error "Can't find CMake toolchain file at ${TOOLCHAIN}."
return 1
fi
info "Using system-provided Android NDK ${SYSTEM_NDK_VERSION} at ${NDK_DIR}"
echo CMAKE=\"${CMAKE}\"
echo CMAKE_GENERATOR=\"Android Gradle - Ninja\"
echo CMAKE_ARGS=\" \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_NDK=${NDK_DIR} \
-DCMAKE_MAKE_PROGRAM=${NINJA} \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} \
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_STL=c++_static \
-DANDROID_CPP_FEATURES=rtti\;exceptions \
\"
}
system_ndk || mason_ndk

View File

@@ -25,7 +25,7 @@ On a terminal, within `mapbox-gl-native/android/java`,
run the tests (`cC` stands for `connectedCheck`):
```
$ ./gradlew cC -p MapboxGLAndroidSDKTestApp
$ ./gradlew -Pmapbox.abis=all cC -p MapboxGLAndroidSDKTestApp
```
Then:
@@ -59,7 +59,7 @@ You can generate JaCoCo reports from espresso tests by
- running the gradle task `createMockDebugCoverageReport` when executing tests.
## Running Espresso test automatically on AWS Device Farm
To run tests on AWS device farm you need to execute `./gradlew devicefarmUpload`.
To run tests on AWS device farm you need to execute `./gradlew -Pmapbox.abis=none devicefarmUpload`.
You can configure the different steps in the testapp `build.gradle`.
AWS credentials are found in bitrise.

View File

@@ -69,7 +69,7 @@ If you like, you can also run with test coverage enabled. This will show you the
You can also run the tests from the command line with:
```
$ ./gradlew test --continue -p MapboxGLAndroidSDKTestApp
$ ./gradlew -Pmapbox.abis=none test -p MapboxGLAndroidSDKTestApp
```
## Running Unit tests on CI
@@ -80,7 +80,7 @@ fails, this will fail and stop the build.
You can find this gradle command in our [buildscript](https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/bitrise.yml#L48):
```
$ ./gradlew testReleaseUnitTest --continue
$ ./gradlew -Pmapbox.abis=none testReleaseUnitTest
```