This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new 22eab6b8 feat: Meson support (#413)
22eab6b8 is described below
commit 22eab6b89576874743d0da212381f9b7809f186c
Author: William Ayd <[email protected]>
AuthorDate: Mon Apr 8 13:34:07 2024 -0400
feat: Meson support (#413)
Not sure if there is a desire for supporting another build backend, but
figured I would share in case.
Meson seems a bit simpler than the existing CMake configuration, and has
the advantage of:
1. Installing dependencies via the wrap database easily
2. Potentially making nanoarrow installable via the
[WrapDB](https://mesonbuild.com/Adding-new-projects-to-wrapdb.html)
Point 2 is not covered here, but might be a nice future enhancement for
downstream Python libraries like NumPy and pandas that use Meson as
their build systems
---
.github/workflows/meson-build.yaml | 66 +++++++++++
.gitignore | 3 +
CMakeLists.txt | 1 +
README.md | 44 +++++++
ci/scripts/build-with-meson.sh | 103 +++++++++++++++++
.gitignore => dev/benchmarks/c/meson.build | 24 ++--
.gitignore => dev/benchmarks/meson.build | 15 +--
dev/release/utils-prepare.sh | 3 +
examples/meson-minimal/README.md | 43 +++++++
.gitignore => examples/meson-minimal/meson.build | 30 ++---
examples/meson-minimal/src/app.cc | 26 +++++
.../meson-minimal/subprojects/nanoarrow.wrap | 21 ++--
meson.build | 50 ++++++++
meson.options | 33 ++++++
src/nanoarrow/meson.build | 128 +++++++++++++++++++++
15 files changed, 538 insertions(+), 52 deletions(-)
diff --git a/.github/workflows/meson-build.yaml
b/.github/workflows/meson-build.yaml
new file mode 100644
index 00000000..5f06b707
--- /dev/null
+++ b/.github/workflows/meson-build.yaml
@@ -0,0 +1,66 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Meson Build Testing
+
+on:
+ schedule:
+ - cron: '5 0 * * 0'
+ pull_request:
+ branches:
+ - main
+ paths:
+ - '**meson.build'
+ - 'meson.options'
+ - '.github/workflows/meson-build.yaml'
+ - 'ci/scripts/build-with-meson.sh'
+
+permissions:
+ contents: read
+
+jobs:
+ verify-meson:
+ name: meson-build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install system dependencies
+ run: |
+ sudo apt-get update && sudo apt-get install -y lcov ninja-build
valgrind
+
+ - name: Install meson
+ run: |
+ python3 -m pip install meson
+
+ - name: Cache Arrow C++ Build
+ id: cache-arrow-build
+ uses: actions/cache@v4
+ with:
+ path: arrow
+ # Bump the number at the end of this line to force a new Arrow C++
build
+ key: arrow-meson-build-10
+
+ - name: Build Arrow C++
+ if: steps.cache-arrow-build.outputs.cache-hit != 'true'
+ shell: bash
+ run: |
+ ci/scripts/build-arrow-cpp-minimal.sh 15.0.2 arrow
+
+ - name: Run meson testing script
+ run: |
+ PKG_CONFIG_PATH="$(pwd)/arrow/lib/pkgconfig"
ci/scripts/build-with-meson.sh
diff --git a/.gitignore b/.gitignore
index 12399570..9ac62842 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,6 @@ CMakeUserPresets.json
.cache
*.swp
__pycache__
+
+# meson subprojects
+subprojects
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6ae3b810..0e0f12a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -243,6 +243,7 @@ if(NANOARROW_BUILD_TESTS)
add_subdirectory("thirdparty/googletest")
+ # Be sure to keep these tests in sync with src/nanoarrow/meson.build
add_executable(utils_test src/nanoarrow/utils_test.cc)
add_executable(buffer_test src/nanoarrow/buffer_test.cc)
add_executable(array_test src/nanoarrow/array_test.cc)
diff --git a/README.md b/README.md
index b130934f..98db3b3d 100644
--- a/README.md
+++ b/README.md
@@ -95,3 +95,47 @@ int print_simple_array(struct ArrowArray* array, struct
ArrowSchema* schema) {
return NANOARROW_OK;
}
```
+
+## Building with Meson
+
+CMake is the officially supported build system for nanoarrow. However, the
Meson backend is an experimental feature you may also wish to try.
+
+To run the test suite with Meson, you will want to first install the testing
dependencies via the wrap database (n.b. no wrap database entry exists for
Arrow - that must be installed separately).
+
+```sh
+mkdir subprojects
+meson wrap install gtest
+meson wrap install google-benchmark
+meson wrap install nlohmann_json
+```
+
+The Arrow C++ library must also be discoverable via pkg-config build tests.
+
+You can then set up your build directory:
+
+```sh
+meson setup builddir
+cd builddir
+```
+
+And configure your project (this could have also been done inline with
``setup``)
+
+```sh
+meson configure -DNANOARROW_BUILD_TESTS=true -DNANOARROW_BUILD_BENCHMARKS=true
+```
+
+Note that if your Arrow pkg-config profile is installed in a non-standard
location on your system, you may pass the ``--pkg-config-path <path to
directory with arrow.pc>`` to either the setup or configure steps above.
+
+With the above out of the way, the ``compile`` command should take care of the
rest:
+
+```sh
+meson compile
+```
+
+Upon a successful build you can execute the test suite and benchmarks with the
following commands:
+
+```sh
+meson test nanoarrow: # default test run
+meson test nanoarrow: --wrap valgrind # run tests under valgrind
+meson test nanoarrow: --benchmark --verbose # run benchmarks
+```
diff --git a/ci/scripts/build-with-meson.sh b/ci/scripts/build-with-meson.sh
new file mode 100755
index 00000000..cd552f21
--- /dev/null
+++ b/ci/scripts/build-with-meson.sh
@@ -0,0 +1,103 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+set -o pipefail
+
+if [ ${VERBOSE:-0} -gt 0 ]; then
+ set -x
+fi
+
+SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
+NANOARROW_DIR="$(cd "${SOURCE_DIR}/../.." && pwd)"
+
+show_header() {
+ if [ -z "$GITHUB_ACTIONS" ]; then
+ echo ""
+ printf '=%.0s' $(seq ${#1}); printf '\n'
+ echo "${1}"
+ printf '=%.0s' $(seq ${#1}); printf '\n'
+ else
+ echo "::group::${1}"; printf '\n'
+ fi
+}
+
+
+case $# in
+ 0) TARGET_NANOARROW_DIR="${NANOARROW_DIR}"
+ ;;
+ 1) TARGET_NANOARROW_DIR="$1"
+ ;;
+ *) echo "Usage:"
+ echo " Build nanoarrow based on a source checkout elsewhere:"
+ echo " $0 path/to/arrow-nanoarrow"
+ exit 1
+ ;;
+esac
+
+function main() {
+ pushd ${TARGET_NANOARROW_DIR}
+
+ SANDBOX_DIR="_meson_builddir"
+ if [ -d "${SANDBOX_DIR}" ]; then
+ rm -rf "${SANDBOX_DIR}"
+ fi
+ mkdir "${SANDBOX_DIR}"
+
+ SUBPROJ_DIR="subprojects"
+ if [ -d "${SUBPROJ_DIR}" ]; then
+ rm -rf "${SUBPROJ_DIR}"
+ fi
+ mkdir "${SUBPROJ_DIR}"
+
+ show_header "Install subprojects"
+ meson wrap install gtest
+ meson wrap install google-benchmark
+ meson wrap install nlohmann_json
+
+ show_header "Compile project with meson"
+ meson setup "${SANDBOX_DIR}" --pkg-config-path $PKG_CONFIG_PATH
+
+ pushd "${SANDBOX_DIR}"
+
+ show_header "Run test suite"
+ meson configure -DNANOARROW_BUILD_TESTS=true \
+ -Db_coverage=true
+ meson compile
+ meson test --wrap valgrind
+
+ show_header "Run benchmarks"
+ meson configure -DNANOARROW_BUILD_BENCHMARKS=true
+ meson compile
+ meson test --benchmark
+
+ show_header "Generate coverage reports"
+ ninja coverage
+ lcov --list meson-logs/coverage.info
+
+ popd
+
+ # Clean up subprojects and build folder
+ rm -rf "${SANDBOX_DIR}"
+ rm -rf "${SUBPROJ_DIR}"
+
+ popd
+}
+
+main
diff --git a/.gitignore b/dev/benchmarks/c/meson.build
similarity index 62%
copy from .gitignore
copy to dev/benchmarks/c/meson.build
index 12399570..5e02feb2 100644
--- a/.gitignore
+++ b/dev/benchmarks/c/meson.build
@@ -6,7 +6,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
@@ -15,15 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-_coverage/
-build/
-scratch/
-out/
-arrow-hpp
-.DS_Store
-CMakeUserPresets.json
-.vscode
-.Rproj.user
-.cache
-*.swp
-__pycache__
+gbench = dependency('benchmark')
+schema_e = executable('schema_benchmark',
+ 'schema_benchmark.cc',
+ dependencies: [gbench, nanoarrow_dep])
+benchmark('schema benchmark', schema_e)
+
+array_e = executable('array_benchmark',
+ 'array_benchmark.cc',
+ dependencies: [gbench, nanoarrow_dep])
+benchmark('array benchmark', array_e)
diff --git a/.gitignore b/dev/benchmarks/meson.build
similarity index 81%
copy from .gitignore
copy to dev/benchmarks/meson.build
index 12399570..d649a1aa 100644
--- a/.gitignore
+++ b/dev/benchmarks/meson.build
@@ -6,7 +6,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
@@ -15,15 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-_coverage/
-build/
-scratch/
-out/
-arrow-hpp
-.DS_Store
-CMakeUserPresets.json
-.vscode
-.Rproj.user
-.cache
-*.swp
-__pycache__
+subdir('c')
diff --git a/dev/release/utils-prepare.sh b/dev/release/utils-prepare.sh
index 7ac57f61..a2e91a67 100755
--- a/dev/release/utils-prepare.sh
+++ b/dev/release/utils-prepare.sh
@@ -42,6 +42,9 @@ update_versions() {
sed -i.bak -E "s/set\(NANOARROW_VERSION \".+\"\)/set(NANOARROW_VERSION
\"${version}\")/g" CMakeLists.txt
rm CMakeLists.txt.bak
git add CMakeLists.txt
+ sed -i.bak -E "s/version: '.+'\/version: '${version}')/g" meson.build
+ rm meson.build.bak
+ git add meson.build
popd
pushd "${NANOARROW_DIR}/r"
diff --git a/examples/meson-minimal/README.md b/examples/meson-minimal/README.md
new file mode 100644
index 00000000..7bc1deac
--- /dev/null
+++ b/examples/meson-minimal/README.md
@@ -0,0 +1,43 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+# Minimal Meson Example
+
+This folder contains a meson project that links to its own copy of
+nanoarrow using a subproject.
+
+To build the project:
+
+```bash
+git clone https://github.com/apache/arrow-nanoarrow.git
+cd arrow-nanoarrow/examples/meson-minimal
+meson setup builddir && cd builddir
+meson compile
+```
+
+After building, you can run the app from the build directory. The app
+parses command line arguments into an int32 array and prints out the
+resulting length (or any error encountered whilst building the array).
+
+```bash
+./example_meson_minimal_app
+# 1
+# 2
+# 3
+```
diff --git a/.gitignore b/examples/meson-minimal/meson.build
similarity index 61%
copy from .gitignore
copy to examples/meson-minimal/meson.build
index 12399570..21a97601 100644
--- a/.gitignore
+++ b/examples/meson-minimal/meson.build
@@ -6,7 +6,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
@@ -15,15 +15,19 @@
# specific language governing permissions and limitations
# under the License.
-_coverage/
-build/
-scratch/
-out/
-arrow-hpp
-.DS_Store
-CMakeUserPresets.json
-.vscode
-.Rproj.user
-.cache
-*.swp
-__pycache__
+project(
+ 'nanoarrow-example-meson-minimal',
+ 'cpp',
+ license: 'Apache 2.0',
+ meson_version: '>=1.3.0',
+ default_options: [
+ 'buildtype=release',
+ 'warning_level=2',
+ 'cpp_std=c++17',
+ ]
+)
+
+nanoarrow_dep = dependency('nanoarrow')
+example_exec = executable('example_meson_minimal_app',
+ 'src/app.cc',
+ dependencies: [nanoarrow_dep])
diff --git a/examples/meson-minimal/src/app.cc
b/examples/meson-minimal/src/app.cc
new file mode 100644
index 00000000..39273b64
--- /dev/null
+++ b/examples/meson-minimal/src/app.cc
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "nanoarrow/nanoarrow.h"
+#include "nanoarrow/nanoarrow.hpp"
+
+int main(void) {
+ nanoarrow::UniqueSchema schema;
+ NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema.get(),
NANOARROW_TYPE_INT32));
+ printf("Schema format for int32 is '%s'\n", schema->format);
+ return EXIT_SUCCESS;
+}
diff --git a/.gitignore b/examples/meson-minimal/subprojects/nanoarrow.wrap
similarity index 78%
copy from .gitignore
copy to examples/meson-minimal/subprojects/nanoarrow.wrap
index 12399570..59eae53a 100644
--- a/.gitignore
+++ b/examples/meson-minimal/subprojects/nanoarrow.wrap
@@ -6,7 +6,7 @@
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
@@ -15,15 +15,10 @@
# specific language governing permissions and limitations
# under the License.
-_coverage/
-build/
-scratch/
-out/
-arrow-hpp
-.DS_Store
-CMakeUserPresets.json
-.vscode
-.Rproj.user
-.cache
-*.swp
-__pycache__
+[wrap-git]
+# url should point to the project root with the top-level meson.build file
+url = ../../..
+revision = head
+
+[provide]
+nanoarrow = nanoarrow_dep
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..b0f10064
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+project(
+ 'nanoarrow',
+ 'c', 'cpp',
+ version: '0.5.0-SNAPSHOT',
+ license: 'Apache 2.0',
+ meson_version: '>=1.3.0',
+ default_options: [
+ 'buildtype=release',
+ 'c_std=c99',
+ 'warning_level=2',
+ 'cpp_std=c++17',
+ ]
+)
+
+if get_option('NANOARROW_CODE_COVERAGE')
+ error(
+ '''For meson builds, please use '-Db_coverage=true' flag
+ instead of -DNANOARROW_CODE_COVERAGE=true''')
+endif
+
+if get_option('NANOARROW_BUNDLE')
+ error('NANOARROW_BUNDLE not implemented in meson configuration - try CMake
instead')
+endif
+
+if get_option('NANOARROW_BUNDLE_AS_CPP')
+ error('NANOARROW_BUNDLE_AS_CPP not implemented in meson configuration - try
CMake instead')
+endif
+
+subdir('src/nanoarrow')
+
+if get_option('NANOARROW_BUILD_BENCHMARKS')
+ subdir('dev/benchmarks')
+endif
diff --git a/meson.options b/meson.options
new file mode 100644
index 00000000..fe8d5ce8
--- /dev/null
+++ b/meson.options
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+option('NANOARROW_BUILD_TESTS', type: 'boolean', description: 'Build tests',
value: false)
+option('NANOARROW_BUILD_BENCHMARKS', type: 'boolean', description: 'Build
benchmarks', value: false)
+option('NANOARROW_BUILD_INTEGRATION_TESTS', type: 'boolean',
+ description: 'Build cross-implementation Arrow integration tests',
+ value: false)
+option('NANOARROW_BUNDLE', type: 'boolean',
+ description: 'Create bundled nanoarrow.h and nanoarrow.c',
+ value: false)
+option('NANOARROW_BUNDLE_AS_CPP', type: 'boolean',
+ description: 'Create bundled nanoarrow.h and nanoarrow.cc',
+ value: false)
+option('NANOARROW_NAMESPACE', type: 'string',
+ description: 'A prefix for exported symbols')
+option('NANOARROW_CODE_COVERAGE', type: 'boolean',
+ description: 'Enable coverage reporting',
+ value: false)
diff --git a/src/nanoarrow/meson.build b/src/nanoarrow/meson.build
new file mode 100644
index 00000000..c8bcdef7
--- /dev/null
+++ b/src/nanoarrow/meson.build
@@ -0,0 +1,128 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+conf_data = configuration_data()
+
+ns = get_option('NANOARROW_NAMESPACE')
+conf_data.set('NANOARROW_NAMESPACE_DEFINE', '#define NANOARROW_NAMESPACE ' +
ns)
+
+version = meson.project_version()
+# Remove any pre-release / build identifiers
+version_no_pre_release = version.split('-')[0]
+version_no_build = version_no_pre_release.split('+')[0]
+components = version_no_build.split('.')
+assert(components.length() >= 3,
+ 'The version does not contain major, minor and patch')
+ver_major = components[0]
+ver_minor = components[1]
+ver_patch = components[2]
+conf_data.set('NANOARROW_VERSION', version)
+conf_data.set('NANOARROW_VERSION_MAJOR', ver_major)
+conf_data.set('NANOARROW_VERSION_MINOR', ver_minor)
+conf_data.set('NANOARROW_VERSION_PATCH', ver_patch)
+
+configure_file(input: 'nanoarrow_config.h.in',
+ output: 'nanoarrow_config.h',
+ configuration: conf_data)
+
+nanoarrow_lib = library(
+ 'nanoarrow',
+ 'array.c',
+ 'schema.c',
+ 'array_stream.c',
+ 'utils.c',
+ install: true)
+
+curdir = include_directories('.') # only needed when used as subproject?
+incdir = include_directories('..')
+
+nanoarrow_dep = declare_dependency(include_directories: [curdir, incdir],
+ link_with: nanoarrow_lib)
+
+if get_option('NANOARROW_BUILD_TESTS') or
get_option('NANOARROW_BUILD_INTEGRATION_TESTS')
+ nlohmann_json_dep = dependency('nlohmann_json')
+
+ c_data_integration_lib = library('nanoarrow_c_data_integration',
+ 'integration/c_data_integration.cc',
+ link_with: nanoarrow_lib,
+ dependencies: [nlohmann_json_dep],
+ include_directories: incdir)
+
+endif
+
+if get_option('NANOARROW_BUILD_TESTS')
+ # CMake configuration sets MEMORYCHECK_COMMAND_OPTIONS but with meson you
instead
+ # wrap the tests with valgrind via `meson test --wrap=valgrind`. See
+ # https://mesonbuild.com/Unit-tests.html
+
+ # Similarly code coverage has a built in option users should use instead
+ # https://mesonbuild.com/Unit-tests.html#coverage
+
+ arrow_dep = dependency('arrow')
+ gtest_dep = dependency('gtest', fallback: ['gtest', 'gtest_main_dep'])
+
+ utils_test = executable('utils_test', 'utils_test.cc',
+ link_with: nanoarrow_lib,
+ dependencies: [arrow_dep, gtest_dep],
+ include_directories: incdir)
+ test('utils test', utils_test)
+
+ buffer_test = executable('buffer_test', 'buffer_test.cc',
+ dependencies: [arrow_dep, gtest_dep],
+ link_with: nanoarrow_lib,
+ include_directories: incdir)
+ test('buffer test', buffer_test)
+
+ array_test = executable('array_test', 'array_test.cc',
+ dependencies: [arrow_dep, gtest_dep],
+ link_with: nanoarrow_lib,
+ include_directories: incdir)
+ test('array test', array_test)
+
+ schema_test = executable('schema_test', 'schema_test.cc',
+ dependencies: [arrow_dep, gtest_dep],
+ link_with: nanoarrow_lib,
+ include_directories: incdir)
+ test('schema test', schema_test)
+
+ array_stream_test = executable('array_stream_test', 'array_stream_test.cc',
+ dependencies: [arrow_dep, gtest_dep],
+ link_with: nanoarrow_lib,
+ include_directories: incdir)
+ test('array_stream test', array_stream_test)
+
+ nanoarrow_hpp_test = executable('nanoarrow_hpp_test',
'nanoarrow_hpp_test.cc',
+ dependencies: [arrow_dep, gtest_dep],
+ link_with: nanoarrow_lib,
+ include_directories: incdir)
+ test('nanoarrow_hpp test', nanoarrow_hpp_test)
+
+ nlohmann_json_dep = dependency('nlohmann_json')
+ nanoarrow_testing_test = executable('nanoarrow_testing_test',
'nanoarrow_testing_test.cc',
+ dependencies: [arrow_dep, gtest_dep,
nlohmann_json_dep],
+ link_with: nanoarrow_lib,
+ include_directories: incdir)
+ test('nanoarrow_testing test', nanoarrow_testing_test)
+
+
+ c_data_integration_test = executable('c_data_integration_test',
'integration/c_data_integration_test.cc',
+ link_with: c_data_integration_lib,
+ dependencies: [arrow_dep, gtest_dep],
+ include_directories: incdir)
+ test('c_data_integration test', c_data_integration_test)
+
+endif