diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-07-22 16:05:19 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-08-05 11:42:22 +0200 |
commit | 5f70a65a2cc33883637fcc9d13ef2c81eba9b75c (patch) | |
tree | e89486b4ca42f778603a5e19db3454c3e4278c71 /platform/android | |
parent | 795d17dbdb33186071f4ecef2fc672bf2767782a (diff) | |
download | qtlocation-mapboxgl-5f70a65a2cc33883637fcc9d13ef2c81eba9b75c.tar.gz |
[build] cmake android
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/config.cmake | 113 | ||||
-rwxr-xr-x | platform/android/scripts/toolchain.sh | 24 |
2 files changed, 123 insertions, 14 deletions
diff --git a/platform/android/config.cmake b/platform/android/config.cmake new file mode 100644 index 0000000000..e4976930f7 --- /dev/null +++ b/platform/android/config.cmake @@ -0,0 +1,113 @@ +#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) +mason_use(libpng 1.6.20) +mason_use(libzip 0.11.2) +mason_use(nunicode 1.6) +mason_use(sqlite 3.9.1) +mason_use(zlib system) + +macro(mbgl_platform_core) + + target_sources(mbgl-core + # Loop + PRIVATE platform/android/src/thread.cpp + PRIVATE platform/android/src/async_task.cpp + PRIVATE platform/android/src/run_loop.cpp + PRIVATE platform/android/src/timer.cpp + + # File source + PRIVATE platform/android/src/http_file_source.cpp + PRIVATE platform/android/src/asset_file_source.cpp + PRIVATE platform/default/default_file_source.cpp + PRIVATE platform/default/online_file_source.cpp + + # Offline + # PRIVATE include/mbgl/storage/offline.hpp + PRIVATE platform/default/mbgl/storage/offline.cpp + PRIVATE platform/default/mbgl/storage/offline_database.cpp + PRIVATE platform/default/mbgl/storage/offline_database.hpp + PRIVATE platform/default/mbgl/storage/offline_download.cpp + PRIVATE platform/default/mbgl/storage/offline_download.hpp + PRIVATE platform/default/sqlite3.cpp + PRIVATE platform/default/sqlite3.hpp + + # Misc + PRIVATE platform/android/src/native_map_view.cpp + PRIVATE platform/android/src/log_android.cpp + PRIVATE platform/default/string_stdlib.cpp + + # Image handling + PRIVATE platform/default/image.cpp + PRIVATE platform/default/png_reader.cpp + PRIVATE platform/default/jpeg_reader.cpp + + # Headless view + # TODO + ) + + target_include_directories(mbgl-core + PRIVATE platform/default + ) + + target_add_mason_package(mbgl-core PUBLIC sqlite) + target_add_mason_package(mbgl-core PUBLIC nunicode) + target_add_mason_package(mbgl-core PUBLIC libpng) + target_add_mason_package(mbgl-core PUBLIC libjpeg-turbo) + target_add_mason_package(mbgl-core PUBLIC zlib) + target_add_mason_package(mbgl-core PUBLIC libzip) + target_add_mason_package(mbgl-core PUBLIC geojson) + target_add_mason_package(mbgl-core PUBLIC jni.hpp) + + target_link_libraries(mbgl-core + PUBLIC -llog + PUBLIC -landroid + PUBLIC -lEGL + PUBLIC -lGLESv2 + PUBLIC -lstdc++ + PUBLIC -latomic + ) +endmacro() + +add_library(mapbox-gl SHARED + platform/android/src/jni.cpp + platform/android/src/attach_env.cpp +) + +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_SDK_PROJECT_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDK) +set(ANDROID_JNI_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/jniLibs/${ANDROID_JNIDIR}/) +set(ANDROID_ASSETS_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/assets/) + +add_custom_target(copy-files + DEPENDS mapbox-gl + DEPENDS example-custom-layer + COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_JNI_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mapbox-gl> ${ANDROID_JNI_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:example-custom-layer> ${ANDROID_JNI_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_ASSETS_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/common/ca-bundle.crt ${ANDROID_ASSETS_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/platform/default/resources/api_mapbox_com-digicert.der ${ANDROID_ASSETS_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/platform/default/resources/api_mapbox_com-geotrust.der ${ANDROID_ASSETS_TARGET_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/platform/default/resources/star_tilestream_net.der ${ANDROID_ASSETS_TARGET_DIR} +) + +add_custom_target(_all ALL + DEPENDS mapbox-gl + DEPENDS example-custom-layer + DEPENDS copy-files +) diff --git a/platform/android/scripts/toolchain.sh b/platform/android/scripts/toolchain.sh index 6eb6a229fe..0f78200803 100755 --- a/platform/android/scripts/toolchain.sh +++ b/platform/android/scripts/toolchain.sh @@ -10,17 +10,13 @@ export MASON_DIR="`pwd`/.mason" export PATH=`mason env PATH` -echo MASON_PLATFORM=\"${MASON_PLATFORM}\" -echo MASON_ANDROID_ABI=\"${MASON_ANDROID_ABI}\" -echo CXX=\"`which $(mason env CXX)`\" -echo CC=\"`which $(mason env CC)`\" -echo LD=\"`which $(mason env LD)`\" -echo LINK=\"`which $(mason env CXX)`\" -echo AR=\"`which $(mason env AR)`\" -echo RANLIB=\"`which $(mason env RANLIB)`\" -echo STRIP=\"`which $(mason env STRIP)`\" -echo LDFLAGS=\"`mason env LDFLAGS` \${LDFLAGS:-}\" -echo CFLAGS=\"`mason env CFLAGS` \${CFLAGS:-}\" -echo CXXFLAGS=\"`mason env CXXFLAGS` \${CXXFLAGS:-}\" -echo CPPFLAGS=\"`mason env CPPFLAGS` \${CPPFLAGS:-}\" -echo JNIDIR=\"`mason env JNIDIR`\" +echo "set(CMAKE_SYSTEM_NAME Android)" +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(ANDROID_JNIDIR \"`mason env JNIDIR`\")" +echo "set(ANDROID_ABI \"${1:-arm-v7}\")" +echo "set(ENV{MASON_ANDROID_ABI} \"${1:-arm-v7}\")" +echo "set(CMAKE_EXE_LINKER_FLAGS \"`mason env LDFLAGS` \${CMAKE_EXE_LINKER_FLAGS}\")" +echo "set(CMAKE_CXX_FLAGS \"-s -fvisibility=hidden -Os `mason env CXXFLAGS` \${CMAKE_CXX_FLAGS}\")" +echo "set(CMAKE_C_FLAGS \"-s -fvisibility=hidden -Os `mason env CPPFLAGS` \${CMAKE_C_FLAGS}\")" |