Skip to content

Commit e6cef22

Browse files
authored
GH-46827: [C++] Update Meson Configuration for compute shared lib (#46839)
### Rationale for this change The major refactor of the compute sources in #46261 addressed updates to the CMake configuration but not Meson. This is a follow up to get the Meson builds working again ### What changes are included in this PR? Meson configuration files are updated to reflect new source structure. gtest has also been bumped to a new WrapDB version, which fixes some undefined behavior that was compounded by updates to the compute test structure ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: #46827 Authored-by: Will Ayd <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
1 parent e23f0fe commit e6cef22

File tree

9 files changed

+204
-132
lines changed

9 files changed

+204
-132
lines changed

cpp/src/arrow/acero/meson.build

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ arrow_acero_srcs = [
8080
arrow_acero_lib = library(
8181
'arrow-acero',
8282
sources: arrow_acero_srcs,
83-
dependencies: [arrow_dep],
83+
dependencies: [arrow_compute_dep, arrow_dep],
8484
)
8585

8686
arrow_acero_dep = declare_dependency(link_with: [arrow_acero_lib])
8787

88-
arrow_acero_testing_sources = ['test_nodes.cc', 'test_util_internal.cc'] + arrow_compute_testing_srcs
88+
arrow_acero_testing_sources = ['test_nodes.cc', 'test_util_internal.cc']
8989

9090
arrow_acero_tests = {
9191
'plan-test': {'sources': ['plan_test.cc', 'test_nodes_test.cc']},
@@ -110,7 +110,7 @@ foreach key, val : arrow_acero_tests
110110
exc = executable(
111111
'arrow-acero-@0@'.format(key),
112112
sources: val['sources'] + arrow_acero_testing_sources,
113-
dependencies: [arrow_acero_dep, arrow_test_dep],
113+
dependencies: [arrow_acero_dep, arrow_compute_test_dep],
114114
)
115115
test(key, exc)
116116
endforeach
@@ -133,7 +133,19 @@ foreach key, val : arrow_acero_benchmarks
133133
exc = executable(
134134
key,
135135
sources: val['sources'] + arrow_acero_testing_sources,
136-
dependencies: [arrow_acero_dep, arrow_benchmark_dep, gmock_dep],
136+
dependencies: [
137+
arrow_acero_dep,
138+
arrow_compute_test_dep,
139+
arrow_benchmark_dep,
140+
gmock_dep,
141+
],
137142
)
138143
benchmark(key, exc)
139144
endforeach
145+
146+
pkg.generate(
147+
filebase: 'arrow-acero',
148+
name: 'Apache Arrow Acero Engine',
149+
description: 'Apache Arrow\'s Acero Engine',
150+
requires: ['arrow-compute'],
151+
)

cpp/src/arrow/c/meson.build

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
if needs_compute
19+
arrow_c_bridge_deps = [arrow_compute_test_dep]
20+
else
21+
arrow_c_bridge_deps = [arrow_test_dep]
22+
endif
23+
1824
exc = executable(
1925
'arrow-c-bridge-test',
2026
sources: ['bridge_test.cc'],
21-
dependencies: [arrow_test_dep],
27+
dependencies: arrow_c_bridge_deps,
2228
)
2329
test('arrow-c-bridge-test', exc)
2430

cpp/src/arrow/compute/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,15 @@ if(ARROW_TESTING AND ARROW_COMPUTE)
4848
add_library(arrow_compute_testing OBJECT ${ARROW_COMPUTE_TESTING_SRCS})
4949
# Even though this is still just an object library we still need to "link"
5050
# arrow_compute_core_testing so that is also included correctly
51-
target_link_libraries(arrow_compute_testing
52-
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
53-
PUBLIC ${ARROW_GTEST_GTEST_MAIN})
51+
if(MSVC AND MSVC_VERSION LESS 1930)
52+
target_link_libraries(arrow_compute_testing
53+
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
54+
PUBLIC ${ARROW_GTEST_GTEST_MAIN})
55+
else()
56+
target_link_libraries(arrow_compute_testing
57+
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
58+
PUBLIC ${ARROW_GTEST_GTEST})
59+
endif()
5460
endif()
5561

5662
set(ARROW_COMPUTE_TEST_PREFIX "arrow-compute")

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,11 @@ endif
2626

2727
exc = executable(
2828
'arrow-scalar-cast-test',
29-
sources: ['scalar_cast_test.cc'] + arrow_compute_testing_srcs + kernel_testing_srcs,
30-
dependencies: [arrow_test_dep],
29+
sources: ['scalar_cast_test.cc'] + kernel_testing_srcs,
30+
dependencies: [arrow_compute_test_dep],
3131
)
3232
test('arrow-scalar-cast-test', exc)
3333

34-
if needs_compute
35-
arrow_compute_test_dep = declare_dependency(dependencies: [arrow_test_dep])
36-
else
37-
arrow_compute_test_dep = disabler()
38-
endif
39-
4034
# ----------------------------------------------------------------------
4135
# Scalar kernels
4236

@@ -71,7 +65,7 @@ scalar_kernel_tests = {
7165
foreach key, val : scalar_kernel_tests
7266
exc = executable(
7367
key,
74-
sources: val['sources'] + arrow_compute_testing_srcs + kernel_testing_srcs,
68+
sources: val['sources'] + kernel_testing_srcs,
7569
dependencies: [arrow_compute_test_dep],
7670
)
7771
test(key, exc)
@@ -126,7 +120,7 @@ vector_kernel_tests = {
126120
foreach key, val : vector_kernel_tests
127121
exc = executable(
128122
key,
129-
sources: val['sources'] + arrow_compute_testing_srcs + kernel_testing_srcs,
123+
sources: val['sources'] + kernel_testing_srcs,
130124
dependencies: [arrow_compute_test_dep],
131125
)
132126
test(key, exc)
@@ -157,7 +151,7 @@ endforeach
157151
# Aggregates
158152
exc = executable(
159153
'arrow-compute-aggregate-test',
160-
sources: ['aggregate_test.cc'] + arrow_compute_testing_srcs + kernel_testing_srcs,
154+
sources: ['aggregate_test.cc'] + kernel_testing_srcs,
161155
dependencies: [arrow_compute_test_dep, filesystem_dep],
162156
)
163157
test('arrow-compute-aggregate-test', exc)

cpp/src/arrow/compute/meson.build

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,48 @@ install_headers(
4141
if needs_compute
4242
pkg.generate(
4343
filebase: 'arrow-compute',
44-
name: 'Apache Arrow Compute',
45-
description: 'All compute kernels for Apache Arrow',
44+
name: 'Apache Arrow Compute Kernels',
45+
description: 'Apache Arrow\'s Compute Kernels',
4646
requires: ['arrow'],
4747
)
4848
endif
4949

50-
arrow_compute_testing_srcs = []
50+
# Define arrow_compute_core_testing object library for common test files requiring
51+
# only core compute. No extra kernels are required.
5152
if needs_testing
52-
arrow_compute_testing_srcs += files('test_util_internal.cc')
53+
arrow_compute_core_test_lib = library(
54+
'arrow-compute-core-testing',
55+
sources: files('test_util_internal.cc'),
56+
dependencies: arrow_test_dep,
57+
)
58+
arrow_compute_core_test_dep = declare_dependency(
59+
link_with: arrow_compute_core_test_lib,
60+
)
61+
else
62+
arrow_compute_core_test_dep = disabler()
63+
endif
64+
65+
# Define arrow_compute_testing object library for test files requiring extra kernels.
66+
if needs_testing and needs_compute
67+
arrow_compute_testing_lib = library(
68+
'arrow-compute-testing',
69+
sources: files('test_env.cc'),
70+
dependencies: [
71+
arrow_compute_dep,
72+
arrow_compute_core_test_dep,
73+
arrow_test_dep_no_main,
74+
],
75+
)
76+
arrow_compute_test_dep = declare_dependency(
77+
link_with: arrow_compute_testing_lib,
78+
dependencies: [
79+
arrow_compute_dep,
80+
arrow_compute_core_test_dep,
81+
arrow_test_dep_no_main,
82+
],
83+
)
84+
else
85+
arrow_compute_test_dep = disabler()
5386
endif
5487

5588
exc = executable(
@@ -59,15 +92,13 @@ exc = executable(
5992
'exec_test.cc',
6093
'kernel_test.cc',
6194
'registry_test.cc',
62-
] + arrow_compute_testing_srcs,
63-
dependencies: [arrow_test_dep],
95+
],
96+
dependencies: [arrow_compute_core_test_dep, arrow_test_dep],
6497
)
6598
test('arrow-internals-test', exc)
6699

67100
compute_tests = {
68-
'arrow-compute-expression-test': {
69-
'sources': ['expression_test.cc'] + arrow_compute_testing_srcs,
70-
},
101+
'arrow-compute-expression-test': {'sources': ['expression_test.cc']},
71102
'arrow-compute-row-test': {
72103
'sources': [
73104
'key_hash_test.cc',
@@ -77,7 +108,7 @@ compute_tests = {
77108
'row/row_encoder_internal_test.cc',
78109
'row/row_test.cc',
79110
'util_internal_test.cc',
80-
] + arrow_compute_testing_srcs,
111+
],
81112
},
82113
}
83114

@@ -96,16 +127,14 @@ compute_tests = {
96127
# - value_counts
97128
#
98129
# Also see: GH-34388, GH-34615
99-
if needs_compute
100-
foreach key, val : compute_tests
101-
exc = executable(
102-
key,
103-
sources: val['sources'],
104-
dependencies: [arrow_test_dep],
105-
)
106-
test(key, exc)
107-
endforeach
108-
endif
130+
foreach key, val : compute_tests
131+
exc = executable(
132+
key,
133+
sources: val['sources'],
134+
dependencies: [arrow_compute_test_dep],
135+
)
136+
test(key, exc)
137+
endforeach
109138

110139
exc = executable(
111140
'arrow-compute-function-benchmark',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ if needs_compute
2424
exc = executable(
2525
'arrow-compute-grouper-benchmark',
2626
sources: ['grouper_benchmark.cc'],
27-
dependencies: [arrow_benchmark_dep],
27+
dependencies: [arrow_compute_dep, arrow_benchmark_dep],
2828
)
2929
endif

cpp/src/arrow/compute/test_env.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,18 @@ class ComputeKernelEnvironment : public ::testing::Environment {
3535

3636
} // namespace
3737

38+
#if defined(_MSC_VER) && _MSC_VER < 1930
3839
// Initialize the compute module
3940
::testing::Environment* compute_kernels_env =
4041
::testing::AddGlobalTestEnvironment(new ComputeKernelEnvironment);
42+
#endif
4143

4244
} // namespace arrow::compute
45+
46+
#if !(defined(_MSC_VER) && _MSC_VER < 1930)
47+
int main(int argc, char** argv) {
48+
::testing::InitGoogleTest(&argc, argv);
49+
::testing::AddGlobalTestEnvironment(new arrow::compute::ComputeKernelEnvironment);
50+
return RUN_ALL_TESTS();
51+
}
52+
#endif

0 commit comments

Comments
 (0)