summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-02-20 19:24:21 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-02-22 18:06:20 +0100
commit341e65f7d51e7acc0bf73893317251adc4d23cb6 (patch)
treecd549c3a57e7dc7737efa7c89298a7ea7777b900 /Makefile
parent586ae94ec4cfd3ea5b223ba36fc519ef8ada5eff (diff)
downloadqtlocation-mapboxgl-341e65f7d51e7acc0bf73893317251adc4d23cb6.tar.gz
[build] use system-provided Android NDK when available
and fall back to Mason if it isn't
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile86
1 files changed, 51 insertions, 35 deletions
diff --git a/Makefile b/Makefile
index 30a5ade7ba..c0c495335f 100644
--- a/Makefile
+++ b/Makefile
@@ -9,12 +9,12 @@ endif
ifeq ($(shell uname -s), Darwin)
HOST_PLATFORM = macos
HOST_PLATFORM_VERSION = $(shell uname -m)
- NINJA ?= platform/macos/ninja
+ export NINJA = platform/macos/ninja
export JOBS ?= $(shell sysctl -n hw.ncpu)
else ifeq ($(shell uname -s), Linux)
HOST_PLATFORM = linux
HOST_PLATFORM_VERSION = $(shell uname -m)
- NINJA ?= platform/linux/ninja
+ export NINJA = platform/linux/ninja
export JOBS ?= $(shell grep --count processor /proc/cpuinfo)
else
$(error Cannot determine host platform)
@@ -465,12 +465,19 @@ test-node: node
#### Android targets ###########################################################
-MBGL_ANDROID_ABIS = arm-v5-9 arm-v7-9 arm-v8-21 x86-9 x86-64-21 mips-9
+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_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-21 x86-64-21,$1),64)
-MBGL_ANDROID_DALVIKVM = dalvikvm$(if $(filter arm-v8-21 x86-64-21,$1),64,32)
+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 = build/android-$1/$(BUILDTYPE)/core-tests
+MBGL_ANDROID_CORE_TEST_DIR = $(MBGL_ANDROID_BUILD_DIR)/core-tests
.PHONY: android-help
android-help:
@@ -500,26 +507,39 @@ android-style-code:
style-code: android-style-code
define ANDROID_RULES
-
-build/android-$1/$(BUILDTYPE)/build.ninja: $(BUILD_DEPS) platform/android/config.cmake
- @mkdir -p build/android-$1/$(BUILDTYPE)
- export MASON_XC_ROOT=`scripts/mason.sh PREFIX android-ndk VERSION $1-r13b` && \
- cd build/android-$1/$(BUILDTYPE) && cmake ../../.. -G Ninja \
- -DMASON_XC_ROOT="$$$${MASON_XC_ROOT}" \
- -DCMAKE_TOOLCHAIN_FILE="$$$${MASON_XC_ROOT}/toolchain.cmake" \
- -DCMAKE_BUILD_TYPE=$(BUILDTYPE) \
- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
- -DMBGL_PLATFORM=android \
- -DMASON_PLATFORM=android \
- -DMASON_PLATFORM_VERSION=$1
+# $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 \
+ -DMASON_PLATFORM_VERSION=$1-$3) && \
+ $$$${CMAKE} \
+ -H. \
+ -B"$(MBGL_ANDROID_BUILD_DIR)"
.PHONY: android-test-lib-$1
-android-test-lib-$1: build/android-$1/$(BUILDTYPE)/build.ninja
- $(NINJA) $(NINJA_ARGS) -j$(JOBS) -C build/android-$1/$(BUILDTYPE) mbgl-test
+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
.PHONY: android-lib-$1
-android-lib-$1: build/android-$1/$(BUILDTYPE)/build.ninja
- $(NINJA) $(NINJA_ARGS) -j$(JOBS) -C build/android-$1/$(BUILDTYPE) mapbox-gl example-custom-layer
+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
.PHONY: android-$1
android-$1: android-lib-$1
@@ -551,8 +571,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 build/android-$1/$(BUILDTYPE)/stripped/libmapbox-gl.so $(MBGL_ANDROID_LOCAL_WORK_DIR) > /dev/null 2>&1
- adb push build/android-$1/$(BUILDTYPE)/stripped/libmbgl-test.so $(MBGL_ANDROID_LOCAL_WORK_DIR) > /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
# 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=$$*"
@@ -574,22 +594,18 @@ run-android-$1: android-$1
apackage: android-lib-$1
endef
-$(foreach abi,$(MBGL_ANDROID_ABIS),$(eval $(call ANDROID_RULES,$(abi))))
+# Explodes the arguments into individual variables
+define ANDROID_RULES_INVOKER
+$(call ANDROID_RULES,$(word 1,$1),$(word 2,$1),$(word 3,$1))
+endef
-# Backwards compatibility
-%-arm-v5: %-arm-v5-9 ;
-%-arm-v7: %-arm-v7-9 ;
-%-arm-v8: %-arm-v8-21 ;
-%-mips: %-mips-9 ;
-%-mips-64: %-mips-64-21 ;
-%-x86: %-x86-9 ;
-%-x86-64: %-x86-64-21 ;
+$(foreach abi,$(MBGL_ANDROID_ABIS),$(eval $(call ANDROID_RULES_INVOKER,$(subst ;, ,$(abi)))))
.PHONY: android
-android: android-arm-v7-9
+android: android-arm-v7
.PHONY: run-android
-run-android: run-android-arm-v7-9
+run-android: run-android-arm-v7
.PHONY: run-android-unit-test
run-android-unit-test: