diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-10 19:14:10 -0800 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-03-17 14:25:37 +0100 |
commit | 9544dcc4834bf816e9e75f0aa9937a1562b2353f (patch) | |
tree | d2c2eec9d7b171ccbc5f3a82104dd19f804b8343 /Makefile | |
parent | aed3869cfaf0f590f58265e203dd7b9a2ee38fb7 (diff) | |
download | qtlocation-mapboxgl-9544dcc4834bf816e9e75f0aa9937a1562b2353f.tar.gz |
[android] move build to Android Studio
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 189 |
1 files changed, 92 insertions, 97 deletions
@@ -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 +.PHONY: run-android-ui-test +run-android-ui-test: run-android-ui-test-arm-v7 +run-android-ui-test-%: run-android-ui-test-arm-v7-% -run-android-unit-test-%: - cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:testDebugUnitTest --tests "$*" +# 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: - cd platform/android && ./gradlew :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest --continue +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: 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 +.PHONY: run-android-ui-test-aws +run-android-ui-test-aws: platform/android/configuration.gradle + cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all devicefarmUpload -run-android-ui-test-%: - adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null - cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class="$*" +.PHONY: apackage +apackage: platform/android/configuration.gradle + cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all assemble$(BUILDTYPE) -.PHONY: run-android-ui-test-aws -run-android-ui-test-aws: - cd platform/android && ./gradlew devicefarmUpload +# 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: - cd platform/android && ./gradlew spoon - -.PHONY: apackage -apackage: - cd platform/android && ./gradlew --parallel --max-workers=$(JOBS) assemble$(BUILDTYPE) +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 |