From: Zbigniew Jędrzejewski-Szmek Date: Tue, 5 Mar 2019 15:19:40 +0000 (+0100) Subject: meson: use a convenience library for the sources shared between core/ and the outside X-Git-Tag: v242-rc1~190^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53f79e125d5614d899bc3489d00850ddf66c45d7;p=thirdparty%2Fsystemd.git meson: use a convenience library for the sources shared between core/ and the outside This avoids double compilation. Those files are tiny, so it doesn't save time, but we avoid repeated warnings and errors, and it's generally cleaner to it this way. The number of commands in 'ninja -C build clean && ninja -C build' drops from 1462 to 1455 for me. --- diff --git a/meson.build b/meson.build index f2b975abc55..5597fe92364 100644 --- a/meson.build +++ b/meson.build @@ -1713,9 +1713,9 @@ executable('systemd-run-generator', executable('systemd-fstab-generator', 'src/fstab-generator/fstab-generator.c', - 'src/core/mount-setup.c', include_directories : includes, - link_with : [libshared], + link_with : [libcore_shared, + libshared], install_rpath : rootlibexecdir, install : true, install_dir : systemgeneratordir) @@ -2353,20 +2353,18 @@ endif executable('systemd-remount-fs', 'src/remount-fs/remount-fs.c', - 'src/core/mount-setup.c', - 'src/core/mount-setup.h', include_directories : includes, - link_with : [libshared], + link_with : [libcore_shared, + libshared], install_rpath : rootlibexecdir, install : true, install_dir : rootlibexecdir) executable('systemd-machine-id-setup', 'src/machine-id-setup/machine-id-setup-main.c', - 'src/core/machine-id-setup.c', - 'src/core/machine-id-setup.h', include_directories : includes, - link_with : [libshared], + link_with : [libcore_shared, + libshared], install_rpath : rootlibexecdir, install : true, install_dir : rootbindir) @@ -2678,12 +2676,9 @@ public_programs += exe executable('systemd-shutdown', systemd_shutdown_sources, - 'src/core/mount-setup.c', - 'src/core/mount-setup.h', - 'src/core/killall.c', - 'src/core/killall.h', include_directories : includes, - link_with : [libshared], + link_with : [libcore_shared, + libshared], dependencies : [libmount], install_rpath : rootlibexecdir, install : true, @@ -2724,12 +2719,9 @@ endif exe = executable('systemd-nspawn', systemd_nspawn_sources, - 'src/core/mount-setup.c', # FIXME: use a variable? - 'src/core/mount-setup.h', - 'src/core/loopback-setup.c', - 'src/core/loopback-setup.h', include_directories : includes, - link_with : [libnspawn_core, + link_with : [libcore_shared, + libnspawn_core, libshared], dependencies : [libblkid], install_rpath : rootlibexecdir, diff --git a/src/core/meson.build b/src/core/meson.build index 6f387c4796a..2e58146d1f1 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -1,5 +1,16 @@ # SPDX-License-Identifier: LGPL-2.1+ +libcore_shared_sources = ''' + killall.c + killall.h + loopback-setup.c + loopback-setup.h + machine-id-setup.c + machine-id-setup.h + mount-setup.c + mount-setup.h +'''.split() + libcore_la_sources = ''' audit-fd.c audit-fd.h @@ -69,8 +80,6 @@ libcore_la_sources = ''' job.h kill.c kill.h - killall.c - killall.h kmod-setup.c kmod-setup.h load-dropin.c @@ -79,14 +88,8 @@ libcore_la_sources = ''' load-fragment.h locale-setup.c locale-setup.h - loopback-setup.c - loopback-setup.h - machine-id-setup.c - machine-id-setup.h manager.c manager.h - mount-setup.c - mount-setup.h mount.c mount.h namespace.c @@ -144,12 +147,22 @@ load_fragment_gperf_nulstr_c = custom_target( command : [awk, '-f', '@INPUT0@', '@INPUT1@'], capture : true) +# A convenience library to share code with other binaries: +# systemd-shutdown, systemd-remount-fs, systemd-machine-id-setup, … +libcore_shared = static_library( + 'core-shared', + libcore_shared_sources, + include_directories : includes, + dependencies : [versiondep, + libmount]) + libcore = static_library( 'core', libcore_la_sources, load_fragment_gperf_c, load_fragment_gperf_nulstr_c, include_directories : includes, + link_whole : libcore_shared, dependencies : [versiondep, threads, librt, diff --git a/src/test/meson.build b/src/test/meson.build index e43f119230d..19f7a1e4864 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -714,11 +714,10 @@ tests += [ 'ENABLE_NSS', 'manual'], [['src/test/test-umount.c', - 'src/core/mount-setup.c', - 'src/core/mount-setup.h', 'src/shutdown/umount.c', 'src/shutdown/umount.h'], - [], + [libcore_shared, + libshared], [libmount]], [['src/test/test-bus-util.c'],