]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: drop three more single-use convenience libraries 21786/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 16 Dec 2021 10:51:08 +0000 (11:51 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 16 Dec 2021 10:51:40 +0000 (11:51 +0100)
The way that the cryptsetup plugins were built was unnecessarilly complicated.
We would build three static libraries that would then be linked into dynamic
libraries. No need to do this.

While at it, let's use a convenience library to avoid compiling the shared code
more than once.

We want the output .so files to be located in the main build directory,
like with all consumable build artifacts, so we need to maintain the split
between src/cryptsetup/cryptsetup-token/meson.build and the main meson.build
file.

AFAICT, the build artifacts are the same: exported and undefined symbols are
identical. There is a tiny difference in size, but I think it might be caused
by a different build directory name.

meson.build
src/cryptsetup/cryptsetup-tokens/meson.build

index bdf192cfc1b41c1a3f43c7e11eb19868cc4b5010..b6170eecf9db1e4f8c5b85ad92a37dd883945a51 100644 (file)
@@ -1836,11 +1836,15 @@ if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
         if conf.get('HAVE_TPM2') == 1
                 cryptsetup_token_systemd_tpm2 = shared_library(
                         'cryptsetup-token-systemd-tpm2',
+                        cryptsetup_token_systemd_tpm2_sources,
+                        include_directories : includes,
                         link_args : ['-shared',
                                      '-Wl,--version-script=' + cryptsetup_token_sym_path],
-                        dependencies : libshared_deps + [libcryptsetup, versiondep],
-                        link_with : [libshared],
-                        link_whole : [cryptsetup_token_systemd_tpm2_static],
+                        link_with : [lib_cryptsetup_token_common,
+                                     libshared],
+                        dependencies : [libcryptsetup,
+                                        tpm2,
+                                        versiondep],
                         link_depends : cryptsetup_token_sym,
                         install_rpath : rootlibexecdir,
                         install : true,
@@ -1850,11 +1854,15 @@ if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
         if conf.get('HAVE_LIBFIDO2') == 1
                 cryptsetup_token_systemd_fido2 = shared_library(
                         'cryptsetup-token-systemd-fido2',
+                        cryptsetup_token_systemd_fido2_sources,
+                        include_directories : includes,
                         link_args : ['-shared',
                                      '-Wl,--version-script=' + cryptsetup_token_sym_path],
-                        dependencies : libshared_deps + [libcryptsetup, versiondep],
-                        link_with : [libshared],
-                        link_whole : [cryptsetup_token_systemd_fido2_static],
+                        link_with : [lib_cryptsetup_token_common,
+                                     libshared],
+                        dependencies : [libcryptsetup,
+                                        libfido2,
+                                        versiondep],
                         link_depends : cryptsetup_token_sym,
                         install_rpath : rootlibexecdir,
                         install : true,
@@ -1864,11 +1872,15 @@ if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
         if conf.get('HAVE_P11KIT') == 1
                 cryptsetup_token_systemd_pkcs11 = shared_library(
                         'cryptsetup-token-systemd-pkcs11',
+                        cryptsetup_token_systemd_pkcs11_sources,
+                        include_directories : includes,
                         link_args : ['-shared',
                                      '-Wl,--version-script=' + cryptsetup_token_sym_path],
-                        dependencies : libshared_deps + [libcryptsetup, versiondep],
-                        link_with : [libshared],
-                        link_whole : [cryptsetup_token_systemd_pkcs11_static],
+                        link_with : [lib_cryptsetup_token_common,
+                                     libshared],
+                        dependencies : [libcryptsetup,
+                                        libp11kit,
+                                        versiondep],
                         link_depends : cryptsetup_token_sym,
                         install_rpath : rootlibexecdir,
                         install : true,
index d174fcb714ec7f91845b08502b292da2baeb1a2e..42c29f100e0c297beacccbc3da49df1b036b4f1a 100644 (file)
@@ -1,64 +1,28 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
-if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
-
-cryptsetup_token_c_args = ['-fvisibility=hidden']
-
 cryptsetup_token_sym = files('cryptsetup-token.sym')
 cryptsetup_token_sym_path = meson.current_source_dir() / 'cryptsetup-token.sym'
 
-if conf.get('HAVE_TPM2') == 1
-        cryptsetup_token_systemd_tpm2_sources = files('''
-                cryptsetup-token-systemd-tpm2.c
-                cryptsetup-token.h
-                cryptsetup-token-util.h
-                cryptsetup-token-util.c
-                luks2-tpm2.c
-                luks2-tpm2.h
-        '''.split())
-
-        cryptsetup_token_systemd_tpm2_static = static_library(
-                'cryptsetup-token-systemd-tpm2_static',
-                cryptsetup_token_systemd_tpm2_sources,
-                include_directories : includes,
-                dependencies : libshared_deps + [libcryptsetup, versiondep],
-                c_args : cryptsetup_token_c_args)
-endif
-
-if conf.get('HAVE_LIBFIDO2') == 1
-        cryptsetup_token_systemd_fido2_sources = files('''
-                cryptsetup-token-systemd-fido2.c
-                cryptsetup-token.h
-                cryptsetup-token-util.h
-                cryptsetup-token-util.c
-                luks2-fido2.c
-                luks2-fido2.h
-        '''.split())
-
-        cryptsetup_token_systemd_fido2_static = static_library(
-                'cryptsetup-token-systemd-fido2_static',
-                cryptsetup_token_systemd_fido2_sources,
-                include_directories : includes,
-                dependencies : libshared_deps + [libcryptsetup, versiondep],
-                c_args : cryptsetup_token_c_args)
-endif
-
-if conf.get('HAVE_P11KIT') == 1
-        cryptsetup_token_systemd_pkcs11_sources = files('''
-                cryptsetup-token-systemd-pkcs11.c
-                cryptsetup-token.h
-                cryptsetup-token-util.h
-                cryptsetup-token-util.c
-                luks2-pkcs11.c
-                luks2-pkcs11.h
-        '''.split())
-
-        cryptsetup_token_systemd_pkcs11_static = static_library(
-                'cryptsetup-token-systemd-pkcs11_static',
-                cryptsetup_token_systemd_pkcs11_sources,
-                include_directories : includes,
-                dependencies : libshared_deps + [libcryptsetup, versiondep],
-                c_args : cryptsetup_token_c_args)
-endif
-
-endif
+lib_cryptsetup_token_common = static_library(
+        'cryptsetup-token-common',
+        'cryptsetup-token.h',
+        'cryptsetup-token-util.h',
+        'cryptsetup-token-util.c',
+        include_directories : includes,
+        link_with : libshared,
+        build_by_default : false)
+
+cryptsetup_token_systemd_tpm2_sources = files(
+        'cryptsetup-token-systemd-tpm2.c',
+        'luks2-tpm2.c',
+        'luks2-tpm2.h')
+
+cryptsetup_token_systemd_fido2_sources = files(
+        'cryptsetup-token-systemd-fido2.c',
+        'luks2-fido2.c',
+        'luks2-fido2.h')
+
+cryptsetup_token_systemd_pkcs11_sources = files(
+        'cryptsetup-token-systemd-pkcs11.c',
+        'luks2-pkcs11.c',
+        'luks2-pkcs11.h')