meson: do not build tests by default when '-Dtests=false'

[zj: it is still possible to build tests explicitly by calling
     ninja -C build test-name. This way we have full flexibility.]
This commit is contained in:
Yu Watanabe 2018-09-12 21:47:56 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 964bc0ad60
commit fd1939fbe7
3 changed files with 13 additions and 7 deletions

View File

@ -1466,7 +1466,8 @@ test_dlopen = executable(
test_dlopen_c,
include_directories : includes,
link_with : [libbasic],
dependencies : [libdl])
dependencies : [libdl],
build_by_default : want_tests != 'false')
foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
['systemd', 'ENABLE_NSS_SYSTEMD'],
@ -2672,6 +2673,7 @@ exe = executable(
test_libsystemd_sym_c,
include_directories : includes,
link_with : [libsystemd],
build_by_default : want_tests != 'false',
install : install_tests,
install_dir : testsdir)
if want_tests != 'false'
@ -2685,7 +2687,7 @@ exe = executable(
link_with : [install_libsystemd_static],
dependencies : [threads], # threads is already included in dependencies on the library,
# but does not seem to get propagated. Add here as a work-around.
build_by_default : static_libsystemd_pic,
build_by_default : want_tests != 'false' and static_libsystemd_pic,
install : install_tests and static_libsystemd_pic,
install_dir : testsdir)
if want_tests != 'false' and static_libsystemd_pic
@ -2698,6 +2700,7 @@ exe = executable(
include_directories : includes,
c_args : ['-Wno-deprecated-declarations'],
link_with : [libudev],
build_by_default : want_tests != 'false',
install : install_tests,
install_dir : testsdir)
if want_tests != 'false'
@ -2710,7 +2713,7 @@ exe = executable(
include_directories : includes,
c_args : ['-Wno-deprecated-declarations'],
link_with : [install_libudev_static],
build_by_default : static_libudev_pic,
build_by_default : want_tests != 'false' and static_libudev_pic,
install : install_tests and static_libudev_pic,
install_dir : testsdir)
if want_tests != 'false' and static_libudev_pic

View File

@ -6,7 +6,8 @@ test_hashmap_ordered_c = custom_target(
input : [awkscript, 'test-hashmap-plain.c'],
output : 'test-hashmap-ordered.c',
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
capture : true,
build_by_default : want_tests != 'false')
test_include_dir = include_directories('.')
@ -26,14 +27,16 @@ test_libsystemd_sym_c = custom_target(
input : [libsystemd_sym_path] + systemd_headers,
output : 'test-libsystemd-sym.c',
command : [generate_sym_test_py, libsystemd_sym_path] + systemd_headers,
capture : true)
capture : true,
build_by_default : want_tests != 'false')
test_libudev_sym_c = custom_target(
'test-libudev-sym.c',
input : [libudev_sym_path, libudev_h_path],
output : 'test-libudev-sym.c',
command : [generate_sym_test_py, '@INPUT0@', '@INPUT1@'],
capture : true)
capture : true,
build_by_default : want_tests != 'false')
test_dlopen_c = files('test-dlopen.c')

View File

@ -235,7 +235,7 @@ custom_target(
'sys',
command : [sys_script_py, meson.current_build_dir()],
output : 'sys',
build_by_default : true)
build_by_default : want_tests != 'false')
if perl.found()
udev_test_pl = find_program('udev-test.pl')