Skip to content

Commit ccd0223

Browse files
authored
GH-45865: [C++] Create dedicated benchmark dependency in Meson (#45909)
### Rationale for this change This helps simplify the Meson configuration by conditionally creating an "Arrow Benchmark Dependency," which may be a disabler when benchmarks are not desired ### What changes are included in this PR? This is a refactor of the meson.build configuration files ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: #45865 Authored-by: Will Ayd <william.ayd@icloud.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 0d72c66 commit ccd0223

File tree

5 files changed

+49
-42
lines changed

5 files changed

+49
-42
lines changed

cpp/src/arrow/c/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test('arrow-dlpack-test', exc)
3232
exc = executable(
3333
'arrow-bridge-benchmark',
3434
sources: ['bridge_benchmark.cc'],
35-
dependencies: [arrow_test_dep, benchmark_dep],
35+
dependencies: [arrow_benchmark_dep],
3636
)
3737
benchmark('arrow-bridge-benchmark', exc)
3838

cpp/src/arrow/csv/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ foreach csv_benchmark : csv_benchmarks
3939
exc = executable(
4040
benchmark_name,
4141
sources: '@0@.cc'.format(csv_benchmark),
42-
dependencies: [arrow_test_dep, benchmark_dep],
42+
dependencies: [arrow_benchmark_dep],
4343
)
4444
benchmark(benchmark_name, exc)
4545
endforeach

cpp/src/arrow/io/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ foreach io_benchmark : io_benchmarks
4747
exc = executable(
4848
benchmark_name,
4949
sources: '@0@.cc'.format(io_benchmark),
50-
dependencies: [arrow_test_dep, benchmark_dep],
50+
dependencies: [arrow_benchmark_dep],
5151
implicit_include_directories: false,
5252
)
5353
benchmark(benchmark_name, exc)

cpp/src/arrow/meson.build

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,12 @@ if needs_testing
390390
filesystem_dep = boost_proj.dependency('boost_filesystem')
391391
endif
392392

393+
gtest_dep = dependency('gtest')
393394
gtest_main_dep = dependency('gtest_main')
394395
gmock_dep = dependency('gmock')
395396
else
396397
filesystem_dep = disabler()
398+
gtest_dep = disabler()
397399
gtest_main_dep = disabler()
398400
gmock_dep = disabler()
399401
endif
@@ -404,10 +406,14 @@ arrow_test_lib = static_library(
404406
dependencies: [arrow_dep, filesystem_dep, gtest_main_dep],
405407
)
406408

407-
arrow_test_dep = declare_dependency(
408-
link_with: [arrow_test_lib],
409-
dependencies: [arrow_dep, filesystem_dep, gmock_dep, gtest_main_dep],
410-
)
409+
if needs_tests
410+
arrow_test_dep = declare_dependency(
411+
link_with: [arrow_test_lib],
412+
dependencies: [arrow_dep, filesystem_dep, gmock_dep, gtest_main_dep],
413+
)
414+
else
415+
arrow_test_dep = disabler()
416+
endif
411417

412418
arrow_tests = {
413419
'arrow-array-test': {
@@ -459,24 +465,27 @@ if needs_ipc
459465
}
460466
endif
461467

462-
if needs_tests
463-
foreach key, val : arrow_tests
464-
exc = executable(
465-
key,
466-
sources: val['sources'],
467-
dependencies: [arrow_test_dep, val.get('dependencies', [])],
468-
)
469-
test(key, exc)
470-
endforeach
471-
endif
468+
foreach key, val : arrow_tests
469+
exc = executable(
470+
key,
471+
sources: val['sources'],
472+
dependencies: [arrow_test_dep, val.get('dependencies', [])],
473+
)
474+
test(key, exc)
475+
endforeach
472476

473477
if needs_benchmarks
474-
benchmark_dep = dependency(
475-
'benchmark',
478+
benchmark_main_dep = dependency(
479+
'benchmark-main',
476480
default_options: {'tests': 'disabled'},
477481
)
482+
483+
arrow_benchmark_dep = declare_dependency(
484+
link_with: [arrow_test_lib],
485+
dependencies: [arrow_dep, benchmark_main_dep, gtest_dep],
486+
)
478487
else
479-
benchmark_dep = disabler()
488+
arrow_benchmark_dep = disabler()
480489
endif
481490

482491
arrow_benchmarks = [
@@ -493,7 +502,7 @@ foreach benchmark : arrow_benchmarks
493502
exc = executable(
494503
benchmark_name,
495504
sources: '@0@.cc'.format(benchmark),
496-
dependencies: [arrow_test_dep, benchmark_dep],
505+
dependencies: [arrow_benchmark_dep],
497506
)
498507

499508
benchmark(benchmark_name, exc)

cpp/src/arrow/testing/meson.build

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,25 @@ install_headers(
3838
subdir: 'arrow/testing',
3939
)
4040

41-
if needs_tests
42-
testing_tests = {
43-
'arrow-generator-test': {'sources': ['generator_test.cc']},
44-
'arrow-gtest-util-test': {'sources': ['gtest_util_test.cc']},
45-
'arrow-random-test': {'sources': ['random_test.cc']},
46-
}
41+
testing_tests = {
42+
'arrow-generator-test': {'sources': ['generator_test.cc']},
43+
'arrow-gtest-util-test': {'sources': ['gtest_util_test.cc']},
44+
'arrow-random-test': {'sources': ['random_test.cc']},
45+
}
4746

48-
foreach key, val : testing_tests
49-
exc = executable(
50-
key,
51-
sources: val['sources'],
52-
dependencies: [arrow_test_dep, val.get('dependencies', [])],
53-
)
54-
test(key, exc)
55-
endforeach
47+
foreach key, val : testing_tests
48+
exc = executable(
49+
key,
50+
sources: val['sources'],
51+
dependencies: [arrow_test_dep, val.get('dependencies', [])],
52+
)
53+
test(key, exc)
54+
endforeach
5655

57-
if needs_filesystem
58-
library(
59-
'arrow-filesystem-example',
60-
sources: ['examplefs.cc'],
61-
dependencies: [arrow_dep, gtest_main_dep],
62-
)
63-
endif
56+
if needs_tests and needs_filesystem
57+
shared_module(
58+
'arrow-filesystem-example',
59+
sources: ['examplefs.cc'],
60+
dependencies: [arrow_dep, gtest_dep],
61+
)
6462
endif

0 commit comments

Comments
 (0)