From d19b38e6d63af7c9c1dc496c72393965a19bc035 Mon Sep 17 00:00:00 2001 From: Tyler Denniston Date: Mon, 5 Mar 2018 17:18:58 -0500 Subject: [PATCH] Fix C++ API visibility Windows build errors. PR #412 Also several improvements to the AppVeyor config. (cherry picked from commit c74f443db443ade76723ee080aeaefd733f96739) --- .appveyor.yml | 65 ++++++++++++++++++- CMakeLists.txt | 21 +++--- HISTORY.md | 25 +++++++ examples/cpp_api/tiledb_map_write.cc | 4 +- tiledb/sm/c_api/tiledb.cc | 2 +- .../cpp_api/tiledb_cpp_api_core_interface.h | 2 +- .../sm/cpp_api/tiledb_cpp_api_schema_base.h | 2 +- 7 files changed, 104 insertions(+), 17 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index cb6e9ef14dc..0f405ab8d50 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -12,6 +12,11 @@ build_script: ..\scripts\install-deps.ps1 + if ($LastExitCode -ne 0) { + Write-Host "Deps install failed." + $host.SetShouldExit($LastExitCode) + } + if ($env:USE_S3 -eq "true") { ..\scripts\install-s3.ps1 ..\scripts\install-minio.ps1 @@ -19,13 +24,69 @@ build_script: } else { ..\bootstrap.ps1 -EnableVerbose } + + if ($LastExitCode -ne 0) { + Write-Host "Bootstrap failed." + $host.SetShouldExit($LastExitCode) + } + + cmake --build . --config Release + + if ($LastExitCode -ne 0) { + Write-Host "Build failed." + $host.SetShouldExit($LastExitCode) + } + test_script: - ps: >- cmake --build . --target check --config Release - cmake --build . --target examples + if ($LastExitCode -ne 0) { + Write-Host "Tests failed." + $host.SetShouldExit($LastExitCode) + } + + cmake --build . --target examples --config Release + + if ($LastExitCode -ne 0) { + Write-Host "Examples failed to build." + $host.SetShouldExit($LastExitCode) + } + + cmake --build . --target install --config Release + + if ($LastExitCode -ne 0) { + Write-Host "Installation failed." + $host.SetShouldExit($LastExitCode) + } + + $env:Path += ";$env:APPVEYOR_BUILD_FOLDER\dist\bin" + + try { + .\examples\c_api\Release\tiledb_dense_create_c.exe + } catch { + Write-Host "C API example failed." + $host.SetShouldExit(1) + } + + if ($LastExitCode -ne 0) { + Write-Host "C API example failed." + $host.SetShouldExit($LastExitCode) + } + + rm -Recurse -Force my_dense_array - cmake --build . --target install + try { + .\examples\cpp_api\Release\tiledb_dense_create_cpp.exe + } catch { + Write-Host "C++ API example failed." + $host.SetShouldExit(1) + } + + if ($LastExitCode -ne 0) { + Write-Host "C++ API example failed." + $host.SetShouldExit($LastExitCode) + } mkdir dist diff --git a/CMakeLists.txt b/CMakeLists.txt index 92b4362bdb4..529834a278d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,28 +75,28 @@ endif() if(USE_HDFS) find_package(LIBJVM REQUIRED) set(TILEDB_LIB_DEPENDENCIES ${TILEDB_LIB_DEPENDENCIES} ${LIBJVM_LIBRARIES}) - + find_package(LIBHDFS REQUIRED) include_directories(${LIBHDFS_INCLUDE_DIR}) # This variable is defined in FindJNI module included in the FindHDFS.cmake file set(TILEDB_LIB_DEPENDENCIES ${TILEDB_LIB_DEPENDENCIES} ${LIBHDFS_LIBRARY}) endif() -if(USE_S3) +if(USE_S3) cmake_minimum_required(VERSION 3.2) find_package(AWSSDK) message(STATUS "AWSSDK_LIB_DIR: ${AWSSDK_LIB_DIR}") message(STATUS "AWSSDK_INC_DIR: ${AWSSDK_INCLUDE_DIR}") message(STATUS "AWSSDK_BIN_DIR: ${AWSSDK_BIN_DIR}") - + set(AWS_SERVICE s3) AWSSDK_LIB_DEPS(AWS_SERVICE AWS_DEPS) - + message(STATUS "AWS service ${AWS_SERVICE} depends on libs: ${AWS_DEPS}") AWSSDK_DETERMINE_LIBS_TO_LINK(AWS_SERVICE AWS_LINKED_LIBS) message(STATUS "AWS linked libs: ${AWS_LINKED_LIBS}") - + set(AWS_LIBRARIES) foreach(LIB ${AWS_LINKED_LIBS}) find_library("AWS_FOUND_${LIB}" NAMES ${LIB} PATHS ${AWSSDK_LIB_DIR} NO_DEFAULT_PATH) @@ -129,11 +129,12 @@ if (WIN32) # We disable some warnings that are not present in gcc/clang -Wall: # C4101: unreferenced local variable # C4244: conversion warning of floating point to integer type. + # C4251: C++ export warning # C4456: local variable hiding previous local variable # C4457: local variable hiding function parameter # C4702: unreachable code # C4996: deprecation warning about e.g. sscanf. - set(MSVC_DISABLE_WARNINGS "/wd4101 /wd4244 /wd4456 /wd4457 /wd4702 /wd4996") + set(MSVC_DISABLE_WARNINGS "/wd4101 /wd4244 /wd4251 /wd4456 /wd4457 /wd4702 /wd4996") # Note: MSVC has the behavior of -fvisibility=hidden by default (you must # explicitly export all symbols you want exported). set(CMAKE_CXX_FLAGS_DEBUG "/DDEBUG /Od /Zi /W4 /WX ${MSVC_DISABLE_WARNINGS}") @@ -234,13 +235,13 @@ if(DOXYGEN_FOUND) add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/doxyfile.in COMMAND mkdir -p doxygen - COMMAND echo INPUT = ${CMAKE_SOURCE_DIR}/doc/mainpage.dox + COMMAND echo INPUT = ${CMAKE_SOURCE_DIR}/doc/mainpage.dox ${TILEDB_CORE_HEADERS} > ${CMAKE_BINARY_DIR}/doxyfile.in COMMAND echo FILE_PATTERNS = *.h >> ${CMAKE_BINARY_DIR}/doxyfile.in COMMENT "Preparing for Doxygen documentation" VERBATIM ) add_custom_target( - doc ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile.mk > + doc ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile.mk > ${CMAKE_BINARY_DIR}/Doxyfile.log 2>&1 COMMENT "Generating API documentation with Doxygen" VERBATIM DEPENDS ${CMAKE_BINARY_DIR}/doxyfile.in @@ -250,9 +251,9 @@ endif(DOXYGEN_FOUND) ########################################################### # Uninstall ########################################################### -set(CMD "xargs printf '-- Uninstalling: %s\\\\n' ` can now be used with compound `T`, such as `std::string` and `std::vector`, and other + objects such as a simple data struct. + +## Improvements +* Fix issue when linking to the C++ API via the shared library. (#408). + +## Breaking changes + +### C API +### C++ API +* `max_buffer_elements` was renamed to `max_buffer_sizes` and now reports sizes in bytes instead of number of elements. This was done to support + arbitrary POD types. +* Buffer size reporting for variable-sized attributes was normalized: offsets will always come first. This impacts `Array::max_buffer_sizes` and `Query::result_buffer_elements`. + If `pair.first` is 0, it is a fixed size attribute. +* `std::array` is backed by a `char` tiledb attribute since the size is not guaranteed. +* `Attribute::set_cell_val_num()` is deprecated. This is now deduced from the Attribute type. +* Headers have the `tiledb_cpp_api_` prefix removed. For example, the include is now `#include ` + # TileDB v1.2.0 Release Notes The 1.2.0 release of TileDB includes many new features, improvements in stability and performance, and two new language interfaces (Python and C++). There are also several breaking changes in the C API and on-disk format, documented below. diff --git a/examples/cpp_api/tiledb_map_write.cc b/examples/cpp_api/tiledb_map_write.cc index 5f62b30b2e7..840d0d059f1 100644 --- a/examples/cpp_api/tiledb_map_write.cc +++ b/examples/cpp_api/tiledb_map_write.cc @@ -74,8 +74,8 @@ int main() { // Create an item, assign values, and add to the map in a single op int t1 = 3; std::string t2{"ccc"}; - std::vector t3{3.1f, 3.2f}; - map[std::vector{300, 300.1}][{"a1", "a2", "a3"}] = + std::array t3{{3.1f, 3.2f}}; + map[std::vector({{300, 300.1}})][{"a1", "a2", "a3"}] = std::make_tuple(t1, t2, t3); // Update an existing key. Old values for a2, a3 will be carried over. diff --git a/tiledb/sm/c_api/tiledb.cc b/tiledb/sm/c_api/tiledb.cc index a79dcce5856..026b31d808f 100644 --- a/tiledb/sm/c_api/tiledb.cc +++ b/tiledb/sm/c_api/tiledb.cc @@ -3037,7 +3037,7 @@ int tiledb_uri_to_path( /* C++ API */ /* ****************************** */ -TILEDB_EXPORT int tiledb::impl::tiledb_query_submit_async( +int tiledb::impl::tiledb_query_submit_async( tiledb_ctx_t* ctx, tiledb_query_t* query, std::function callback, diff --git a/tiledb/sm/cpp_api/tiledb_cpp_api_core_interface.h b/tiledb/sm/cpp_api/tiledb_cpp_api_core_interface.h index 79fe929a38b..77fc075be4d 100644 --- a/tiledb/sm/cpp_api/tiledb_cpp_api_core_interface.h +++ b/tiledb/sm/cpp_api/tiledb_cpp_api_core_interface.h @@ -55,7 +55,7 @@ namespace impl { * @param callback_data Data to pass callback * @return TILEDB_OK for success and TILEDB_ERR for error. */ -int tiledb_query_submit_async( +TILEDB_EXPORT int tiledb_query_submit_async( tiledb_ctx_t* ctx, tiledb_query_t* query, std::function callback, diff --git a/tiledb/sm/cpp_api/tiledb_cpp_api_schema_base.h b/tiledb/sm/cpp_api/tiledb_cpp_api_schema_base.h index 8ca67b2327e..ab9068c096c 100644 --- a/tiledb/sm/cpp_api/tiledb_cpp_api_schema_base.h +++ b/tiledb/sm/cpp_api/tiledb_cpp_api_schema_base.h @@ -49,7 +49,7 @@ class Compressor; * Base class for TileDB schemas. This is intended * for all array-backed stores. */ -class Schema { +class TILEDB_EXPORT Schema { public: const Context& context() const { return ctx_.get();