From 965e3933c81c112dac831644435911fa18c3e9b4 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Fri, 11 Apr 2025 10:27:45 -0400 Subject: [PATCH] GH-46116: [C++] Implement IPC directory in Meson --- ci/scripts/cpp_build.sh | 4 ++ cpp/meson.build | 20 +++++- cpp/meson.options | 18 ++++- cpp/src/arrow/ipc/meson.build | 120 ++++++++++++++++++++++++++++++++++ cpp/src/arrow/meson.build | 4 ++ 5 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 cpp/src/arrow/ipc/meson.build diff --git a/ci/scripts/cpp_build.sh b/ci/scripts/cpp_build.sh index d692379d1e803..e80a12db6702c 100755 --- a/ci/scripts/cpp_build.sh +++ b/ci/scripts/cpp_build.sh @@ -143,8 +143,12 @@ if [ "${ARROW_USE_MESON:-OFF}" = "ON" ]; then --prefix=${MESON_PREFIX:-${ARROW_HOME}} \ --buildtype=${ARROW_BUILD_TYPE:-debug} \ -Dauto_features=enabled \ + -Dbrotli=disabled \ + -Dfuzzing=disabled \ -Dgcs=disabled \ + -Dlz4=disabled \ -Ds3=disabled \ + -Dzstd=disabled \ . \ ${source_dir} diff --git a/cpp/meson.build b/cpp/meson.build index 0362f2afd0c35..9d41c14291605 100644 --- a/cpp/meson.build +++ b/cpp/meson.build @@ -68,7 +68,25 @@ needs_integration = get_option('integration').enabled() needs_tests = get_option('tests').enabled() needs_acero = get_option('acero').enabled() needs_ipc = get_option('ipc').enabled() or needs_tests or needs_acero or needs_benchmarks -needs_testing = get_option('testing').enabled() or needs_tests or needs_benchmarks or needs_integration +needs_fuzzing = get_option('fuzzing').enabled() +needs_testing = (get_option('testing').enabled() +or needs_tests +or needs_benchmarks +or needs_fuzzing +or needs_integration +) needs_json = get_option('json').enabled() or needs_testing +needs_brotli = get_option('brotli').enabled() or needs_fuzzing +needs_lz4 = get_option('lz4').enabled() +needs_zstd = get_option('zstd').enabled() +needs_utilities = get_option('utilities').enabled() + +if (get_option('brotli').enabled() or get_option('lz4').enabled() or get_option( + 'zstd', +).enabled() +) + # See GH issue 46115 + error('Compression options (brotli, lz4, zstd) are not implemented in Meson') +endif subdir('src/arrow') diff --git a/cpp/meson.options b/cpp/meson.options index 7b7008bd3572a..a9ecfc8890e71 100644 --- a/cpp/meson.options +++ b/cpp/meson.options @@ -23,9 +23,11 @@ option( ) option('benchmarks', type: 'feature', description: 'Build the Arrow micro benchmarks') +option('brotli', type: 'feature', description: 'Build with Brotli compression') option('compute', type: 'feature', description: 'Build all Arrow Compute kernels') option('csv', type: 'feature', description: 'Build the Arrow CSV Parser Module') option('filesystem', type: 'feature', description: 'Build the Arrow Filesystem Layer') +option('fuzzing', type: 'feature', description: 'Build Arrow Fuzzing executables') option( 'gcs', @@ -34,7 +36,12 @@ option( ) option('hdfs', type: 'feature', description: 'Build the Arrow HDFS bridge') -option('integration', type: 'feature', description: 'Build the Arrow integration test executables') + +option( + 'integration', + type: 'feature', + description: 'Build the Arrow integration test executables', +) option( 'ipc', @@ -47,6 +54,12 @@ option('json', type: 'feature', description: 'Build Arrow with JSON support') option('git_id', type: 'string') option('git_description', type: 'string') +option( + 'lz4', + type: 'feature', + description: 'Build with lz4 compression', +) + option( 'package_kind', type: 'string', @@ -60,3 +73,6 @@ option( ) option('testing', type: 'feature', description: 'Build the Arrow testing libraries') option('tests', type: 'feature', description: 'Build the Arrow googletest unit tests') + +option('utilities', type: 'feature', description: 'Build Arrow commandline utilities') +option('zstd', type: 'feature', description: 'Build with zstd compression') diff --git a/cpp/src/arrow/ipc/meson.build b/cpp/src/arrow/ipc/meson.build new file mode 100644 index 0000000000000..125cb316a09ee --- /dev/null +++ b/cpp/src/arrow/ipc/meson.build @@ -0,0 +1,120 @@ +# 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. + +exc = executable( + 'arrow-feather-test', + sources: ['feather_test.cc'], + dependencies: [arrow_ipc_deps, arrow_test_dep], +) +test('arrow-feather-test', exc) + +ipc_tests = [ + 'json_simple_test', + 'message_internal_test', + 'read_write_test', + 'tensor_test', +] + +foreach ipc_test : ipc_tests + test_name = 'arrow-ipc-@0@'.format(ipc_test.replace('_', '-')) + exc = executable( + test_name, + sources: ['@0@.cc'.format(ipc_test)], + dependencies: [arrow_ipc_deps, arrow_test_dep], + ) + test(test_name, exc) +endforeach + +install_headers( + [ + 'api.h', + 'dictionary.h', + 'feather.h', + 'json_simple.h', + 'message.h', + 'options.h', + 'reader.h', + 'test_common.h', + 'type_fwd.h', + 'util.h', + 'writer.h', + ], + subdir: 'arrow/ipc', +) + +if needs_utilities or needs_integration + file_to_stream_exc = executable( + 'arrow-file-to-stream', + sources: ['file_to_stream.cc'], + dependencies: [arrow_dep], + install: needs_utilities, + ) + + stream_to_file_exc = executable( + 'arrow-stream-to-file', + sources: ['stream_to_file.cc'], + dependencies: [arrow_dep], + install: needs_utilities, + ) +endif + +exc = executable( + 'arrow-ipc-read-write-benchmark', + sources: ['read_write_benchmark.cc'], + dependencies: [arrow_benchmark_dep], +) +benchmark('arrow-ipc-read-write-benchmark', exc) + +if needs_fuzzing or (needs_utilities +and needs_testing +and needs_lz4 +and needs_zstd +) + fuzz_corpus_exc = executable( + 'arrow-ipc-generate-fuzz-corpus', + sources: ['generate_fuzz_corpus.cc'], + dependencies: [arrow_test_dep], + ) + + tensor_fuzz_corpus_exc = executable( + 'arrow-ipc-generate-tensor-fuzz-corpus', + sources: ['generate_tensor_fuzz_corpus.cc'], + dependencies: [arrow_test_dep], + ) +endif + +ipc_fuzz_targets = ['file_fuzz', 'stream_fuzz', 'tensor_stream_fuzz'] + +if needs_fuzzing + if meson.version() < '1.8.0' + error( + ' Meson >= 1.8.0 is required for fuzzing support, found @0@'.format( + meson.version(), + ), + ) + endif + + foreach ipc_fuzz_target : ipc_fuzz_targets + target_name = 'arrow-ipc-@0@'.format(ipc_fuzz_target.replace('_', '-')) + executable( + target_name, + sources: ['@0@.cc'.format(ipc_fuzz_target)], + dependencies: [arrow_dep], + override_options: ['-Db_sanitize=fuzzer'], + ) + endforeach +endif diff --git a/cpp/src/arrow/meson.build b/cpp/src/arrow/meson.build index 5f5052162d0a5..7f0557d331274 100644 --- a/cpp/src/arrow/meson.build +++ b/cpp/src/arrow/meson.build @@ -685,3 +685,7 @@ endif if needs_json subdir('json') endif + +if needs_ipc + subdir('ipc') +endif