diff --git a/Makefile b/Makefile index cff4445d0a5..0f36b0dbfab 100644 --- a/Makefile +++ b/Makefile @@ -385,11 +385,10 @@ build/android-$1/$(BUILDTYPE)/Makefile: build/android-$1/$(BUILDTYPE)/toolchain. -DCMAKE_TOOLCHAIN_FILE=build/android-$1/$(BUILDTYPE)/toolchain.cmake \ -DCMAKE_BUILD_TYPE=$(BUILDTYPE) \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ -DMBGL_PLATFORM=android android-lib-$1: build/android-$1/$(BUILDTYPE)/Makefile - $(MAKE) VERBOSE=1 -j$(JOBS) -C build/android-$1/$(BUILDTYPE) mapbox-gl + $(MAKE) -j$(JOBS) -C build/android-$1/$(BUILDTYPE) all android-$1: android-lib-$1 cd platform/android && ./gradlew --parallel --max-workers=$(JOBS) assemble$(BUILDTYPE) @@ -401,6 +400,12 @@ $(foreach abi,$(ANDROID_ABIS),$(eval $(call ANDROID_RULES,$(abi)))) android: android-arm-v7 +test-android: + cd platform/android && ./gradlew testReleaseUnitTest --continue + +apackage: + cd platform/android && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE) + #### Miscellaneous targets ##################################################### style-code: diff --git a/platform/android/config.cmake b/platform/android/config.cmake index 3bbf44a61b9..371b7533e73 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -1,3 +1,6 @@ +#Include to use build specific variables +include(${CMAKE_CURRENT_BINARY_DIR}/toolchain.cmake) + mason_use(geojson 0.1.4) mason_use(jni.hpp 2.0.0) mason_use(libjpeg-turbo 1.4.2) @@ -69,7 +72,6 @@ macro(mbgl_platform_core) ) endmacro() - add_library(mapbox-gl SHARED platform/android/src/jni.cpp platform/android/src/attach_env.cpp @@ -78,3 +80,27 @@ add_library(mapbox-gl SHARED target_link_libraries(mapbox-gl PUBLIC mbgl-core ) + +add_library(example-custom-layer SHARED + platform/android/src/example_custom_layer.cpp +) + +target_link_libraries(example-custom-layer + PRIVATE mbgl-core +) + +set(ANDROID_TARGET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platform/android/MapboxGLAndroidSDK/src/main/jniLibs/${ANDROID_JNIDIR}/) + +add_custom_target(copy-binaries + DEPENDS mapbox-gl + DEPENDS example-custom-layer + COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy $ ${ANDROID_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy $ ${ANDROID_TARGET_DIR} +) + +add_custom_target(_all ALL + DEPENDS mapbox-gl + DEPENDS example-custom-layer + DEPENDS copy-binaries +) diff --git a/platform/android/scripts/toolchain.sh b/platform/android/scripts/toolchain.sh index 639be7a8bfa..54f75528b12 100755 --- a/platform/android/scripts/toolchain.sh +++ b/platform/android/scripts/toolchain.sh @@ -14,4 +14,4 @@ echo "set(CMAKE_SYSTEM_NAME Linux)" echo "set(CMAKE_SYSTEM_VERSION 1)" echo "set(CMAKE_CXX_COMPILER \"`which $(mason env CXX)`\")" echo "set(CMAKE_C_COMPILER \"`which $(mason env CC)`\")" -echo "set(JNIDIR \"`mason env JNIDIR`\")" \ No newline at end of file +echo "set(ANDROID_JNIDIR \"`mason env JNIDIR`\")" \ No newline at end of file