From 53f79e125d5614d899bc3489d00850ddf66c45d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 5 Mar 2019 16:19:40 +0100 Subject: [PATCH 1/2] 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. --- meson.build | 28 ++++++++++------------------ src/core/meson.build | 29 +++++++++++++++++++++-------- src/test/meson.build | 5 ++--- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/meson.build b/meson.build index f2b975abc5..5597fe9236 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 6f387c4796..2e58146d1f 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 e43f119230..19f7a1e486 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'], From 68d923d0d097f5ffb198e6f2674f154f7e358b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 5 Mar 2019 16:22:33 +0100 Subject: [PATCH 2/2] meson: drop "_la_" from variable name A left-over from libtool times. --- src/core/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/meson.build b/src/core/meson.build index 2e58146d1f..86ab35d818 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -11,7 +11,7 @@ libcore_shared_sources = ''' mount-setup.h '''.split() -libcore_la_sources = ''' +libcore_sources = ''' audit-fd.c audit-fd.h automount.c @@ -158,7 +158,7 @@ libcore_shared = static_library( libcore = static_library( 'core', - libcore_la_sources, + libcore_sources, load_fragment_gperf_c, load_fragment_gperf_nulstr_c, include_directories : includes,