diff --git a/r/R/zzz.R b/r/R/zzz.R index be952a6b4f7..21bc504360e 100644 --- a/r/R/zzz.R +++ b/r/R/zzz.R @@ -15,6 +15,19 @@ # specific language governing permissions and limitations # under the License. -#' @useDynLib arrow, .registration = TRUE #' @importFrom Rcpp sourceCpp NULL + +NAMESPACE <- environment() + +.onLoad <- function(libname, pkgname) { + dll <- library.dynam("arrow", pkgname, libname) + + for(routine in getDLLRegisteredRoutines(dll)$.Call) { + assign(routine$name, routine, envir = NAMESPACE) + } +} + +.onUnload <- function(libpath) { + library.dynam.unload("arrow", libpath) +} diff --git a/r/configure b/r/configure index 10045d3c5ec..11bd4bcd1be 100755 --- a/r/configure +++ b/r/configure @@ -43,11 +43,9 @@ fi # Note that cflags may be empty in case of success if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then echo "Found INCLUDE_DIR and/or LIB_DIR!" - PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS" PKG_LIBS="-L$LIB_DIR $PKG_LIBS" elif [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then echo "Found pkg-config cflags and libs!" - PKG_CFLAGS=${PKGCONFIG_CFLAGS} PKG_LIBS=${PKGCONFIG_LIBS} elif [[ "$OSTYPE" == "darwin"* ]]; then if [ "$(command -v brew)" ]; then @@ -56,22 +54,21 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then curl -sfL "https://jeroen.github.io/autobrew/$PKG_BREW_NAME" > autobrew source autobrew fi - PKG_CFLAGS="-I$BREWDIR/opt/$PKG_BREW_NAME/include" PKG_LIBS="-L$BREWDIR/opt/$PKG_BREW_NAME/lib $PKG_LIBS" fi -PKG_CFLAGS="$PKG_CFLAGS -DARROW_R_WITH_PARQUET" - -# For debugging -echo "PKG_CFLAGS=$PKG_CFLAGS" -echo "PKG_LIBS=$PKG_LIBS" - # Find compiler CXXCPP=$("${R_HOME}"/bin/R CMD config CXXCPP) CXX11FLAGS=$("${R_HOME}"/bin/R CMD config CXX11FLAGS) CXX11STD=$("${R_HOME}"/bin/R CMD config CXX11STD) CPPFLAGS=$("${R_HOME}"/bin/R CMD config CPPFLAGS) +PKG_CFLAGS="-I../inst/include -DARROW_R_WITH_PARQUET" + +# For debugging +echo "PKG_CFLAGS=$PKG_CFLAGS" +echo "PKG_LIBS=$PKG_LIBS" + # If libarrow uses the old GLIBCXX ABI, so we have to use it too if [ "$ARROW_USE_OLD_CXXABI" ]; then $PKG_CFLAGS="$PKG_CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0" diff --git a/r/data-raw/arrow_headers.R b/r/data-raw/arrow_headers.R new file mode 100644 index 00000000000..b81e3901261 --- /dev/null +++ b/r/data-raw/arrow_headers.R @@ -0,0 +1,21 @@ +library(fs) +library(magrittr) +library(glue) + +copy_headers <- function(dir) { + origin <- glue("../cpp/src/{dir}") + dest <- glue("r/inst/include/{dir}") + + # copy all files + try(dir_delete(dest), silent = TRUE) + dir_copy(origin, dest) + + # only keep headers + dir_ls(dest, glob = "*.h", invert = TRUE, all = TRUE, recurse = TRUE, type = "file") %>% + file_delete() + + message(glue("{n} header files copied in `{dest}`", n = length(dir_ls(dest, recurse = TRUE)))) + invisible() +} +copy_headers("arrow") +copy_headers("parquet") diff --git a/r/man/table.Rd b/r/man/table.Rd index 4d93ff385b5..fbf9632a03a 100644 --- a/r/man/table.Rd +++ b/r/man/table.Rd @@ -9,7 +9,10 @@ table(..., schema = NULL) \arguments{ \item{...}{arrays, chunked arrays, or R vectors} -\item{schema}{NULL or a schema} +\item{schema}{a schema. The default (\code{NULL}) infers the schema from the \code{...}} +} +\value{ +an arrow::Table } \description{ Create an arrow::Table from a data frame