Skip to content

Commit c7a9100

Browse files
WillAydkou
andauthored
apacheGH-41816: [C++] Add Minimal Meson Build of libarrow (apache#45441)
### Rationale for this change The Meson build system may be more user friendly to some developers, and may make it easier to perform tasks like valgrind, coverage, or ASAN/UBSAN coverage. There is also a prior art for using meson in the nanoarrow and arrow-adbc projects. ### What changes are included in this PR? This PR implements a Meson configuration that can build a minimal libarrow. ### Are these changes tested? A nightly CI job is also added to detect regressions. ### Are there any user-facing changes? No * GitHub Issue: apache#41816 Lead-authored-by: Will Ayd <[email protected]> Co-authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 15f1d94 commit c7a9100

11 files changed

+556
-4
lines changed

Diff for: ci/conda_env_cpp.txt

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ libprotobuf
3737
libutf8proc
3838
lz4-c
3939
make
40+
meson
4041
ninja
4142
nodejs
4243
orc

Diff for: ci/scripts/cpp_build.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ if [ "${ARROW_OFFLINE}" = "ON" ]; then
109109
echo > /etc/resolv.conf
110110
fi
111111

112-
if [ "${ARROW_EMSCRIPTEN:-OFF}" = "ON" ]; then
112+
if [ "${ARROW_USE_MESON:-OFF}" = "ON" ]; then
113+
meson setup \
114+
--prefix=${MESON_PREFIX:-${ARROW_HOME}} \
115+
--buildtype=${ARROW_BUILD_TYPE:-debug} \
116+
. \
117+
${source_dir}
118+
elif [ "${ARROW_EMSCRIPTEN:-OFF}" = "ON" ]; then
113119
if [ "${UBUNTU}" = "20.04" ]; then
114120
echo "arrow emscripten build is not supported on Ubuntu 20.04, run with UBUNTU=22.04"
115121
exit -1
@@ -244,8 +250,12 @@ else
244250
${source_dir}
245251
fi
246252

247-
export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:-$[${n_jobs} + 1]}
248-
time cmake --build . --target install
253+
if [ "${ARROW_USE_MESON:-OFF}" = "ON" ]; then
254+
time meson install
255+
else
256+
export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:-$[${n_jobs} + 1]}
257+
time cmake --build . --target install
258+
fi
249259

250260
# Save disk space by removing large temporary build products
251261
find . -name "*.o" -delete

Diff for: ci/scripts/cpp_test.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,21 @@ pushd ${build_dir}
8989
if [ -z "${PYTHON}" ] && ! which python > /dev/null 2>&1; then
9090
export PYTHON="${PYTHON:-python3}"
9191
fi
92-
ctest \
92+
if [ "${ARROW_USE_MESON:-OFF}" = "ON" ]; then
93+
ARROW_BUILD_EXAMPLES=OFF # TODO: Remove this
94+
meson test \
95+
--print-errorlogs \
96+
"$@"
97+
else
98+
ctest \
9399
--label-regex unittest \
94100
--output-on-failure \
95101
--parallel ${n_jobs} \
96102
--repeat until-pass:3 \
97103
--timeout ${ARROW_CTEST_TIMEOUT:-300} \
98104
"${ctest_options[@]}" \
99105
"$@"
106+
fi
100107

101108
if [ "${ARROW_BUILD_EXAMPLES}" == "ON" ]; then
102109
examples=$(find ${binary_output_dir} -executable -name "*example")

Diff for: cpp/meson.build

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
'arrow',
20+
'cpp',
21+
'c',
22+
version: '20.0.0-SNAPSHOT',
23+
license: 'Apache-2.0',
24+
meson_version: '>=1.3.0',
25+
default_options: [
26+
'buildtype=release',
27+
'c_std=c99',
28+
'warning_level=2',
29+
'cpp_std=c++17',
30+
],
31+
)
32+
33+
project_args = [
34+
'-Wno-unused-parameter',
35+
'-Wno-array-bounds',
36+
'-Wno-stringop-overflow',
37+
'-Wno-aggressive-loop-optimizations',
38+
'-Wno-nonnull',
39+
]
40+
41+
c_compiler = meson.get_compiler('c')
42+
c_args = c_compiler.get_supported_arguments(project_args)
43+
add_project_arguments(c_args, language: 'c')
44+
45+
cpp_compiler = meson.get_compiler('cpp')
46+
cpp_args = cpp_compiler.get_supported_arguments(project_args)
47+
add_project_arguments(cpp_args, language: 'cpp')
48+
49+
git_id = get_option('git_id')
50+
if git_id == ''
51+
git_id = run_command('git', 'log', '-n1', '--format=%H', check: false).stdout().strip()
52+
endif
53+
54+
git_description = get_option('git_description')
55+
if git_description == ''
56+
git_description = run_command('git', 'describe', '--tags', check: false).stdout().strip()
57+
endif
58+
59+
subdir('src/arrow')

Diff for: cpp/meson.options

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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(
19+
'git_id',
20+
type: 'string',
21+
)
22+
23+
option(
24+
'git_description',
25+
type: 'string',
26+
)
27+
28+
option(
29+
'package_kind',
30+
type: 'string',
31+
description: 'Arbitrary string that identifies the kind of package (for informational purposes)',
32+
)

0 commit comments

Comments
 (0)