diff --git a/CMakeLists.txt b/CMakeLists.txt index 7067bedc..2f3fa491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,9 @@ add_definitions(-DDUCKDB_PATCH_VERSION=${DUCKDB_PATCH_VERSION}) # Enable network functionality (OpenSSL and GDAL's CURL based fs/drivers) option(SPATIAL_USE_NETWORK "Enable network functionality" ON) -if (EMSCRIPTEN OR IOS OR ANDROID) +if(EMSCRIPTEN + OR IOS + OR ANDROID) set(SPATIAL_USE_NETWORK OFF) endif() @@ -32,7 +34,6 @@ include_directories(spatial/third_party/protozero/include) include_directories(spatial/third_party/shapelib) add_subdirectory(spatial/third_party/shapelib) - add_library(${EXTENSION_NAME} STATIC ${EXTENSION_SOURCES}) # Build dependencies TODO: in the future we should allow users to dynamically @@ -44,10 +45,8 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/deps) execute_process( # Generate project COMMAND - ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} - -DDUCKDB_ENABLE_DEPRECATED_API=1 - -DWASM_LOADABLE_EXTENSIONS=1 - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -DDUCKDB_ENABLE_DEPRECATED_API=1 + -DWASM_LOADABLE_EXTENSIONS=1 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DOSX_BUILD_ARCH=${OSX_BUILD_ARCH} -DSPATIAL_USE_NETWORK=${SPATIAL_USE_NETWORK} -DOPENSSL_ROOT_DIR=$ENV{OPENSSL_ROOT_DIR} @@ -55,8 +54,8 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/deps) -DVCPKG_INSTALLED_DIR='${CMAKE_BINARY_DIR}/vcpkg_installed' -DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}' -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}' - -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE='${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}' - -S ${CMAKE_CURRENT_SOURCE_DIR}/deps -B ${CMAKE_BINARY_DIR}/deps + -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE='${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}' -S + ${CMAKE_CURRENT_SOURCE_DIR}/deps -B ${CMAKE_BINARY_DIR}/deps RESULT_VARIABLE DEPENDENCIES_GENERATE_RESULT) if(NOT DEPENDENCIES_GENERATE_RESULT EQUAL 0) message(FATAL_ERROR "Could not generate dependencies project") @@ -83,7 +82,7 @@ message(STATUS "Find libraries path: '${CMAKE_PREFIX_PATH}'") set(ZLIB_USE_STATIC_LIBS ON) set(OPENSSL_USE_STATIC_LIBS ON) -if (EMSCRIPTEN) +if(EMSCRIPTEN) set(OPENSSL_USE_STATIC_LIBS OFF) endif() @@ -97,16 +96,15 @@ find_package(EXPAT REQUIRED) find_package(GeographicLib REQUIRED) # Important: The link order matters, its the reverse order of dependency -set(EXTENSION_DEPENDENCIES - GDAL::GDAL - GEOS::geos_c - PROJ::proj - EXPAT::EXPAT - SQLite::SQLite3 - ZLIB::ZLIB - ${SQLITE3_MEMVFS} - ${GeographicLib_LIBRARIES} -) +set(EXTENSION_DEPENDENCIES + GDAL::GDAL + GEOS::geos_c + PROJ::proj + EXPAT::EXPAT + SQLite::SQLite3 + ZLIB::ZLIB + ${SQLITE3_MEMVFS} + ${GeographicLib_LIBRARIES}) if(SPATIAL_USE_NETWORK) message(STATUS "Building with network functionality") @@ -125,7 +123,7 @@ if((NOT EMSCRIPTEN) AND (NOT IOS)) find_library(CoreFoundation_Library CoreFoundation) find_library(SystemConfiguration_Library SystemConfiguration) list(APPEND EXTENSION_DEPENDENCIES ${CoreFoundation_Library} - ${SystemConfiguration_Library}) + ${SystemConfiguration_Library}) endif() endif() @@ -139,7 +137,8 @@ target_link_libraries(${EXTENSION_NAME} PUBLIC ${EXTENSION_DEPENDENCIES}) set(PARAMETERS "-warnings") build_loadable_extension(${TARGET_NAME} ${PARAMETERS} ${EXTENSION_SOURCES}) -target_link_libraries(${TARGET_NAME}_loadable_extension ${EXTENSION_DEPENDENCIES}) +target_link_libraries(${TARGET_NAME}_loadable_extension + ${EXTENSION_DEPENDENCIES}) install( TARGETS ${EXTENSION_NAME} diff --git a/spatial/include/spatial/doc_util.hpp b/spatial/include/spatial/doc_util.hpp index 5745f67c..86fca3eb 100644 --- a/spatial/include/spatial/doc_util.hpp +++ b/spatial/include/spatial/doc_util.hpp @@ -11,13 +11,14 @@ struct DocTag { struct DocUtil { static void AddDocumentation(duckdb::DatabaseInstance &db, const char *function_name, const char *description, - const char *example, - const duckdb::unordered_map &tags, duckdb::vector parameter_names = {}); + const char *example, const duckdb::unordered_map &tags, + duckdb::vector parameter_names = {}); // Abuse adding tags as a comment template static void AddDocumentation(duckdb::DatabaseInstance &db, const char *function_name, const char *description, - const char *example, const DocTag (&tags)[N], duckdb::vector parameter_names = {}) { + const char *example, const DocTag (&tags)[N], + duckdb::vector parameter_names = {}) { duckdb::unordered_map tag_map; for (size_t i = 0; i < N; i++) { tag_map[tags[i].key] = tags[i].value; diff --git a/spatial/src/spatial/geos/functions/aggregate.cpp b/spatial/src/spatial/geos/functions/aggregate.cpp index c4787863..d4aec18b 100644 --- a/spatial/src/spatial/geos/functions/aggregate.cpp +++ b/spatial/src/spatial/geos/functions/aggregate.cpp @@ -197,8 +197,9 @@ void GeosAggregateFunctions::Register(DatabaseInstance &db) { AggregateFunctionSet st_intersection_agg("ST_Intersection_Agg"); st_intersection_agg.AddFunction( - AggregateFunction::UnaryAggregateDestructor( - core::GeoTypes::GEOMETRY(), core::GeoTypes::GEOMETRY())); + AggregateFunction::UnaryAggregateDestructor(core::GeoTypes::GEOMETRY(), + core::GeoTypes::GEOMETRY())); ExtensionUtil::RegisterFunction(db, st_intersection_agg); DocUtil::AddDocumentation(db, "ST_Intersection_Agg", INTERSECTION_DOC_DESCRIPTION, INTERSECTION_DOC_EXAMPLE, @@ -206,8 +207,9 @@ void GeosAggregateFunctions::Register(DatabaseInstance &db) { AggregateFunctionSet st_union_agg("ST_Union_Agg"); st_union_agg.AddFunction( - AggregateFunction::UnaryAggregateDestructor( - core::GeoTypes::GEOMETRY(), core::GeoTypes::GEOMETRY())); + AggregateFunction::UnaryAggregateDestructor(core::GeoTypes::GEOMETRY(), + core::GeoTypes::GEOMETRY())); ExtensionUtil::RegisterFunction(db, st_union_agg); DocUtil::AddDocumentation(db, "ST_Union_Agg", UNION_DOC_DESCRIPTION, UNION_DOC_EXAMPLE, DOC_TAGS); diff --git a/spatial/src/spatial/geos/functions/scalar/st_buffer.cpp b/spatial/src/spatial/geos/functions/scalar/st_buffer.cpp index 78b034e4..05833550 100644 --- a/spatial/src/spatial/geos/functions/scalar/st_buffer.cpp +++ b/spatial/src/spatial/geos/functions/scalar/st_buffer.cpp @@ -130,7 +130,8 @@ void GEOSScalarFunctions::RegisterStBuffer(DatabaseInstance &db) { GEOSFunctionLocalState::Init)); ExtensionUtil::RegisterFunction(db, set); - DocUtil::AddDocumentation(db, "ST_Buffer", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS, {"geom", "distance", "num_triangles", "join_style", "cap_style", "mitre_limit"}); + DocUtil::AddDocumentation(db, "ST_Buffer", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS, + {"geom", "distance", "num_triangles", "join_style", "cap_style", "mitre_limit"}); } } // namespace geos diff --git a/spatial/src/spatial/proj/functions.cpp b/spatial/src/spatial/proj/functions.cpp index 554c77a3..9a7b962c 100644 --- a/spatial/src/spatial/proj/functions.cpp +++ b/spatial/src/spatial/proj/functions.cpp @@ -510,7 +510,8 @@ void ProjFunctions::Register(DatabaseInstance &db) { GeometryTransformFunction, TransformBind, nullptr, nullptr, ProjFunctionLocalState::Init)); ExtensionUtil::RegisterFunction(db, set); - DocUtil::AddDocumentation(db, "ST_Transform", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS, {"geom", "source_crs", "target_crs", "always_xy"}); + DocUtil::AddDocumentation(db, "ST_Transform", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS, + {"geom", "source_crs", "target_crs", "always_xy"}); GenerateSpatialRefSysTable::Register(db); } diff --git a/spatial/src/spatial_extension.cpp b/spatial/src/spatial_extension.cpp index 488cd1ff..f5839843 100644 --- a/spatial/src/spatial_extension.cpp +++ b/spatial/src/spatial_extension.cpp @@ -54,7 +54,7 @@ static string RemoveIndentAndTrailingWhitespace(const char *text) { void spatial::DocUtil::AddDocumentation(duckdb::DatabaseInstance &db, const char *function_name, const char *description, const char *example, const duckdb::unordered_map &tags, - duckdb::vector parameter_names) { + duckdb::vector parameter_names) { auto &system_catalog = Catalog::GetSystemCatalog(db); auto data = CatalogTransaction::GetSystemTransaction(db);