naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
594167
From 3088f292855f4a525271906a5652985f01c5d7b2 Mon Sep 17 00:00:00 2001
594167
From: Jan Janssen <medhefgo@web.de>
594167
Date: Fri, 7 Jan 2022 21:55:50 +0100
594167
Subject: [PATCH] meson: Use files() for source lists for boot and fundamental
594167
594167
This fixes build reproducibility as otherwise the full path
594167
of the source files ends up in the output binary.
594167
594167
(cherry picked from commit b3c5a7074cd434bc02c4b560afe933d3df24759e)
594167
594167
Related: #2017035
594167
---
594167
 src/boot/efi/meson.build    | 29 +++++++++++++++++------------
594167
 src/fundamental/meson.build | 22 +++++++++-------------
594167
 2 files changed, 26 insertions(+), 25 deletions(-)
594167
594167
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build
594167
index 144fbb0f43..4cc43dc00c 100644
594167
--- a/src/boot/efi/meson.build
594167
+++ b/src/boot/efi/meson.build
594167
@@ -312,9 +312,10 @@ efi_headers = files(
594167
         'shim.h',
594167
         'splash.h',
594167
         'util.h',
594167
-        'xbootldr.h')
594167
+        'xbootldr.h',
594167
+)
594167
 
594167
-common_sources = [
594167
+common_sources = files(
594167
         'assert.c',
594167
         'devicetree.c',
594167
         'disk.c',
594167
@@ -322,31 +323,34 @@ common_sources = [
594167
         'measure.c',
594167
         'pe.c',
594167
         'secure-boot.c',
594167
-        'util.c']
594167
+        'util.c',
594167
+)
594167
 
594167
-systemd_boot_sources = [
594167
+systemd_boot_sources = files(
594167
         'boot.c',
594167
         'console.c',
594167
         'drivers.c',
594167
         'random-seed.c',
594167
         'shim.c',
594167
-        'xbootldr.c']
594167
+        'xbootldr.c',
594167
+)
594167
 
594167
-stub_sources = [
594167
+stub_sources = files(
594167
         'cpio.c',
594167
         'initrd.c',
594167
         'splash.c',
594167
-        'stub.c']
594167
+        'stub.c',
594167
+)
594167
 
594167
 if efi_arch[1] in ['ia32', 'x86_64']
594167
-        stub_sources += 'linux_x86.c'
594167
+        stub_sources += files('linux_x86.c')
594167
 else
594167
-        stub_sources += 'linux.c'
594167
+        stub_sources += files('linux.c')
594167
 endif
594167
 
594167
 # BCD parser only makes sense on arches that Windows supports.
594167
 if efi_arch[1] in ['ia32', 'x86_64', 'arm', 'aarch64']
594167
-        systemd_boot_sources += 'bcd.c'
594167
+        systemd_boot_sources += files('bcd.c')
594167
         tests += [
594167
                 [['src/boot/efi/test-bcd.c'],
594167
                  [],
594167
@@ -359,9 +363,10 @@ endif
594167
 systemd_boot_objects = []
594167
 stub_objects = []
594167
 foreach file : fundamental_source_paths + common_sources + systemd_boot_sources + stub_sources
594167
-        o_file = custom_target(file.split('/')[-1] + '.o',
594167
+        # FIXME: replace ''.format(file) with fs.name(file) when meson_version requirement is >= 0.59.0
594167
+        o_file = custom_target('@0@.o'.format(file).split('/')[-1],
594167
                                input : file,
594167
-                               output : file.split('/')[-1] + '.o',
594167
+                               output : '@0@.o'.format(file).split('/')[-1],
594167
                                command : [cc.cmd_array(), '-c', '@INPUT@', '-o', '@OUTPUT@', efi_cflags],
594167
                                depend_files : efi_headers + fundamental_headers)
594167
         if (fundamental_source_paths + common_sources + systemd_boot_sources).contains(file)
594167
diff --git a/src/fundamental/meson.build b/src/fundamental/meson.build
594167
index 287f0fe36a..f927788c3a 100644
594167
--- a/src/fundamental/meson.build
594167
+++ b/src/fundamental/meson.build
594167
@@ -8,20 +8,16 @@ fundamental_headers = files(
594167
         'macro-fundamental.h',
594167
         'sha256.h',
594167
         'string-util-fundamental.h',
594167
-        'types-fundamental.h')
594167
-
594167
-sources = '''
594167
-        bootspec-fundamental.c
594167
-        efivars-fundamental.c
594167
-        string-util-fundamental.c
594167
-        sha256.c
594167
-'''.split()
594167
+        'types-fundamental.h',
594167
+)
594167
 
594167
 # for sd-boot
594167
-fundamental_source_paths = []
594167
-foreach source : sources
594167
-        fundamental_source_paths += meson.current_source_dir() / source
594167
-endforeach
594167
+fundamental_source_paths = files(
594167
+        'bootspec-fundamental.c',
594167
+        'efivars-fundamental.c',
594167
+        'sha256.c',
594167
+        'string-util-fundamental.c',
594167
+)
594167
 
594167
 # for libbasic
594167
-fundamental_sources = files(sources) + fundamental_headers
594167
+fundamental_sources = fundamental_source_paths + fundamental_headers