]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: support building .standalone variants for shared modules
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Jul 2026 19:30:10 +0000 (04:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 10 Jul 2026 07:29:54 +0000 (16:29 +0900)
Extend the module building logic to automatically generate '.standalone'
variants for non-NSS/PAM shared modules (such as cryptsetup tokens).

Like standalone executables, these are not built by default to keep
the base build time unaffected, but can be built explicitly on demand
via `ninja <module_name>.standalone`.

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

index 6850298a316fa6fe4e824155f6a262334f668ed4..f9c84767dee83ecaa1bea535c0fac1ac04b2a872 100644 (file)
@@ -2525,6 +2525,7 @@ test_dlopen = executables_by_name.get('test-dlopen')
 nss_targets = []
 pam_targets = []
 module_targets = []
+modules_by_name = {}
 foreach dict : modules
         name = dict.get('name')
         is_nss = name.startswith('nss_')
@@ -2570,6 +2571,40 @@ foreach dict : modules
         )
 
         module_targets += lib
+        modules_by_name += { name : lib }
+
+        if not is_nss and not is_pam
+                # Typically for cryptsetup token modules.
+
+                name_static = name + '.standalone'
+                kwargs_static = kwargs
+
+                link_with_static = []
+                foreach obj : kwargs_static.get('link_with', [])
+                        if obj.full_path() == libshared.full_path()
+                                link_with_static += [
+                                        libshared_static,
+                                        libsystemd_static,
+                                ]
+                        else
+                                link_with_static += obj
+                        endif
+                endforeach
+
+                kwargs_static += {
+                        'link_with' : link_with_static,
+                        'install' : false,
+                        'build_by_default' : false,
+                }
+
+                lib_static = shared_library(
+                        name_static,
+                        kwargs : kwargs_static,
+                        implicit_include_directories : false,
+                )
+
+                modules_by_name += { name_static : lib_static }
+        endif
 
         if is_nss
                 # We cannot use shared_module because it does not support version suffix.
index 078062d073f1ce0e518687f47a849c5d0ba0718b..db08b264cc848ac3b575878bd24b786039ee635a 100644 (file)
@@ -9,7 +9,6 @@ lib_cryptsetup_token_common = static_library(
                 libcryptsetup_cflags,
                 userspace,
         ],
-        link_with : libshared,
         build_by_default : false)
 
 cryptsetup_token_systemd_tpm2_sources = files(