core: move several source files to src/shared

As, the files are used by many executables, fstab-generator, remount-fs,
machine-id-setup, and etc.
With this change, the total size of the relevant executables and
libshared slightly decreases.

Before:
```
$ ll systemd-fstab-generator systemd-remount-fs systemd-machine-id-setup systemd-shutdown systemd-nspawn systemd src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 7577800 Jan  5 13:35 src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 4608360 Jan  5 13:35 systemd
-rwxrwxr-x 1 watanabe watanabe  117240 Jan  5 13:35 systemd-fstab-generator
-rwxrwxr-x 1 watanabe watanabe   61576 Jan  5 13:35 systemd-machine-id-setup
-rwxrwxr-x 1 watanabe watanabe  853080 Jan  5 13:35 systemd-nspawn
-rwxrwxr-x 1 watanabe watanabe   70600 Jan  5 13:35 systemd-remount-fs
-rwxrwxr-x 1 watanabe watanabe  172624 Jan  5 13:35 systemd-shutdown
```
Total: 13461280

After:
```
$ ll systemd-fstab-generator systemd-remount-fs systemd-machine-id-setup systemd-shutdown systemd-nspawn systemd src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 7658336 Jan  5 13:32 src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 4523560 Jan  5 13:32 systemd
-rwxrwxr-x 1 watanabe watanabe   78288 Jan  5 13:32 systemd-fstab-generator
-rwxrwxr-x 1 watanabe watanabe   30984 Jan  5 13:32 systemd-machine-id-setup
-rwxrwxr-x 1 watanabe watanabe  840384 Jan  5 13:32 systemd-nspawn
-rwxrwxr-x 1 watanabe watanabe   39104 Jan  5 13:32 systemd-remount-fs
-rwxrwxr-x 1 watanabe watanabe  117160 Jan  5 13:32 systemd-shutdown
```
Total: 13287816
This commit is contained in:
Yu Watanabe 2021-01-01 05:38:06 +09:00
parent 772e0a76f3
commit bac11cd667
12 changed files with 14 additions and 33 deletions

View file

@ -1914,8 +1914,7 @@ executable(
'systemd-fstab-generator',
'src/fstab-generator/fstab-generator.c',
include_directories : includes,
link_with : [libcore_shared,
libshared],
link_with : [libshared],
install_rpath : rootlibexecdir,
install : true,
install_dir : systemgeneratordir)
@ -2925,8 +2924,7 @@ executable(
'systemd-remount-fs',
'src/remount-fs/remount-fs.c',
include_directories : includes,
link_with : [libcore_shared,
libshared],
link_with : [libshared],
install_rpath : rootlibexecdir,
install : true,
install_dir : rootlibexecdir)
@ -2935,8 +2933,7 @@ executable(
'systemd-machine-id-setup',
'src/machine-id-setup/machine-id-setup-main.c',
include_directories : includes,
link_with : [libcore_shared,
libshared],
link_with : [libshared],
install_rpath : rootlibexecdir,
install : true,
install_dir : rootbindir)
@ -3287,8 +3284,7 @@ executable(
'systemd-shutdown',
systemd_shutdown_sources,
include_directories : includes,
link_with : [libcore_shared,
libshared],
link_with : [libshared],
dependencies : [libmount],
install_rpath : rootlibexecdir,
install : true,
@ -3336,8 +3332,7 @@ public_programs += executable(
'systemd-nspawn',
systemd_nspawn_sources,
include_directories : includes,
link_with : [libcore_shared,
libnspawn_core,
link_with : [libnspawn_core,
libshared],
dependencies : [libblkid,
libseccomp],

View file

@ -1,16 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
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_sources = '''
apparmor-setup.c
apparmor-setup.h
@ -151,22 +140,12 @@ 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_sources,
load_fragment_gperf_c,
load_fragment_gperf_nulstr_c,
include_directories : includes,
link_whole : libcore_shared,
dependencies : [versiondep,
threads,
librt,

View file

@ -145,6 +145,8 @@ shared_sources = files('''
json-internal.h
json.c
json.h
killall.c
killall.h
libcrypt-util.c
libcrypt-util.h
libfido2-util.c
@ -165,6 +167,10 @@ shared_sources = files('''
logs-show.h
loop-util.c
loop-util.h
loopback-setup.c
loopback-setup.h
machine-id-setup.c
machine-id-setup.h
machine-image.c
machine-image.h
machine-pool.c
@ -175,6 +181,8 @@ shared_sources = files('''
mkfs-util.c
mkfs-util.h
module-util.h
mount-setup.c
mount-setup.h
mount-util.c
mount-util.h
net-condition.c

View file

@ -775,8 +775,7 @@ tests += [
[['src/test/test-umount.c',
'src/shutdown/umount.c',
'src/shutdown/umount.h'],
[libcore_shared,
libshared],
[libshared],
[libmount]],
[['src/test/test-bus-util.c'],