Skip to content

Commit

Permalink
GH-41816: [C++] Meson Build System Support
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd committed Feb 6, 2025
1 parent 1567be0 commit 2f7048f
Show file tree
Hide file tree
Showing 17 changed files with 1,226 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,8 @@ repos:
?^c_glib/test/run-test\.sh$|
?^dev/release/utils-generate-checksum\.sh$|
)
- repo: https://github.com/trim21/pre-commit-mirror-meson
rev: v1.6.1
hooks:
- id: meson-fmt
args: ['--inplace']
55 changes: 55 additions & 0 deletions cpp/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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(
'arrow',
'cpp',
'c',
version: '19.0.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',
],
)

project_args = [
'-Wno-unused-parameter',
'-Wno-array-bounds',
'-Wno-stringop-overflow',
'-Wno-aggressive-loop-optimizations',
'-Wno-nonnull',
]

c_compiler = meson.get_compiler('c')
c_args = c_compiler.get_supported_arguments(project_args)
add_project_arguments(c_args, language: 'c')

cpp_compiler = meson.get_compiler('cpp')
cpp_args = cpp_compiler.get_supported_arguments(project_args)
add_project_arguments(cpp_args, language: 'cpp')

needs_tests = get_option('tests')
needs_ipc = needs_tests or get_option('ipc')
needs_testing = needs_tests or get_option('testing')
needs_json = needs_testing or get_option('json')
needs_compute = get_option('compute')

subdir('src/arrow')
32 changes: 32 additions & 0 deletions cpp/meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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('compute', type: 'boolean', description: 'Build compute', value: false)
option('ipc', type: 'boolean', description: 'Build IPC', value: false)
option(
'json',
type: 'boolean',
description: 'Build Arrow with JSON support (requires RapidJSON)',
value: false,
)
option(
'testing',
type: 'boolean',
description: 'Build the Arrow testing libraries',
value: false,
)
option('tests', type: 'boolean', description: 'Build tests', value: false)
32 changes: 32 additions & 0 deletions cpp/src/arrow/array/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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.

tests = {
'arrow-concatenate-test': {'sources': ['concatenate_test.cc']},
'arrow-diff-test': {'sources': ['diff_test.cc']},
}

foreach key, val : tests
exc = executable(
key,
sources: val['sources'],
dependencies: [arrow_test_dep],
)
test(key, exc)
endforeach

# TODO: arrow_install_all_headers
33 changes: 33 additions & 0 deletions cpp/src/arrow/c/meson.build
Original file line number Diff line number Diff line change
@@ -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.

tests = {
'arrow-c-bridge-test': {'sources': ['bridge_test.cc']},
'arrow-dlpack-test': {'sources': ['dlpack_test.cc']},
}

foreach key, val : tests
exc = executable(
key,
sources: val['sources'],
dependencies: [arrow_test_dep],
)
test(key, exc)
endforeach

# add_arrow_benchmark(bridge_benchmark)
# TODO: arrow_install_all_headers
94 changes: 94 additions & 0 deletions cpp/src/arrow/compute/kernels/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# 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.

# TODO: arrow_install_all_headers
# TODO: add_pkg_config

compute_kernels_test_util_srcs = [
'../test_util_internal.cc',
'test_util_internal.cc',
]

tests = {'scalar-cast-test': {'sources': ['scalar_cast_test.cc']}}

