From 54987a42678e44112f3f9fc27c24b0a966831dac Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 14 Apr 2025 23:34:22 -0400 Subject: [PATCH] GH-46141: Add flight directory to Meson configuration --- cpp/meson.build | 5 +- cpp/meson.options | 7 ++ cpp/src/arrow/flight/meson.build | 205 +++++++++++++++++++++++++++++++ cpp/src/arrow/meson.build | 4 + cpp/subprojects/abseil-cpp.wrap | 125 +++++++++++++++++++ cpp/subprojects/c-ares.wrap | 30 +++++ cpp/subprojects/grpc.wrap | 34 +++++ cpp/subprojects/protobuf.wrap | 33 +++++ 8 files changed, 441 insertions(+), 2 deletions(-) create mode 100644 cpp/src/arrow/flight/meson.build create mode 100644 cpp/subprojects/abseil-cpp.wrap create mode 100644 cpp/subprojects/c-ares.wrap create mode 100644 cpp/subprojects/grpc.wrap create mode 100644 cpp/subprojects/protobuf.wrap diff --git a/cpp/meson.build b/cpp/meson.build index f4d006d31f4..247f3154b96 100644 --- a/cpp/meson.build +++ b/cpp/meson.build @@ -24,7 +24,7 @@ project( meson_version: '>=1.3.0', default_options: [ 'buildtype=release', - 'c_std=c99', + 'c_std=gnu11,c11', 'warning_level=2', 'cpp_std=c++17', ], @@ -67,7 +67,8 @@ needs_filesystem = get_option('filesystem').enabled() or needs_azure or needs_gc 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_flight = get_option('flight').enabled() +needs_ipc = get_option('ipc').enabled() or needs_tests or needs_acero or needs_benchmarks or needs_flight needs_fuzzing = get_option('fuzzing').enabled() needs_testing = (get_option('testing').enabled() or needs_tests diff --git a/cpp/meson.options b/cpp/meson.options index b51d20c8d5b..fed38a29700 100644 --- a/cpp/meson.options +++ b/cpp/meson.options @@ -52,6 +52,13 @@ option( ) option('json', type: 'feature', description: 'Build Arrow with JSON support') + +option( + 'flight', + type: 'feature', + description: 'Build the Arrow Flight RPC System (requires GRPC, Protocol Buffers)', +) + option('git_id', type: 'string') option('git_description', type: 'string') diff --git a/cpp/src/arrow/flight/meson.build b/cpp/src/arrow/flight/meson.build new file mode 100644 index 00000000000..85df8e61cb6 --- /dev/null +++ b/cpp/src/arrow/flight/meson.build @@ -0,0 +1,205 @@ +# 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. + +install_headers( + [ + 'api.h', + 'client_auth.h', + 'client_cookie_middleware.h', + 'client.h', + 'client_middleware.h', + 'client_tracing_middleware.h', + 'middleware.h', + 'otel_logging.h', + 'platform.h', + 'server_auth.h', + 'server.h', + 'server_middleware.h', + 'server_tracing_middleware.h', + 'test_auth_handlers.h', + 'test_definitions.h', + 'test_flight_server.h', + 'test_util.h', + 'transport.h', + 'transport_server.h', + 'type_fwd.h', + 'types_async.h', + 'types.h', + 'visibility.h', + ], + subdir: 'arrow/flight', +) + +grpc_dep = dependency('grpc++') +protobuf_dep = dependency('protobuf') +abseil_sync_dep = dependency('absl_synchronization') + +fs = import('fs') +protoc = find_program('protoc') + +flight_proto_path = fs.parent(meson.project_source_root()) / 'format' +flight_proto_files = custom_target( + 'arrow-flight-proto-files', + input: [flight_proto_path / 'Flight.proto'], + output: ['Flight.pb.cc', 'Flight.pb.h'], + command: [ + protoc, + '--proto_path=' + flight_proto_path, + '--cpp_out=' + meson.current_build_dir(), + '@INPUT@', + ], +) + +grpc_cpp_plugin = find_program('grpc_cpp_plugin') +flight_proto_grpc_files = custom_target( + 'arrow-flight-proto-grpc-files', + input: [flight_proto_path / 'Flight.proto'], + output: ['Flight.grpc.pb.cc', 'Flight.grpc.pb.h'], + command: [ + protoc, + '--proto_path=' + flight_proto_path, + '--grpc_out=' + meson.current_build_dir(), + '--plugin=protoc-gen-grpc=' + grpc_cpp_plugin.full_path(), + '@INPUT@', + ], +) + +arrow_flight_srcs = [ + 'client.cc', + 'client_cookie_middleware.cc', + 'client_tracing_middleware.cc', + 'cookie_internal.cc', + 'middleware.cc', + 'serialization_internal.cc', + 'server.cc', + 'server_auth.cc', + 'server_tracing_middleware.cc', + 'transport.cc', + 'transport_server.cc', + 'transport/grpc/grpc_client.cc', + 'transport/grpc/grpc_server.cc', + 'transport/grpc/serialization_internal.cc', + 'transport/grpc/protocol_grpc_internal.cc', + 'transport/grpc/util_internal.cc', + 'types.cc', +] + +thread_dep = dependency('threads') + +arrow_flight = library( + 'arrow-flight', + # We intentionally index flight_proto_grpc_files[1] so as to avoid + # adding 'Flight.grpc.pb.cc' to the sources. This is required + # because protocol_grpc_internal.cc includes the source file + # directly; using as a source here will cause a ODR violation + sources: arrow_flight_srcs + [ + flight_proto_files, + flight_proto_grpc_files[1], + ], + dependencies: [ + arrow_dep, + grpc_dep, + protobuf_dep, + abseil_sync_dep, + thread_dep, + ], + cpp_args: '-DARROW_FLIGHT_EXPORTING', +) + +arrow_flight_dep = declare_dependency( + link_with: arrow_flight, + dependencies: [grpc_dep, protobuf_dep, abseil_sync_dep], +) + +if needs_testing + arrow_flight_testing_lib = library( + 'arrow-flight-testing', + sources: [ + 'test_auth_handlers.cc', + 'test_definitions.cc', + 'test_flight_server.cc', + 'test_util.cc', + ], + dependencies: [arrow_test_dep, arrow_flight_dep, thread_dep], + ) + + arrow_flight_test_dep = declare_dependency( + link_with: arrow_flight_testing_lib, + dependencies: [arrow_flight_dep], + ) +else + arrow_flight_test_dep = disabler() +endif + +flight_tests = ['flight_internals_test', 'flight_test'] +foreach flight_test : flight_tests + test_name = '@0@'.format(flight_test.replace('_', '-')) + exc = executable( + test_name, + sources: [ + '@0@.cc'.format(flight_test), + # flight_internals_test.cc transitively includes Flight.grpc.pb.h + # so we must declare that here to avoid a race condition + flight_proto_grpc_files[1], + ], + dependencies: [arrow_test_dep, arrow_flight_test_dep], + ) + test(test_name, exc) +endforeach + +flight_test_dep_no_main = [ + arrow_dep, + arrow_flight_test_dep, + gtest_dep, + gmock_dep, + gflags_dep, +] + +if needs_tests or needs_benchmarks + executable( + 'flight-test-server', + sources: ['test_server.cc'], + dependencies: flight_test_dep_no_main, + ) +endif + +if needs_benchmarks + server_proto_path = meson.project_source_root() / 'src' / 'arrow' / 'flight' + flight_proto_files = custom_target( + 'arrow-flight-benchmark-perf-proto-files', + input: [server_proto_path / 'perf.proto'], + output: ['perf.pb.cc', 'perf.pb.h'], + command: [ + protoc, + '--proto_path=' + meson.current_source_dir(), + '--cpp_out=' + meson.current_build_dir(), + '@INPUT@', + ], + ) + + executable( + 'arrow-flight-perf-server', + sources: ['perf_server.cc'] + flight_proto_files, + dependencies: flight_test_dep_no_main, + ) + + executable( + 'arrow-flight-benchmark', + sources: ['flight_benchmark.cc'] + flight_proto_files, + dependencies: flight_test_dep_no_main, + ) +endif diff --git a/cpp/src/arrow/meson.build b/cpp/src/arrow/meson.build index 018cb2dac54..cad76c39db8 100644 --- a/cpp/src/arrow/meson.build +++ b/cpp/src/arrow/meson.build @@ -720,6 +720,10 @@ if needs_filesystem subdir('filesystem') endif +if needs_flight + subdir('flight') +endif + if needs_json subdir('json') endif diff --git a/cpp/subprojects/abseil-cpp.wrap b/cpp/subprojects/abseil-cpp.wrap new file mode 100644 index 00000000000..54fc2280c7c --- /dev/null +++ b/cpp/subprojects/abseil-cpp.wrap @@ -0,0 +1,125 @@ +# 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. + +[wrap-file] +directory = abseil-cpp-20240722.0 +source_url = https://github.com/abseil/abseil-cpp/releases/download/20240722.0/abseil-cpp-20240722.0.tar.gz +source_filename = abseil-cpp-20240722.0.tar.gz +source_hash = f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3 +patch_filename = abseil-cpp_20240722.0-3_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/abseil-cpp_20240722.0-3/get_patch +patch_hash = 12dd8df1488a314c53e3751abd2750cf233b830651d168b6a9f15e7d0cf71f7b +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/abseil-cpp_20240722.0-3/abseil-cpp-20240722.0.tar.gz +wrapdb_version = 20240722.0-3 + +[provide] +absl_base = absl_base_dep +absl_container = absl_container_dep +absl_debugging = absl_debugging_dep +absl_log = absl_log_dep +absl_flags = absl_flags_dep +absl_hash = absl_hash_dep +absl_crc = absl_crc_dep +absl_numeric = absl_numeric_dep +absl_profiling = absl_profiling_dep +absl_random = absl_random_dep +absl_status = absl_status_dep +absl_strings = absl_strings_dep +absl_synchronization = absl_synchronization_dep +absl_time = absl_time_dep +absl_types = absl_types_dep +absl_algorithm_container = absl_base_dep +absl_any_invocable = absl_base_dep +absl_bad_any_cast_impl = absl_types_dep +absl_bad_optional_access = absl_types_dep +absl_bad_variant_access = absl_types_dep +absl_bind_front = absl_base_dep +absl_city = absl_hash_dep +absl_civil_time = absl_time_dep +absl_cleanup = absl_base_dep +absl_cord = absl_strings_dep +absl_cord_internal = absl_strings_dep +absl_cordz_functions = absl_strings_dep +absl_cordz_handle = absl_strings_dep +absl_cordz_info = absl_strings_dep +absl_cordz_sample_token = absl_strings_dep +absl_core_headers = absl_base_dep +absl_crc32c = absl_crc_dep +absl_debugging_internal = absl_debugging_dep +absl_demangle_internal = absl_debugging_dep +absl_die_if_null = absl_log_dep +absl_examine_stack = absl_debugging_dep +absl_exponential_biased = absl_profiling_dep +absl_failure_signal_handler = absl_debugging_dep +absl_flags_commandlineflag = absl_flags_dep +absl_flags_commandlineflag_internal = absl_flags_dep +absl_flags_config = absl_flags_dep +absl_flags_internal = absl_flags_dep +absl_flags_marshalling = absl_flags_dep +absl_flags_parse = absl_flags_dep +absl_flags_private_handle_accessor = absl_flags_dep +absl_flags_program_name = absl_flags_dep +absl_flags_reflection = absl_flags_dep +absl_flags_usage = absl_flags_dep +absl_flags_usage_internal = absl_flags_dep +absl_flat_hash_map = absl_container_dep +absl_flat_hash_set = absl_container_dep +absl_function_ref = absl_base_dep +absl_graphcycles_internal = absl_synchronization_dep +absl_hashtablez_sampler = absl_container_dep +absl_inlined_vector = absl_container_dep +absl_int128 = absl_numeric_dep +absl_leak_check = absl_debugging_dep +absl_log_initialize = absl_log_dep +absl_log_internal_check_op = absl_log_dep +absl_log_internal_message = absl_log_dep +absl_log_severity = absl_base_dep +absl_low_level_hash = absl_hash_dep +absl_memory = absl_base_dep +absl_optional = absl_types_dep +absl_periodic_sampler = absl_profiling_dep +absl_random_bit_gen_ref = absl_random_dep +absl_random_distributions = absl_random_dep +absl_random_internal_distribution_test_util = absl_random_dep +absl_random_internal_platform = absl_random_dep +absl_random_internal_pool_urbg = absl_random_dep +absl_random_internal_randen = absl_random_dep +absl_random_internal_randen_hwaes = absl_random_dep +absl_random_internal_randen_hwaes_impl = absl_random_dep +absl_random_internal_randen_slow = absl_random_dep +absl_random_internal_seed_material = absl_random_dep +absl_random_random = absl_random_dep +absl_random_seed_gen_exception = absl_random_dep +absl_random_seed_sequences = absl_random_dep +absl_raw_hash_set = absl_container_dep +absl_raw_logging_internal = absl_base_dep +absl_scoped_set_env = absl_base_dep +absl_span = absl_types_dep +absl_spinlock_wait = absl_base_dep +absl_stacktrace = absl_debugging_dep +absl_statusor = absl_status_dep +absl_str_format = absl_strings_dep +absl_str_format_internal = absl_strings_dep +absl_strerror = absl_base_dep +absl_string_view = absl_strings_dep +absl_strings_internal = absl_strings_dep +absl_symbolize = absl_debugging_dep +absl_throw_delegate = absl_base_dep +absl_time_zone = absl_time_dep +absl_type_traits = absl_base_dep +absl_utility = absl_base_dep +absl_variant = absl_types_dep diff --git a/cpp/subprojects/c-ares.wrap b/cpp/subprojects/c-ares.wrap new file mode 100644 index 00000000000..276abf81ba0 --- /dev/null +++ b/cpp/subprojects/c-ares.wrap @@ -0,0 +1,30 @@ +# 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. + +[wrap-file] +directory = c-ares-1.34.4 +source_url = https://github.com/c-ares/c-ares/releases/download/v1.34.4/c-ares-1.34.4.tar.gz +source_filename = c-ares-1.34.4.tar.gz +source_hash = fa38dbed659ee4cc5a32df5e27deda575fa6852c79a72ba1af85de35a6ae222f +patch_filename = c-ares_1.34.4-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/c-ares_1.34.4-1/get_patch +patch_hash = 0d334f610c714412629dd3e0a0dc2c7ced21744cf952c2d63d1eeb7680e4929d +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/c-ares_1.34.4-1/c-ares-1.34.4.tar.gz +wrapdb_version = 1.34.4-1 + +[provide] +libcares = cares_dep diff --git a/cpp/subprojects/grpc.wrap b/cpp/subprojects/grpc.wrap new file mode 100644 index 00000000000..cc8744a1980 --- /dev/null +++ b/cpp/subprojects/grpc.wrap @@ -0,0 +1,34 @@ +# 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. + +[wrap-file] +directory = grpc-1.59.1 +source_url = https://github.com/grpc/grpc/archive/refs/tags/v1.59.1.tar.gz +source_filename = grpc-1.59.1.tar.gz +source_hash = 916f88a34f06b56432611aaa8c55befee96d0a7b7d7457733b9deeacbc016f99 +patch_filename = grpc_1.59.1-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/grpc_1.59.1-1/get_patch +patch_hash = 61055ee4df79b0d98e0db8cdd9b534eb9d8ac71f7a8d2219b6efb905419fbe2b +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/grpc_1.59.1-1/grpc-1.59.1.tar.gz +wrapdb_version = 1.59.1-1 + +[provide] +grpc = grpc_dep +grpc_unsecure = grpc_unsecure_dep +grpc++ = grpcpp_dep +grpc++_unsecure = grpcpp_unsecure_dep +program_names = grpc_cpp_plugin, grpc_python_plugin, grpc_ruby_plugin, grpc_php_plugin, grpc_node_plugin diff --git a/cpp/subprojects/protobuf.wrap b/cpp/subprojects/protobuf.wrap new file mode 100644 index 00000000000..b579a1b7358 --- /dev/null +++ b/cpp/subprojects/protobuf.wrap @@ -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. + +[wrap-file] +directory = protobuf-25.2 +source_url = https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protobuf-25.2.tar.gz +source_filename = protobuf-25.2.tar.gz +source_hash = 8ff511a64fc46ee792d3fe49a5a1bcad6f7dc50dfbba5a28b0e5b979c17f9871 +patch_filename = protobuf_25.2-2_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/protobuf_25.2-2/get_patch +patch_hash = a2f5968097eb036c228b72258435d09e93dca4093d09acb5078a376d8155df46 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/protobuf_25.2-2/protobuf-25.2.tar.gz +wrapdb_version = 25.2-2 + +[provide] +protobuf = protobuf_dep +protobuf-lite = protobuf_lite_dep +protoc = protoc_dep +program_names = protoc