Skip to content

Commit 6d39114

Browse files
committed
GH-46797: [C++] Support Meson on Windows
1 parent 066b216 commit 6d39114

File tree

20 files changed

+367
-63
lines changed

20 files changed

+367
-63
lines changed

.github/workflows/cpp_extra.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ jobs:
133133
- image: conda-cpp
134134
run-options: >-
135135
-e ARROW_USE_MESON=ON
136+
-e MESON_SETUP_ARGS="-Dauto_features=enabled -Dfuzzing=disabled -Dgcs=disabled -Ds3=disabled"
136137
runs-on: ubuntu-latest
137138
title: AMD64 Ubuntu Meson
138139
# TODO: We should remove this "continue-on-error: true" once GH-47207 is resolved
@@ -278,3 +279,70 @@ jobs:
278279
cmake --build cpp/examples/minimal_build.build
279280
cd cpp/examples/minimal_build
280281
../minimal_build.build/arrow-example
282+
283+
meson-windows:
284+
needs: check-labels
285+
name: ${{ matrix.title }}
286+
runs-on: ${{ matrix.runs-on }}
287+
if: needs.check-labels.outputs.ci-extra == 'true'
288+
timeout-minutes: 75
289+
strategy:
290+
fail-fast: false
291+
matrix:
292+
include:
293+
- runs-on: windows-2022
294+
title: AMD64 Windows Meson
295+
steps:
296+
- name: Checkout Arrow
297+
uses: actions/checkout@v4
298+
with:
299+
fetch-depth: 0
300+
submodules: recursive
301+
- name: Download Timezone Database
302+
shell: bash
303+
run: ci/scripts/download_tz_database.sh
304+
- name: Install ccache
305+
shell: bash
306+
run: |
307+
ci/scripts/install_ccache.sh 4.6.3 /usr
308+
- name: Setup ccache
309+
shell: bash
310+
run: |
311+
ci/scripts/ccache_setup.sh
312+
- name: ccache info
313+
id: ccache-info
314+
shell: bash
315+
run: |
316+
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
317+
- name: Cache ccache
318+
uses: actions/cache@v4
319+
with:
320+
path: ${{ steps.ccache-info.outputs.cache-dir }}
321+
key: cpp-ccache-windows-meson-${{ env.CACHE_VERSION }}-${{ hashFiles('cpp/**') }}
322+
restore-keys: cpp-ccache-windows-meson-${{ env.CACHE_VERSION }}-
323+
env:
324+
# We can invalidate the current cache by updating this.
325+
CACHE_VERSION: "2022-09-13"
326+
- name: Setup Python
327+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
328+
with:
329+
python-version: 3
330+
- name: Install Meson
331+
run: |
332+
python3 -m pip install meson
333+
- name: Build
334+
shell: bash
335+
env:
336+
ARROW_USE_MESON: ON
337+
ARROW_HOME: C:\arrow-dist
338+
MESON_SETUP_ARGS: "--vsenv -Dauto_features=enabled -Dfuzzing=disabled -Dgcs=disabled -Ds3=disabled -Dazure=disabled"
339+
run: |
340+
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
341+
- name: Test
342+
shell: bash
343+
env:
344+
ARROW_USE_MESON: ON
345+
run: |
346+
# For ORC
347+
export TZDIR=/c/msys64/usr/share/zoneinfo
348+
ci/scripts/cpp_test.sh $(pwd) $(pwd)/build

ci/scripts/cpp_build.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,7 @@ if [ "${ARROW_USE_MESON:-OFF}" = "ON" ]; then
142142
meson setup \
143143
--prefix=${MESON_PREFIX:-${ARROW_HOME}} \
144144
--buildtype=${ARROW_BUILD_TYPE:-debug} \
145-
-Dauto_features=enabled \
146-
-Dfuzzing=disabled \
147-
-Dgcs=disabled \
148-
-Ds3=disabled \
145+
${MESON_SETUP_ARGS} \
149146
. \
150147
${source_dir}
151148

ci/scripts/cpp_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ if [ "${ARROW_USE_MESON:-OFF}" = "ON" ]; then
9595
--no-rebuild \
9696
--print-errorlogs \
9797
--suite arrow \
98+
--max-lines=0 \
99+
--timeout-multiplier 10 \
98100
"$@"
99101
else
100102
ctest \

cpp/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ project_args = [
3131
'-Wno-stringop-overflow',
3232
'-Wno-aggressive-loop-optimizations',
3333
'-Wno-nonnull',
34+
'/bigobj',
3435
]
3536