if needs_compute
tests += {
'arrow-compute-scalar-type-test': {
'sources': [
'scalar_boolean_test.cc',
'scalar_nested_test.cc',
'scalar_string_test.cc',
],
},
'arrow-compute-scalar-if-else-test': {
'sources': ['scalar_if_else_test.cc'],
},
'arrow-compute-scalar-temporal-test': {
'sources': ['scalar_temporal_test.cc'],
},
'arrow-compute-scalar-match-test': {
'sources': [
'scalar_arithmetic_test.cc',
'scalar_compare_test.cc',
'scalar_round_arithmetic_test.cc',
],
},
'arrow-compute-scalar-utility-test': {
'sources': [
'scalar_random_test.cc',
'scalar_set_lookup_test.cc',
'scalar_validity_test.cc',
],
},
# Vector tests
'arrow-compute-vector-test': {
'sources': [
'vector_cumulative_ops_test.cc',
'vector_pairwise_test.cc',
'vector_hash_test.cc',
'vector_nested_test.cc',
'vector_replace_test.cc',
'vector_run_end_encode_test.cc',
'select_k_test.cc',
],
},
'arrow-compute-vector-sort-test': {'sources': ['vector_sort_test.cc']},
'arrow-compute-vector-selection-test': {
'sources': ['vector_selection_test.cc'],
},
'arrow-compute-vector-swizzle-test': {
'sources': ['vector_swizzle_test.cc'],
},
# Aggregates
'arrow-compute-aggregate-test': {'sources': ['aggregate_test.cc']},
# Utilities
'arrow-compute-kernel-utility-test': {
'sources': ['codegen_internal_test.cc'],
},
}
endif

foreach key, val : tests
exc = executable(
key,
sources: compute_kernels_test_util_srcs + val['sources'],
dependencies: [arrow_test_dep],
)
test(key, exc)
endforeach

# TODO: benchmarks
83 changes: 83 additions & 0 deletions cpp/src/arrow/compute/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 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.

# TODO: arrow_install_all_headers
# TODO: add_pkg_config

arrow_compute_objlibs = []

# TODO: the CMake configuration builds test_util_internal.cc
# as an object library, but it still requires the gtest dependency
# In Meson, the gtest dependency being declared here then transists
# down to libraries that try to use this, causing all of the symbols
# to be duplicated. For now, we are just adding test_util_internal.cc
# to the appropriate sources as a workaround
'''
if needs_testing
arrow_compute_testing_lib = static_library(
'arrow_compute_testing',
sources: ['test_util_internal.cc'],
include_directories: [include_dir],
build_by_default: false,
)
arrow_compute_objlibs += arrow_compute_testing_lib.extract_all_objects(recursive: true)
endif
'''
compute_test_util_srcs = ['test_util_internal.cc']

tests = {
'arrow-internals-test': {
'sources': [
'function_test.cc',
'exec_test.cc',
'kernel_test.cc',
'registry_test.cc',
],
},
}

if needs_compute
tests += {
'arrow-compute-expression-test': {'sources': ['expression_test.cc']},
'arrow-compute-row-test': {
'sources': compute_test_util_srcs + [
'key_hash_test.cc',
'light_array_test.cc',
'row/compare_test.cc',
'row/grouper_test.cc',
'row/row_encoder_internal_test.cc',
'row/row_test.cc',
'util_internal_test.cc',
],
},
}
endif

foreach key, val : tests
exc = executable(
key,
sources: val['sources'],
dependencies: [arrow_test_dep],
)
test(key, exc)
endforeach

# add_arrow_benchmark(function_benchmark)

subdir('kernels')
subdir('row')

20 changes: 20 additions & 0 deletions cpp/src/arrow/compute/row/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.

# TODO: arrow_install_all_headers

# TODO: add_arrow_benchmark(grouper_benchmark)
31 changes: 31 additions & 0 deletions cpp/src/arrow/extension/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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.

extension_test_srcs = ['bool8_test.cc', 'json_test.cc', 'uuid_test.cc']

if needs_json
extension_test_srcs += ['fixed_shape_tensor_test.cc', 'opaque_test.cc']
endif

extension_exc = executable(
key,
sources: extension_test_srcs,
dependencies: [arrow_test_dep],
)
test('arrow-canonical-extensions', extension_exc)

# TODO: arrow_install_all_headers
Loading

0 comments on commit 2f7048f

Please sign in to comment.