meson: Use files() for source lists for boot and fundamental

This fixes build reproducibility as otherwise the full path
of the source files ends up in the output binary.
This commit is contained in:
Jan Janssen 2022-01-07 21:55:50 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent f2d323a3ab
commit b3c5a7074c
2 changed files with 26 additions and 25 deletions

View file

@ -312,9 +312,10 @@ efi_headers = files(
'shim.h', 'shim.h',
'splash.h', 'splash.h',
'util.h', 'util.h',
'xbootldr.h') 'xbootldr.h',
)
common_sources = [ common_sources = files(
'assert.c', 'assert.c',
'devicetree.c', 'devicetree.c',
'disk.c', 'disk.c',
@ -322,31 +323,34 @@ common_sources = [
'measure.c', 'measure.c',
'pe.c', 'pe.c',
'secure-boot.c', 'secure-boot.c',
'util.c'] 'util.c',
)
systemd_boot_sources = [ systemd_boot_sources = files(
'boot.c', 'boot.c',
'console.c', 'console.c',
'drivers.c', 'drivers.c',
'random-seed.c', 'random-seed.c',
'shim.c', 'shim.c',
'xbootldr.c'] 'xbootldr.c',
)
stub_sources = [ stub_sources = files(
'cpio.c', 'cpio.c',
'initrd.c', 'initrd.c',
'splash.c', 'splash.c',
'stub.c'] 'stub.c',
)
if efi_arch[1] in ['ia32', 'x86_64'] if efi_arch[1] in ['ia32', 'x86_64']
stub_sources += 'linux_x86.c' stub_sources += files('linux_x86.c')
else else
stub_sources += 'linux.c' stub_sources += files('linux.c')
endif endif
# BCD parser only makes sense on arches that Windows supports. # BCD parser only makes sense on arches that Windows supports.
if efi_arch[1] in ['ia32', 'x86_64', 'arm', 'aarch64'] if efi_arch[1] in ['ia32', 'x86_64', 'arm', 'aarch64']
systemd_boot_sources += 'bcd.c' systemd_boot_sources += files('bcd.c')
tests += [ tests += [
[['src/boot/efi/test-bcd.c'], [['src/boot/efi/test-bcd.c'],
[], [],
@ -362,9 +366,10 @@ endif
systemd_boot_objects = [] systemd_boot_objects = []
stub_objects = [] stub_objects = []
foreach file : fundamental_source_paths + common_sources + systemd_boot_sources + stub_sources foreach file : fundamental_source_paths + common_sources + systemd_boot_sources + stub_sources
o_file = custom_target(file.split('/')[-1] + '.o', # FIXME: replace ''.format(file) with fs.name(file) when meson_version requirement is >= 0.59.0
o_file = custom_target('@0@.o'.format(file).split('/')[-1],
input : file, input : file,
output : file.split('/')[-1] + '.o', output : '@0@.o'.format(file).split('/')[-1],
command : [cc.cmd_array(), '-c', '@INPUT@', '-o', '@OUTPUT@', efi_cflags], command : [cc.cmd_array(), '-c', '@INPUT@', '-o', '@OUTPUT@', efi_cflags],
depend_files : efi_headers + fundamental_headers) depend_files : efi_headers + fundamental_headers)
if (fundamental_source_paths + common_sources + systemd_boot_sources).contains(file) if (fundamental_source_paths + common_sources + systemd_boot_sources).contains(file)

View file

@ -8,20 +8,16 @@ fundamental_headers = files(
'macro-fundamental.h', 'macro-fundamental.h',
'sha256.h', 'sha256.h',
'string-util-fundamental.h', 'string-util-fundamental.h',
'types-fundamental.h') 'types-fundamental.h',
)
sources = '''
bootspec-fundamental.c
efivars-fundamental.c
string-util-fundamental.c
sha256.c
'''.split()
# for sd-boot # for sd-boot
fundamental_source_paths = [] fundamental_source_paths = files(
foreach source : sources 'bootspec-fundamental.c',
fundamental_source_paths += meson.current_source_dir() / source 'efivars-fundamental.c',
endforeach 'sha256.c',
'string-util-fundamental.c',
)
# for libbasic # for libbasic
fundamental_sources = files(sources) + fundamental_headers fundamental_sources = fundamental_source_paths + fundamental_headers