From fd1939fbe73c59aaa911363cfa4f7be748fb1d2a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 12 Sep 2018 21:47:56 +0900 Subject: [PATCH] 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.] --- meson.build | 9 ++++++--- src/test/meson.build | 9 ++++++--- test/meson.build | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 12ddddd3ebe..694c5cfcdd7 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/src/test/meson.build b/src/test/meson.build index e82c993ab4d..86d7b16d459 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -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') diff --git a/test/meson.build b/test/meson.build index 8bec8dc07c8..9750ff22b94 100644 --- a/test/meson.build +++ b/test/meson.build @@ -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')