Skip to content

Commit

Permalink
[c++,r,python] Move nanoarrow to src/external (#2383)
Browse files Browse the repository at this point in the history
* [c++,r] Move `nanoarrow` to `src/external`

* Slight tweak to CMakeLists, adjustment for vendoring

* Un-clang-format files restoring release 0.4.0 copies

* Re-adjust after rebase

* Path adjustment for nanoarrow include, pkg-config update

* Adjusting Python too

* Adjusting Python too, once more

* Adjust include path for R for the non pkg-config case too

* The Python installation for 'interop' needs another includes case
  • Loading branch information
eddelbuettel authored Apr 5, 2024
1 parent c6a6bcc commit d2b15c2
Show file tree
Hide file tree
Showing 15 changed files with 3,771 additions and 3,977 deletions.
2 changes: 2 additions & 0 deletions apis/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ def run(self):
INC_DIRS = [
"dist_links/libtiledbsoma/include",
"dist_links/libtiledbsoma/external/include",
"dist_links/libtiledbsoma/src/external/include",
"../../build/externals/install/include",
str(tiledbsoma_dir / "include"),
str(tiledbsoma_dir / "include/tiledbsoma"),
str(tiledbsoma_dir.parent / "build/externals/install/include"),
str(tiledbsoma_dir / "include"),
str(tiledb_dir / "include"),
Expand Down
2 changes: 1 addition & 1 deletion apis/r/configure
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export CXX="`${R_HOME}/bin/R CMD config CXX`"
export CMAKE_OSX_ARCHITECTURES="`uname -m`"
tools/build_libtiledbsoma.sh

pkgincl="-I../inst/tiledb/include -I../inst/tiledbsoma/include"
pkgincl="-I../inst/tiledb/include -I../inst/tiledbsoma/include -I../inst/tiledbsoma/include/tiledbsoma"
pkglibs="-ltiledb -L../inst/tiledb/lib -ltiledbsoma -L../inst/tiledbsoma/lib"
rpath="-Wl,-rpath,'\$\$ORIGIN/../tiledb/lib' -Wl,-rpath,'\$\$ORIGIN/../tiledbsoma/lib'"
macosver=`${R_HOME}/bin/Rscript -e 'if (Sys.info()["sysname"] == "Darwin") cat("-mmacosx-version-min=11.0") else cat("")'`
Expand Down
2 changes: 1 addition & 1 deletion apis/r/inst/include/tiledbsoma_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define TILEDB_NO_API_DEPRECATION_WARNINGS
#endif

#include <tiledbsoma/utils/nanoarrow.h> // for C interface to Arrow
#include <nanoarrow/nanoarrow.h> // for C interface to Arrow
#include <tiledb/tiledb> // for QueryCondition etc
#define ARROW_SCHEMA_AND_ARRAY_DEFINED 1
#include <tiledbsoma/tiledbsoma>
Expand Down
8 changes: 4 additions & 4 deletions apis/r/src/rinterface.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Rcpp.h> // for R interface to C++
#include <nanoarrow/r.h> // for C interface to Arrow (via R package)
#include <tiledbsoma/utils/nanoarrow.hpp> // for C/C++ interface to Arrow
#include <RcppInt64> // for fromInteger64
#include <Rcpp.h> // for R interface to C++
#include <nanoarrow/r.h> // for C interface to Arrow (via R package)
#include <nanoarrow/nanoarrow.hpp> // for C/C++ interface to Arrow
#include <RcppInt64> // for fromInteger64

// we currently get deprecation warnings by default which are noisy
#ifndef TILEDB_NO_API_DEPRECATION_WARNINGS
Expand Down
13 changes: 4 additions & 9 deletions apis/r/src/riterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
#define TILEDB_NO_API_DEPRECATION_WARNINGS
#endif

//#define RCPP_DEBUG_LEVEL 5

#include <Rcpp.h> // for R interface to C++
#include <nanoarrow/r.h> // for C interface to Arrow (via R package nanoarrow)
#include <tiledbsoma/utils/nanoarrow.h>
#include <RcppInt64> // for fromInteger64
#include <Rcpp.h> // for R interface to C++
#include <nanoarrow/r.h> // for C interface to Arrow (via R package nanoarrow)
#include <nanoarrow/nanoarrow.h>
#include <RcppInt64> // for fromInteger64

#include <tiledb/tiledb>
#if TILEDB_VERSION_MAJOR == 2 && TILEDB_VERSION_MINOR >= 4
#include <tiledb/tiledb_experimental>
#endif

// We get these via nanoarrow and must not include carrow.h again
#define ARROW_SCHEMA_AND_ARRAY_DEFINED 1
#include <tiledbsoma/tiledbsoma>

#include "rutilities.h" // local declarations
Expand Down
9 changes: 3 additions & 6 deletions apis/r/src/rutilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
#define TILEDB_NO_API_DEPRECATION_WARNINGS
#endif

#include <Rcpp.h> // for R interface to C++
#include <tiledbsoma/utils/nanoarrow.h> // for C interface to Arrow
#include <RcppInt64> // for fromInteger64

// We get these via nanoarrow and must cannot include carrow.h again
#define ARROW_SCHEMA_AND_ARRAY_DEFINED 1
#include <Rcpp.h> // for R interface to C++
#include <nanoarrow/nanoarrow.h> // for C interface to Arrow
#include <RcppInt64> // for fromInteger64
#include <tiledbsoma/tiledbsoma>

#include "rutilities.h" // local declarations
Expand Down
8 changes: 0 additions & 8 deletions apis/r/src/xptr-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const tiledb_xptr_object tiledb_xptr_vlv_buf_t { 180 };
const tiledb_xptr_object tiledb_xptr_query_buf_t { 190 };

// the definitions above are internal to tiledb-r but we need a new value here if we want tag the external pointer
const tiledb_xptr_object tiledb_arrow_array_t { 300 };
const tiledb_xptr_object tiledb_arrow_schema_t { 310 };

const tiledb_xptr_object tiledb_soma_reader_t { 500 };

// templated checkers for external pointer tags
Expand All @@ -52,10 +49,6 @@ template <> inline const int32_t XPtrTagType<tiledb::VFS> = til
// template <> inline const int32_t XPtrTagType<vlv_buf_t> = tiledb_xptr_vlv_buf_t;
// template <> inline const int32_t XPtrTagType<query_buf_t> = tiledb_xptr_query_buf_t;


template <> inline const int32_t XPtrTagType<ArrowArray> = tiledb_arrow_array_t;
template <> inline const int32_t XPtrTagType<ArrowSchema> = tiledb_arrow_schema_t;

template <> inline const int32_t XPtrTagType<tdbs::SOMAArray> = tiledb_soma_reader_t;

template <typename T> Rcpp::XPtr<T> make_xptr(T* p, bool finalize=true) {
Expand All @@ -81,4 +74,3 @@ template<typename T> void check_xptr_tag(Rcpp::XPtr<T> ptr) {
// in rinterface.cpp
Rcpp::XPtr<ArrowSchema> schema_owning_xptr(void);
Rcpp::XPtr<ArrowArray> array_owning_xptr(void);

2 changes: 1 addition & 1 deletion libtiledbsoma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# The MIT License
#
# Copyright (c) 2022-2023 TileDB, Inc.
# Copyright (c) 2022-2024 TileDB, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions libtiledbsoma/cmake/inputs/tiledbsoma.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ URL: https://github.com/single-cell-data/TileDB-SOMA
Version: @VERSION@
Requires: @PKGCONF_REQ_PUB@
Requires.private: @PKGCONF_REQ_PRIV@
Cflags: -I"${includedir}"
Cflags: -I"${includedir}" -I"${includedir}/tiledbsoma"
Libs: -L"${libdir}" -ltiledbsoma
Libs.private: -L"${libdir}" -ltiledbsoma @PKGCONF_LIBS_PRIV@
Libs.private: -L"${libdir}" -ltiledbsoma @PKGCONF_LIBS_PRIV@
21 changes: 13 additions & 8 deletions libtiledbsoma/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ message(STATUS "Building with commit hash ${BUILD_COMMIT_HASH}")
# Common object library
# ###########################################################
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/utils/nanoarrow.c PROPERTIES LANGUAGE CXX)
${CMAKE_CURRENT_SOURCE_DIR}/external/src/nanoarrow/nanoarrow.c PROPERTIES LANGUAGE CXX)

add_library(TILEDB_SOMA_OBJECTS OBJECT
${CMAKE_CURRENT_SOURCE_DIR}/reindexer/reindexer.cc
Expand All @@ -72,10 +72,10 @@ add_library(TILEDB_SOMA_OBJECTS OBJECT
${CMAKE_CURRENT_SOURCE_DIR}/utils/stats.cc
${CMAKE_CURRENT_SOURCE_DIR}/utils/util.cc
${CMAKE_CURRENT_SOURCE_DIR}/utils/version.cc
${CMAKE_CURRENT_SOURCE_DIR}/utils/nanoarrow.c

${CMAKE_CURRENT_SOURCE_DIR}/external/src/thread_pool/thread_pool.cc
${CMAKE_CURRENT_SOURCE_DIR}/external/src/thread_pool/status.cc
${CMAKE_CURRENT_SOURCE_DIR}/external/src/nanoarrow/nanoarrow.c
)

message(STATUS "Building TileDB without deprecation warnings")
Expand All @@ -90,6 +90,11 @@ target_compile_options(

set_property(TARGET TILEDB_SOMA_OBJECTS PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories(TILEDB_SOMA_OBJECTS
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/external/include/nanoarrow
)

target_include_directories(TILEDB_SOMA_OBJECTS
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
Expand Down Expand Up @@ -216,12 +221,6 @@ install(FILES
DESTINATION "include/tiledbsoma/reindexer/"
)

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/utils/nanoarrow.h
${CMAKE_CURRENT_SOURCE_DIR}/utils/nanoarrow.hpp
DESTINATION "include/tiledbsoma/utils/"
)

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/tiledbsoma/tiledbsoma
DESTINATION "include/tiledbsoma"
Expand All @@ -242,6 +241,12 @@ install(FILES
DESTINATION "include/tiledbsoma/soma/span"
)

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/external/include/nanoarrow/nanoarrow.h
${CMAKE_CURRENT_SOURCE_DIR}/external/include/nanoarrow/nanoarrow.hpp
DESTINATION "include/tiledbsoma/nanoarrow"
)


# ###########################################################
# API symbol exports
Expand Down
Loading

0 comments on commit d2b15c2

Please sign in to comment.