Skip to content

Commit

Permalink
Merge branch 'mbtiles-build-options' into scene-refactor-base
Browse files Browse the repository at this point in the history
  • Loading branch information
hjanetzek committed Nov 30, 2018
2 parents 1acec75 + 07b6d0e commit e60e7d6
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ project(tangram)
# Options
option(TANGRAM_USE_SYSTEM_FONT_LIBS "Use system libraries Freetype, ICU and Harfbuzz via pkgconfig" OFF)
option(TANGRAM_USE_SYSTEM_GLFW_LIBS "Use system libraries for GLFW3 via pkgconfig" OFF)
option(TANGRAM_USE_SYSTEM_SQLITE_LIBS "Use system libraries for SQLite via pkgconfig" OFF)
option(TANGRAM_MBTILES_DATASOURCE "Build MBTiles Datasource" ON)

option(TANGRAM_BUILD_TESTS "Build unit tests" OFF)
option(TANGRAM_BUNDLE_TESTS "Compile all tests into a single binary" ON)
Expand Down
1 change: 1 addition & 0 deletions bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ foreach(_src_file_path ${BENCH_SOURCES})
)

target_link_libraries(${EXECUTABLE_NAME}
PRIVATE
tangram-core
benchmark
platform_mock
Expand Down
20 changes: 16 additions & 4 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ project(tangram-core)
# Build core library dependencies.
add_subdirectory(deps)

if (TANGRAM_MBTILES_DATASOURCE)
set(MBTILES_SOURCES src/data/mbtilesDataSource.cpp)
set(MBTILES_LIBS SQLiteCpp sqlite3)
endif()

add_library(tangram-core
src/map.cpp
src/platform.cpp
src/data/clientGeoJsonSource.cpp
src/data/mbtilesDataSource.cpp
src/data/memoryCacheDataSource.cpp
src/data/networkDataSource.cpp
src/data/properties.cpp
Expand Down Expand Up @@ -95,6 +99,7 @@ add_library(tangram-core
src/view/flyTo.cpp
src/view/view.cpp
src/view/viewConstraint.cpp
${MBTILES_SOURCES}
)

# Include headers from core library and dependencies.
Expand Down Expand Up @@ -128,12 +133,11 @@ target_include_directories(tangram-core
# Link core library dependencies.
target_link_libraries(tangram-core
PRIVATE
${MBTILES_LIBS}
duktape
css-color-parser-cpp
yaml-cpp
alfons
SQLiteCpp
sqlite3
double-conversion
miniz
z
Expand All @@ -145,7 +149,15 @@ if(UNIX AND NOT APPLE)
endif()

if(TANGRAM_WARN_ON_RULE_CONFLICT)
add_definitions(-DTANGRAM_WARN_ON_RULE_CONFLICT)
target_compile_definitions(tangram-core
PRIVATE
TANGRAM_WARN_ON_RULE_CONFLICT)
endif()

if (TANGRAM_MBTILES_DATASOURCE)
target_compile_definitions(tangram-core
PRIVATE
TANGRAM_MBTILES_DATASOURCE)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down
38 changes: 22 additions & 16 deletions core/deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,29 @@ endif()
set(GLM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glm)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/alfons)

## SQLiteCpp ##
###############
set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "")
set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "")
set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "")

add_subdirectory(SQLiteCpp)

# Extensions aren't needed for MBTiles and aren't available in older versions of sqlite3.
target_compile_definitions(SQLiteCpp PRIVATE SQLITE_OMIT_LOAD_EXTENSION)

# needed for sqlite3 to work for ndk15c+ and android api level < 21
# refer:
# https://github.com/android-ndk/ndk/issues/477 and
# https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
if (ANDROID)
if (TANGRAM_MBTILES_DATASOURCE)
## SQLiteCpp ##
###############
set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "")
set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "")
set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "")

if (TANGRAM_USE_SYSTEM_SQLITE_LIBS)
set(SQLITECPP_INTERNAL_SQLITE OFF CACHE BOOL "")
endif()

add_subdirectory(SQLiteCpp)

# Extensions aren't needed for MBTiles and aren't available in older versions of sqlite3.
target_compile_definitions(SQLiteCpp PRIVATE SQLITE_OMIT_LOAD_EXTENSION)

# needed for sqlite3 to work for ndk15c+ and android api level < 21
# refer:
# https://github.com/android-ndk/ndk/issues/477 and
# https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
if (ANDROID)
target_compile_definitions(sqlite3 PRIVATE _FILE_OFFSET_BITS=32)
endif()
endif()

## double-conversion ##
Expand Down
4 changes: 4 additions & 0 deletions core/src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,12 @@ SceneID Map::updateSceneAsync(const std::vector<SceneUpdate>& _sceneUpdates) {
}

void Map::setMBTiles(const char* _dataSourceName, const char* _mbtilesFilePath) {
#ifdef TANGRAM_MBTILES_DATASOURCE
std::string scenePath = std::string("sources.") + _dataSourceName + ".mbtiles";
updateSceneAsync({SceneUpdate{scenePath.c_str(), _mbtilesFilePath}});
#else
LOGE("MBTiles support is disabled. This source will be ignored: %s", _dataSourceName);
#endif
}

void Map::resize(int _newWidth, int _newHeight) {
Expand Down
5 changes: 5 additions & 0 deletions core/src/scene/sceneLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,10 +1038,15 @@ void SceneLoader::loadSource(const std::shared_ptr<Platform>& platform, const st
rawSources->setCacheSize(CACHE_SIZE);

if (isMBTilesFile) {
#ifdef TANGRAM_MBTILES_DATASOURCE
// If we have MBTiles, we know the source is tiled.
tiled = true;
// Create an MBTiles data source from the file at the url and add it to the source chain.
rawSources->setNext(std::make_unique<MBTilesDataSource>(platform, name, url, ""));
#else
LOGE("MBTiles support is disabled. This source will be ignored: %s", name.c_str());
return;
#endif
} else if (tiled) {
rawSources->setNext(std::make_unique<NetworkDataSource>(platform, url, std::move(subdomains), isTms));
}
Expand Down
5 changes: 4 additions & 1 deletion platforms/android/tangram/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ android {
'-Wignored-qualifiers',
'-Wtype-limits',
'-Wmissing-field-initializers',
'-Wno-format-pedantic'
'-Wno-format-pedantic',
'-Wno-gnu-statement-expression',
'-Wgnu-anonymous-struct',
'-Wno-nested-anon-types'

if (abi == 'all') {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
Expand Down
8 changes: 6 additions & 2 deletions platforms/linux/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ check_unsupported_compiler_version()

add_definitions(-DTANGRAM_LINUX)

get_nextzen_api_key(NEXTZEN_API_KEY)
add_definitions(-DNEXTZEN_API_KEY="${NEXTZEN_API_KEY}")

find_package(OpenGL REQUIRED)

Expand Down Expand Up @@ -75,4 +73,10 @@ target_compile_options(tangram
-Wmissing-field-initializers
)

get_nextzen_api_key(NEXTZEN_API_KEY)
target_compile_definitions(tangram
PRIVATE
NEXTZEN_API_KEY="${NEXTZEN_API_KEY}")


add_resources(tangram "${PROJECT_SOURCE_DIR}/scenes" "res")

0 comments on commit e60e7d6

Please sign in to comment.