3637
c_compiler = meson.get_compiler('c')

cpp/src/arrow/acero/meson.build

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,19 @@ arrow_acero_lib = library(
8282
sources: arrow_acero_srcs,
8383
dependencies: [arrow_compute_dep, arrow_dep, threads_dep],
8484
gnu_symbol_visibility: 'hidden',
85+
cpp_shared_args: ['-DARROW_ACERO_EXPORTING'],
86+
cpp_static_args: ['-DARROW_ACERO_STATIC'],
8587
)
8688

87-
arrow_acero_dep = declare_dependency(link_with: [arrow_acero_lib])
89+
arrow_acero_compile_args = []
90+
if get_option('default_library') != 'shared'
91+
arrow_acero_compile_args += ['-DARROW_ACERO_STATIC']
92+
endif
93+
94+
arrow_acero_dep = declare_dependency(
95+
link_with: [arrow_acero_lib],
96+
compile_args: arrow_acero_compile_args,
97+
)
8898

8999
arrow_acero_testing_sources = ['test_nodes.cc', 'test_util_internal.cc']
90100

@@ -137,8 +147,7 @@ foreach key, val : arrow_acero_benchmarks
137147
dependencies: [
138148
arrow_acero_dep,
139149
arrow_compute_test_dep,
140-
arrow_benchmark_dep,
141-
gmock_dep,
150+
benchmark_main_dep,
142151
],
143152
)
144153
benchmark(key, exc)

cpp/src/arrow/compute/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ if(ARROW_TESTING AND ARROW_COMPUTE)
4747
target_link_libraries(arrow_compute_testing
4848
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
4949
PUBLIC ${ARROW_GTEST_GTEST_MAIN})
50+
target_compile_definitions(arrow_compute_testing PRIVATE COMPILED_BY_CMAKE)
5051
else()
5152
target_link_libraries(arrow_compute_testing
5253
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>

cpp/src/arrow/compute/kernels/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ endforeach
152152
exc = executable(
153153
'arrow-compute-aggregate-test',
154154
sources: ['aggregate_test.cc'] + kernel_testing_srcs,
155-
dependencies: [arrow_compute_test_dep, filesystem_dep],
155+
dependencies: [arrow_compute_test_dep, boost_deps],
156156
)
157157
test('arrow-compute-aggregate-test', exc)
158158

cpp/src/arrow/compute/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ endif
5050
# Define arrow_compute_core_testing object library for common test files requiring
5151
# only core compute. No extra kernels are required.
5252
if needs_testing
53-
arrow_compute_core_test_lib = library(
53+
arrow_compute_core_test_lib = static_library(
5454
'arrow-compute-core-testing',
5555
sources: files('test_util_internal.cc'),
5656
dependencies: arrow_test_dep,
@@ -64,7 +64,7 @@ endif
6464

6565
# Define arrow_compute_testing object library for test files requiring extra kernels.
6666
if needs_testing and needs_compute
67-
arrow_compute_testing_lib = library(
67+
arrow_compute_testing_lib = static_library(
6868
'arrow-compute-testing',
6969
sources: files('test_env.cc'),
7070
dependencies: [

cpp/src/arrow/compute/test_env.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ class ComputeKernelEnvironment : public ::testing::Environment {
3535

3636
} // namespace
3737

38-
#ifdef _MSC_VER
38+
#if defined(_MSC_VER) && defined(COMPILED_BY_CMAKE)
3939
// Initialize the compute module
4040
::testing::Environment* compute_kernels_env =
4141
::testing::AddGlobalTestEnvironment(new ComputeKernelEnvironment);
4242
#endif
4343

4444
} // namespace arrow::compute
4545

46-
#ifndef _MSC_VER
46+
#if !(defined(_MSC_VER) && defined(COMPILED_BY_CMAKE))
4747
int main(int argc, char** argv) {
4848
::testing::InitGoogleTest(&argc, argv);
4949
::testing::AddGlobalTestEnvironment(new arrow::compute::ComputeKernelEnvironment);

cpp/src/arrow/filesystem/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_cpp_arg = '-DARROW_FILESYSTEM_EXAMPLE_LIBPATH="@0@"'.format(
4747
exc = executable(
4848
'arrow-filesystem-test',
4949
sources: ['filesystem_test.cc', 'localfs_test.cc'],
50-
dependencies: [arrow_test_dep],
50+
dependencies: [arrow_test_dep, arrow_filesystem_example_dep],
5151
cpp_args: test_cpp_arg,
5252
)
5353
test('arrow-filesystem-test', exc)

0 commit comments

Comments
 (0)