blob: 635c27a44f0d1fcd73b753cde8de6a6bcb0c993f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
add_definitions(-DMBGL_USE_GLES2=1)
include(cmake/test-files.cmake)
#Include to use build specific variables
include(${CMAKE_CURRENT_BINARY_DIR}/toolchain.cmake)
# Build thin archives.
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
if ((ANDROID_ABI STREQUAL "armeabi") OR (ANDROID_ABI STREQUAL "armeabi-v7a") OR (ANDROID_ABI STREQUAL "arm64-v8a") OR
(ANDROID_ABI STREQUAL "x86") OR (ANDROID_ABI STREQUAL "x86_64"))
# Use Identical Code Folding on platforms that support the gold linker.
set(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=gold -Wl,--icf=safe ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=gold -Wl,--icf=safe ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
mason_use(jni.hpp VERSION 2.0.0 HEADER_ONLY)
mason_use(libjpeg-turbo VERSION 1.5.0)
mason_use(libpng VERSION 1.6.25)
mason_use(libzip VERSION 1.1.3)
mason_use(nunicode VERSION 1.7.1)
mason_use(sqlite VERSION 3.14.2)
mason_use(gtest VERSION 1.7.0)
mason_use(icu VERSION 58.1)
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)
set(ANDROID_TEST_APP_JNI_TARGET_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs/${ANDROID_JNIDIR})
macro(mbgl_android_copy_asset source target)
add_custom_command(
OUTPUT ${ANDROID_ASSETS_TARGET_DIR}/${target}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/${source} ${ANDROID_ASSETS_TARGET_DIR}/${target}
DEPENDS ${CMAKE_SOURCE_DIR}/${source}
)
endmacro()
mbgl_android_copy_asset(common/ca-bundle.crt ca-bundle.crt)
add_custom_target(mbgl-copy-android-assets
DEPENDS ${ANDROID_ASSETS_TARGET_DIR}/ca-bundle.crt
)
## mbgl core ##
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/run_loop_impl.hpp
PRIVATE platform/android/src/timer.cpp
# File source
PRIVATE platform/android/src/asset_file_source.cpp
PRIVATE platform/android/src/http_file_source.cpp
PRIVATE platform/default/default_file_source.cpp
PRIVATE platform/default/local_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/logging_android.cpp
PRIVATE platform/default/string_stdlib.cpp
PRIVATE platform/default/bidi.cpp
# Image handling
PRIVATE platform/default/image.cpp
PRIVATE platform/default/png_reader.cpp
PRIVATE platform/default/jpeg_reader.cpp
# Thread pool
PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
PRIVATE platform/default/mbgl/util/default_thread_pool.hpp
# Conversion C++ -> Java
platform/android/src/conversion/constant.hpp
platform/android/src/conversion/conversion.hpp
platform/android/src/style/conversion/function.hpp
platform/android/src/style/conversion/property_value.hpp
platform/android/src/style/conversion/types.hpp
platform/android/src/style/conversion/types_string_values.hpp
# Style conversion Java -> C++
platform/android/src/style/android_conversion.hpp
platform/android/src/style/conversion/geojson.hpp
platform/android/src/style/value.cpp
platform/android/src/style/value.hpp
platform/android/src/style/conversion/url_or_tileset.hpp
# Style
platform/android/src/style/layers/background_layer.cpp
platform/android/src/style/layers/background_layer.hpp
platform/android/src/style/layers/circle_layer.cpp
platform/android/src/style/layers/circle_layer.hpp
platform/android/src/style/layers/custom_layer.cpp
platform/android/src/style/layers/custom_layer.hpp
platform/android/src/style/layers/fill_layer.cpp
platform/android/src/style/layers/fill_layer.hpp
platform/android/src/style/layers/layer.cpp
platform/android/src/style/layers/layer.hpp
platform/android/src/style/layers/layers.cpp
platform/android/src/style/layers/layers.hpp
platform/android/src/style/layers/line_layer.cpp
platform/android/src/style/layers/line_layer.hpp
platform/android/src/style/layers/raster_layer.cpp
platform/android/src/style/layers/raster_layer.hpp
platform/android/src/style/layers/symbol_layer.cpp
platform/android/src/style/layers/symbol_layer.hpp
platform/android/src/style/sources/geojson_source.cpp
platform/android/src/style/sources/geojson_source.hpp
platform/android/src/style/sources/source.cpp
platform/android/src/style/sources/source.hpp
platform/android/src/style/sources/sources.cpp
platform/android/src/style/sources/sources.hpp
platform/android/src/style/sources/raster_source.cpp
platform/android/src/style/sources/raster_source.hpp
platform/android/src/style/sources/vector_source.cpp
platform/android/src/style/sources/vector_source.hpp
# Connectivity
platform/android/src/connectivity_listener.cpp
platform/android/src/connectivity_listener.hpp
# Native map
platform/android/src/native_map_view.cpp
platform/android/src/native_map_view.hpp
# Main jni bindings
platform/android/src/attach_env.cpp
platform/android/src/attach_env.hpp
platform/android/src/java_types.cpp
platform/android/src/java_types.hpp
# Main entry point
platform/android/src/jni.hpp
platform/android/src/jni.cpp
)
target_include_directories(mbgl-core
PUBLIC 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 libzip)
target_add_mason_package(mbgl-core PUBLIC geojson)
target_add_mason_package(mbgl-core PUBLIC jni.hpp)
target_add_mason_package(mbgl-core PUBLIC rapidjson)
target_add_mason_package(mbgl-core PUBLIC icu)
target_compile_options(mbgl-core
PRIVATE -fvisibility=hidden
PRIVATE -ffunction-sections
PRIVATE -fdata-sections
PRIVATE -Os
)
target_link_libraries(mbgl-core
PUBLIC -llog
PUBLIC -landroid
PUBLIC -lEGL
PUBLIC -lGLESv2
PUBLIC -lstdc++
PUBLIC -latomic
PUBLIC -lz
PUBLIC -Wl,--gc-sections
)
endmacro()
## Main library ##
add_library(mapbox-gl SHARED
platform/android/src/main.cpp
)
add_dependencies(mapbox-gl
mbgl-copy-android-assets
)
target_compile_options(mapbox-gl
PRIVATE -fvisibility=hidden
PRIVATE -ffunction-sections
PRIVATE -fdata-sections
PRIVATE -Os
)
target_link_libraries(mapbox-gl
PUBLIC mbgl-core
PUBLIC -Wl,--gc-sections
)
# 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 ${STRIP_COMMAND} $<TARGET_FILE:mapbox-gl> -o ${ANDROID_JNI_TARGET_DIR}/$<TARGET_FILE_NAME:mapbox-gl>)
## Test library ##
add_library(mbgl-test SHARED
# Actual tests
${MBGL_TEST_FILES}
# Main test entry point
platform/android/src/test/main.jni.cpp
)
add_dependencies(mbgl-test
mapbox-gl
)
target_sources(mbgl-test
# Headless view
PRIVATE platform/default/mbgl/gl/headless_backend.cpp
PRIVATE platform/default/mbgl/gl/headless_backend.hpp
PRIVATE platform/default/mbgl/gl/offscreen_view.cpp
PRIVATE platform/default/mbgl/gl/offscreen_view.hpp
PRIVATE platform/linux/src/headless_backend_egl.cpp
PRIVATE platform/linux/src/headless_display_egl.cpp
)
target_compile_options(mbgl-test
PRIVATE -fvisibility=hidden
PRIVATE -Os
)
target_compile_definitions(mbgl-test
PRIVATE MBGL_ASSET_ZIP=1
)
target_include_directories(mbgl-test
PRIVATE include
PRIVATE src # TODO: eliminate
PRIVATE test/include
PRIVATE test/src
PRIVATE platform/default
PRIVATE ${MBGL_GENERATED}/include
)
target_link_libraries(mbgl-test
PRIVATE mbgl-core
)
target_add_mason_package(mbgl-test PRIVATE geometry)
target_add_mason_package(mbgl-test PRIVATE variant)
target_add_mason_package(mbgl-test PRIVATE unique_resource)
target_add_mason_package(mbgl-test PRIVATE rapidjson)
target_add_mason_package(mbgl-test PRIVATE gtest)
target_add_mason_package(mbgl-test PRIVATE pixelmatch)
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 ${STRIP_COMMAND} $<TARGET_FILE:mapbox-gl> -o ${CMAKE_CURRENT_BINARY_DIR}/stripped/$<TARGET_FILE_NAME:mapbox-gl>
COMMAND ${STRIP_COMMAND} $<TARGET_FILE:mbgl-test> -o ${CMAKE_CURRENT_BINARY_DIR}/stripped/$<TARGET_FILE_NAME:mbgl-test>)
## Custom layer example ##
add_library(example-custom-layer SHARED
platform/android/src/example_custom_layer.cpp
)
target_compile_options(example-custom-layer
PRIVATE -fvisibility=hidden
PRIVATE -ffunction-sections
PRIVATE -fdata-sections
PRIVATE -Os
)
target_link_libraries(example-custom-layer
PRIVATE mapbox-gl
PUBLIC -Wl,--gc-sections
)
add_custom_command(TARGET example-custom-layer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_TEST_APP_JNI_TARGET_DIR}
COMMAND ${STRIP_COMMAND} $<TARGET_FILE:example-custom-layer> -o ${ANDROID_TEST_APP_JNI_TARGET_DIR}/$<TARGET_FILE_NAME:example-custom-layer>)
|