Skip to content

Commit 55dd13d

Browse files
committed
feat: Meson build system for nanoarrow-ipc extension
1 parent c413d69 commit 55dd13d

File tree

11 files changed

+195
-5
lines changed

11 files changed

+195
-5
lines changed

dev/release/utils-prepare.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ update_versions() {
4747
git add meson.build
4848
popd
4949

50+
pushd "${NANOARROW_DIR}/extensions/nanoarrow_ipc"
51+
sed -i.bak -E "s/version: '.+'\/version: '${version}')/g" meson.build
52+
rm meson.build.bak
53+
git add meson.build
54+
popd
55+
5056
pushd "${NANOARROW_DIR}/r"
5157
Rscript -e "desc::desc_set(Version = '${r_version}')"
5258
git add DESCRIPTION
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
project(
19+
'nanoarrow_ipc',
20+
'c', 'cpp',
21+
version: '0.5.0-SNAPSHOT',
22+
license: 'Apache 2.0',
23+
meson_version: '>=1.3.0',
24+
default_options: [
25+
'buildtype=release',
26+
'c_std=c11',
27+
'warning_level=2',
28+
'cpp_std=c++17',
29+
]
30+
)
31+
32+
if get_option('NANOARROW_IPC_CODE_COVERAGE')
33+
error(
34+
'''For meson builds, please use '-Db_coverage=true' flag
35+
instead of -DNANOARROW_IPC_CODE_COVERAGE=true''')
36+
endif
37+
38+
if get_option('NANOARROW_IPC_BUNDLE')
39+
error('NANOARROW_IPC_BUNDLE not implemented in meson configuration - try CMake instead')
40+
endif
41+
42+
subdir('src/nanoarrow')
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
option('NANOARROW_IPC_BUILD_TESTS', type: 'boolean', description: 'Build tests', value: false)
19+
option('NANOARROW_BUILD_APPS', type: 'boolean', description: 'Build utility applications', value: false)
20+
option('NANOARROW_IPC_CODE_COVERAGE', type: 'boolean', description: 'Do not use', value: false)
21+
option('NANOARROW_IPC_BUNDLE', type: 'boolean',
22+
description: 'Create bundled nanoarrow_ipc.h and nanoarrow_ipc.c',
23+
value: false)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
cmake = import('cmake')
2+
cmake_opts = cmake.subproject_options()
3+
cmake_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': true})
4+
flatcc_subproj = cmake.subproject('flatcc', options: cmake_opts)
5+
flatcc_dep = flatcc_subproj.dependency('flatccrt')
6+
7+
nanoarrow_dep = dependency('nanoarrow')
8+
9+
nanoarrow_ipc_lib = library(
10+
'nanoarrow_ipc',
11+
'nanoarrow_ipc_decoder.c',
12+
'nanoarrow_ipc_reader.c',
13+
dependencies: [flatcc_dep, nanoarrow_dep],
14+
install: true
15+
)
16+
17+
18+
if get_option('NANOARROW_IPC_BUILD_TESTS')
19+
arrow_dep = dependency('arrow')
20+
gtest_dep = dependency('gtest', fallback: ['gtest', 'gtest_main_dep'])
21+
nlohmann_json_dep = dependency('nlohmann_json')
22+
zlib_dep = dependency('zlib')
23+
24+
ipc_decoder_test = executable('nanoarrow_ipc_decoder_test',
25+
'nanoarrow_ipc_decoder_test.cc',
26+
link_with: nanoarrow_ipc_lib,
27+
dependencies: [
28+
flatcc_dep,
29+
nanoarrow_dep,
30+
arrow_dep,
31+
gtest_dep,
32+
])
33+
test('nanoarrow_ipc_decoder_test', ipc_decoder_test)
34+
35+
ipc_reader_test = executable('nanoarrow_ipc_reader_test',
36+
'nanoarrow_ipc_reader_test.cc',
37+
link_with: nanoarrow_ipc_lib,
38+
dependencies: [
39+
flatcc_dep,
40+
nanoarrow_dep,
41+
arrow_dep,
42+
gtest_dep,
43+
])
44+
test('nanoarrow_ipc_reader_test', ipc_reader_test)
45+
46+
ipc_files_test = executable('nanoarrow_ipc_files_test',
47+
'nanoarrow_ipc_files_test.cc',
48+
link_with: nanoarrow_ipc_lib,
49+
dependencies: [
50+
flatcc_dep,
51+
nanoarrow_dep,
52+
arrow_dep,
53+
gtest_dep,
54+
nlohmann_json_dep,
55+
zlib_dep,
56+
])
57+
test('nanoarrow_ipc_files_test', ipc_files_test)
58+
59+
ipc_hpp_test = executable('nanoarrow_ipc_hpp_test',
60+
'nanoarrow_ipc_hpp_test.cc',
61+
link_with: nanoarrow_ipc_lib,
62+
dependencies: [
63+
flatcc_dep,
64+
nanoarrow_dep,
65+
arrow_dep,
66+
gtest_dep,
67+
])
68+
test('nanoarrow_ipc_hpp_test', ipc_hpp_test)
69+
endif

extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc_decoder_test.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ struct ArrowIpcDecoderPrivate {
5454
static enum ArrowIpcEndianness ArrowIpcSystemEndianness(void) {
5555
uint32_t check = 1;
5656
char first_byte;
57-
enum ArrowIpcEndianness system_endianness;
5857
memcpy(&first_byte, &check, sizeof(char));
5958
if (first_byte) {
6059
return NANOARROW_IPC_ENDIANNESS_LITTLE;
@@ -501,8 +500,6 @@ TEST(NanoarrowIpcTest, NanoarrowIpcDecodeSimpleRecordBatchFromShared) {
501500
data.size_bytes = sizeof(kSimpleRecordBatch);
502501

503502
ArrowIpcDecoderInit(&decoder);
504-
auto decoder_private =
505-
reinterpret_cast<struct ArrowIpcDecoderPrivate*>(decoder.private_data);
506503

507504
ASSERT_EQ(ArrowIpcDecoderSetSchema(&decoder, &schema, nullptr), NANOARROW_OK);
508505
EXPECT_EQ(ArrowIpcDecoderDecodeHeader(&decoder, data, &error), NANOARROW_OK);
@@ -602,6 +599,7 @@ TEST(NanoarrowIpcTest, NanoarrowIpcSharedBufferThreadSafeDecode) {
602599
std::thread threads[10];
603600
for (int i = 0; i < 10; i++) {
604601
threads[i] = std::thread([&arrays, i, &one_two_three_le] {
602+
// TODO: warning: statement has no effect [-Wunused-value]
605603
memcmp(arrays[i].children[0]->buffers[1], one_two_three_le,
606604
sizeof(one_two_three_le));
607605
ArrowArrayRelease(arrays + i);
@@ -791,7 +789,7 @@ TEST_P(ArrowTypeIdParameterizedTestFixture, NanoarrowIpcDecodeSwapEndian) {
791789
// Make a data buffer long enough for 10 Decimal256s with a pattern
792790
// where an endian swap isn't silently the same value (e.g., 0s)
793791
uint8_t data_buffer[32 * 10];
794-
for (int64_t i = 0; i < sizeof(data_buffer); i++) {
792+
for (size_t i = 0; i < sizeof(data_buffer); i++) {
795793
data_buffer[i] = i % 256;
796794
}
797795

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[wrap-git]
2+
method = cmake
3+
url = https://github.com/dvidelabs/flatcc
4+
revision = v0.6.1
5+
depth = 1
6+
clone-recursive = true
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[wrap-file]
2+
directory = googletest-1.14.0
3+
source_url = https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
4+
source_filename = gtest-1.14.0.tar.gz
5+
source_hash = 8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7
6+
patch_filename = gtest_1.14.0-2_patch.zip
7+
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.14.0-2/get_patch
8+
patch_hash = 4ec7f767364386a99f7b2d61678287a73ad6ba0f9998be43b51794c464a63732
9+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.14.0-2/gtest-1.14.0.tar.gz
10+
wrapdb_version = 1.14.0-2
11+
12+
[provide]
13+
gtest = gtest_dep
14+
gtest_main = gtest_main_dep
15+
gmock = gmock_dep
16+
gmock_main = gmock_main_dep
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[wrap-git]
2+
url = ../../..
3+
revision = head
4+
depth = 1
5+
6+
[provide]
7+
nanoarrow = nanoarrow_dep
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[wrap-file]
2+
directory = nlohmann_json-3.11.2
3+
lead_directory_missing = true
4+
source_url = https://github.com/nlohmann/json/releases/download/v3.11.2/include.zip
5+
source_filename = nlohmann_json-3.11.2.zip
6+
source_hash = e5c7a9f49a16814be27e4ed0ee900ecd0092bfb7dbfca65b5a421b774dccaaed
7+
wrapdb_version = 3.11.2-1
8+
9+
[provide]
10+
nlohmann_json = nlohmann_json_dep
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[wrap-file]
2+
directory = zlib-1.3.1
3+
source_url = http://zlib.net/fossils/zlib-1.3.1.tar.gz
4+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.1-1/zlib-1.3.1.tar.gz
5+
source_filename = zlib-1.3.1.tar.gz
6+
source_hash = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
7+
patch_filename = zlib_1.3.1-1_patch.zip
8+
patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.1-1/get_patch
9+
patch_hash = e79b98eb24a75392009cec6f99ca5cdca9881ff20bfa174e8b8926d5c7a47095
10+
wrapdb_version = 1.3.1-1
11+
12+
[provide]
13+
zlib = zlib_dep

0 commit comments

Comments
 (0)