meson: link tests with a convenience library of sources used by multiple binaries

This saves repeatedly compiling them, resulting in 16 fewer compile
steps, in exchange for one `ar` step.
This commit is contained in:
Eli Schwartz 2021-08-09 20:03:57 -04:00
parent 6a258043f5
commit ee3355df30
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6

View File

@ -29,58 +29,54 @@ ZSTDRTTEST = ['--test-large-data']
test_includes = [ include_directories(join_paths(zstd_rootdir, 'programs')) ] test_includes = [ include_directories(join_paths(zstd_rootdir, 'programs')) ]
datagen_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), testcommon_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'),
join_paths(zstd_rootdir, 'tests/datagencli.c')] join_paths(zstd_rootdir, 'programs/util.c'),
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'programs/benchfn.c'),
join_paths(zstd_rootdir, 'programs/benchzstd.c')]
testcommon = static_library('testcommon',
testcommon_sources)
datagen_sources = [join_paths(zstd_rootdir, 'tests/datagencli.c')]
datagen = executable('datagen', datagen = executable('datagen',
datagen_sources, datagen_sources,
c_args: [ '-DNDEBUG' ], c_args: [ '-DNDEBUG' ],
include_directories: test_includes, include_directories: test_includes,
dependencies: libzstd_dep, dependencies: libzstd_dep,
link_with: testcommon,
install: false) install: false)
fullbench_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), fullbench_sources = [join_paths(zstd_rootdir, 'tests/fullbench.c')]
join_paths(zstd_rootdir, 'programs/util.c'),
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'programs/benchfn.c'),
join_paths(zstd_rootdir, 'programs/benchzstd.c'),
join_paths(zstd_rootdir, 'tests/fullbench.c')]
fullbench = executable('fullbench', fullbench = executable('fullbench',
fullbench_sources, fullbench_sources,
include_directories: test_includes, include_directories: test_includes,
dependencies: libzstd_dep, dependencies: libzstd_dep,
link_with: testcommon,
install: false) install: false)
fuzzer_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), fuzzer_sources = [join_paths(zstd_rootdir, 'tests/fuzzer.c')]
join_paths(zstd_rootdir, 'programs/util.c'),
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'tests/fuzzer.c')]
fuzzer = executable('fuzzer', fuzzer = executable('fuzzer',
fuzzer_sources, fuzzer_sources,
include_directories: test_includes, include_directories: test_includes,
dependencies: [ libzstd_dep, thread_dep ], dependencies: [ libzstd_dep, thread_dep ],
link_with: testcommon,
install: false) install: false)
zstreamtest_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), zstreamtest_sources = [join_paths(zstd_rootdir, 'tests/seqgen.c'),
join_paths(zstd_rootdir, 'programs/util.c'),
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'tests/seqgen.c'),
join_paths(zstd_rootdir, 'tests/zstreamtest.c')] join_paths(zstd_rootdir, 'tests/zstreamtest.c')]
zstreamtest = executable('zstreamtest', zstreamtest = executable('zstreamtest',
zstreamtest_sources, zstreamtest_sources,
include_directories: test_includes, include_directories: test_includes,
dependencies: libzstd_dep, dependencies: libzstd_dep,
link_with: testcommon,
install: false) install: false)
paramgrill_sources = [join_paths(zstd_rootdir, 'programs/benchfn.c'), paramgrill_sources = [join_paths(zstd_rootdir, 'tests/paramgrill.c')]
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'programs/benchzstd.c'),
join_paths(zstd_rootdir, 'programs/datagen.c'),
join_paths(zstd_rootdir, 'programs/util.c'),
join_paths(zstd_rootdir, 'tests/paramgrill.c')]
paramgrill = executable('paramgrill', paramgrill = executable('paramgrill',
paramgrill_sources, paramgrill_sources,
include_directories: test_includes, include_directories: test_includes,
dependencies: [ libzstd_dep, libm_dep ], dependencies: [ libzstd_dep, libm_dep ],
link_with: testcommon,
install: false) install: false)
roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')] roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')]
@ -111,18 +107,15 @@ if 0 < legacy_level and legacy_level <= 4
install: false) install: false)
endif endif
decodecorpus_sources = [join_paths(zstd_rootdir, 'programs/util.c'), decodecorpus_sources = [join_paths(zstd_rootdir, 'tests/decodecorpus.c')]
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'tests/decodecorpus.c')]
decodecorpus = executable('decodecorpus', decodecorpus = executable('decodecorpus',
decodecorpus_sources, decodecorpus_sources,
include_directories: test_includes, include_directories: test_includes,
dependencies: [ libzstd_dep, libm_dep ], dependencies: [ libzstd_dep, libm_dep ],
link_with: testcommon,
install: false) install: false)
poolTests_sources = [join_paths(zstd_rootdir, 'programs/util.c'), poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c'),
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'tests/poolTests.c'),
join_paths(zstd_rootdir, 'lib/common/pool.c'), join_paths(zstd_rootdir, 'lib/common/pool.c'),
join_paths(zstd_rootdir, 'lib/common/threading.c'), join_paths(zstd_rootdir, 'lib/common/threading.c'),
join_paths(zstd_rootdir, 'lib/common/zstd_common.c'), join_paths(zstd_rootdir, 'lib/common/zstd_common.c'),
@ -131,6 +124,7 @@ poolTests = executable('poolTests',
poolTests_sources, poolTests_sources,
include_directories: test_includes, include_directories: test_includes,
dependencies: [ libzstd_dep, thread_dep ], dependencies: [ libzstd_dep, thread_dep ],
link_with: testcommon,
install: false) install: false)
checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')] checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')]