]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Use static library for EFI tests 26641/head
authorJan Janssen <medhefgo@web.de>
Sat, 4 Mar 2023 13:10:35 +0000 (14:10 +0100)
committerJan Janssen <medhefgo@web.de>
Fri, 10 Mar 2023 10:41:08 +0000 (11:41 +0100)
This also moves them so that fuzz builds do not need pyelftools around.

src/boot/efi/meson.build

index 6b04cfb4951b6792382a23b236dd3d8412d4f760..7e497f78663deea4c5a8386e660d614ad88e51a0 100644 (file)
@@ -2,6 +2,55 @@
 
 efi_config_h_dir = meson.current_build_dir()
 
+if efi_arch != ''
+        libefitest = static_library(
+                'efitest',
+                files(
+                        'bcd.c',
+                        'efi-string.c',
+                ),
+                build_by_default : false,
+                include_directories : [
+                        basic_includes,
+                        include_directories('.'),
+                ],
+                dependencies : userspace)
+
+        efitest_base = {
+                'link_with' : [
+                        libefitest,
+                        libshared,
+                ],
+        }
+
+        tests += [
+                {
+                        'sources' : files('test-bcd.c'),
+                        'dependencies' : libzstd,
+                        'condition' : 'HAVE_ZSTD',
+                        'base' : efitest_base,
+                },
+                {
+                        'sources' : files('test-efi-string.c'),
+                        'base' : efitest_base,
+                },
+        ]
+        fuzzers += [
+                {
+                        'sources' : files('fuzz-bcd.c'),
+                        'base' : efitest_base,
+                },
+                {
+                        'sources' : files('fuzz-efi-string.c'),
+                        'base' : efitest_base,
+                },
+                {
+                        'sources' : files('fuzz-efi-printf.c'),
+                        'base' : efitest_base,
+                },
+        ]
+endif
+
 if conf.get('ENABLE_BOOTLOADER') != 1
         subdir_done()
 endif
@@ -209,49 +258,9 @@ if host_machine.cpu_family() in ['x86', 'x86_64']
         stub_sources += files('linux_x86.c')
 endif
 
-tests += [
-        {
-                'sources' : files(
-                        'test-efi-string.c',
-                        'efi-string.c',
-                )
-        },
-]
-
 # BCD parser only makes sense on arches that Windows supports.
 if host_machine.cpu_family() in ['aarch64', 'arm', 'x86_64', 'x86']
         systemd_boot_sources += files('bcd.c')
-        tests += [
-                {
-                        'sources' : files(
-                                'test-bcd.c',
-                                'efi-string.c',
-                        ),
-                        'dependencies' : libzstd,
-                        'condition' : 'HAVE_ZSTD',
-                },
-        ]
-        fuzzers += [
-                {
-                        'sources' : files(
-                                'fuzz-bcd.c',
-                                'bcd.c',
-                                'efi-string.c'
-                        ),
-                },
-                {
-                        'sources' : files(
-                                'fuzz-efi-string.c',
-                                'efi-string.c'
-                        ),
-                },
-                {
-                        'sources' : files(
-                                'fuzz-efi-printf.c',
-                                'efi-string.c'
-                        ),
-                },
-        ]
 endif
 
 boot_targets = []