]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: use a convenience library for the sources shared between core/ and the outside
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 5 Mar 2019 15:19:40 +0000 (16:19 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 5 Mar 2019 20:01:17 +0000 (21:01 +0100)
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
src/core/meson.build
src/test/meson.build

index f2b975abc5555a8d2a986ad3c31e62007841e6e5..5597fe92364ae8c2e2a9754effc03d7a34e7b1cb 100644 (file)
@@ -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,
index 6f387c4796ae03908e00e50d6345dd7b2d25adfd..2e58146d1f1dd0687448b8048bcc2f5e2408314a 100644 (file)
@@ -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,
index e43f119230d7485f7597ec2b49ac7cb373966521..19f7a1e48647667e57984b4e3f60aa468879bcc3 100644 (file)
@@ -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'],