]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: use template to declare udev plugins
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 25 Jun 2023 20:01:03 +0000 (05:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 3 Aug 2023 11:37:16 +0000 (20:37 +0900)
src/udev/meson.build
test/meson.build

index 2c100959412b3248895383ca2dbcb5c68672ee17..bc5c859845f2e12174bd147382496a3cf6ed7a40 100644 (file)
@@ -116,6 +116,13 @@ libudevd_core = static_library(
                         userspace],
         build_by_default : false)
 
+udev_plugin_template = executable_template + {
+        'public' : true,
+        'link_with' : udev_link_with,
+        'install_rpath' : udev_rpath,
+        'install_dir' : udevlibexecdir,
+}
+
 executables += [
         executable_template + {
                 'name' : 'udevadm',
@@ -131,41 +138,50 @@ executables += [
                 ],
                 'install_rpath' : udev_rpath,
         },
+        udev_plugin_template + {
+                'name' : 'ata_id',
+                'sources' : files('ata_id/ata_id.c'),
+        },
+        udev_plugin_template + {
+                'name' : 'cdrom_id',
+                'sources' : files('cdrom_id/cdrom_id.c'),
+        },
+        udev_plugin_template + {
+                'name' : 'dmi_memory_id',
+                'conditions' : ['HAVE_DMI'],
+                'sources' : files('dmi_memory_id/dmi_memory_id.c'),
+        },
+        udev_plugin_template + {
+                'name' : 'fido_id',
+                'sources' : files(
+                        'fido_id/fido_id.c',
+                        'fido_id/fido_id_desc.c',
+                ),
+        },
+        udev_plugin_template + {
+                'name' : 'iocost',
+                'sources' : files('iocost/iocost.c'),
+        },
+        udev_plugin_template + {
+                'name' : 'mtd_probe',
+                'sources' : files(
+                        'mtd_probe/mtd_probe.c',
+                        'mtd_probe/probe_smartmedia.c',
+                ),
+        },
+        udev_plugin_template + {
+                'name' : 'scsi_id',
+                'sources' : files(
+                        'scsi_id/scsi_id.c',
+                        'scsi_id/scsi_serial.c',
+                ),
+        },
+        udev_plugin_template + {
+                'name' : 'v4l_id',
+                'sources' : files('v4l_id/v4l_id.c'),
+        },
 ]
 
-udev_progs = [['ata_id/ata_id.c'],
-              ['cdrom_id/cdrom_id.c'],
-              ['fido_id/fido_id.c',
-               'fido_id/fido_id_desc.c'],
-              ['iocost/iocost.c'],
-              ['scsi_id/scsi_id.c',
-               'scsi_id/scsi_serial.c'],
-              ['v4l_id/v4l_id.c'],
-              ['mtd_probe/mtd_probe.c',
-               'mtd_probe/probe_smartmedia.c']]
-
-if conf.get('HAVE_DMI') == 1
-        udev_progs += [['dmi_memory_id/dmi_memory_id.c']]
-endif
-
-udev_prog_paths = {}
-foreach prog : udev_progs
-        name = fs.stem(prog[0])
-
-        exe = executable(
-                name,
-                prog,
-                include_directories : includes,
-                dependencies : [userspace],
-                link_with : udev_link_with,
-                install_rpath : udev_rpath,
-                install : true,
-                install_dir : udevlibexecdir)
-
-        udev_prog_paths += {name : exe}
-        public_programs += exe
-endforeach
-
 meson.add_install_script(meson_make_symlink,
                          bindir / 'udevadm',
                          libexecdir / 'systemd-udevd')
index d57736e739d8822b895d3553e60932a878d0ef73..99f50828a3c2e3cafc78f147cbfedfbbf755f71f 100644 (file)
@@ -258,6 +258,7 @@ endif
 
 if want_tests != 'false' and conf.get('HAVE_DMI') == 1
         udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
+        exe = executables_by_name.get('dmi_memory_id')
 
         if git.found() and fs.is_dir(project_source_root / '.git')
                 out = run_command(
@@ -276,10 +277,10 @@ if want_tests != 'false' and conf.get('HAVE_DMI') == 1
                 test('dmidecode_' + fs.stem(p),
                      udev_dmi_memory_id_test,
                      suite : 'dist',
-                     args : [udev_prog_paths['dmi_memory_id'].full_path(),
+                     args : [exe.full_path(),
                              source,
                              source + '.txt'],
-                     depends : udev_prog_paths['dmi_memory_id'])
+                     depends : exe)
         endforeach
 endif