meson: inline output file names

Before 7d247d3cb8, we needed the file name
twice. But now we only need it once, so no need to overcomplicate things
by defining a variable with a single use.

When a variable is used, it's also easier to make a mistake and e.g.
accidentally reuse the variable later.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-07-25 11:37:29 +02:00
parent 92716a079f
commit 0e031d5e0b
3 changed files with 14 additions and 28 deletions

View File

@@ -129,25 +129,22 @@ foreach item : [
['errno', [], '', ['<errno.h>'], ],
]
fname = '@0@-list.txt'.format(item[0])
generate_list = files('generate-@0@-list.sh'.format(item[0]))
list_txt = custom_target(
input : [generate_list, item[1]],
output : fname,
output : '@0@-list.txt'.format(item[0]),
command : [env, 'bash', generate_list, cpp, system_include_args],
capture : true)
fname = '@0@-from-name.gperf'.format(item[0])
gperf_file = custom_target(
input : list_txt,
output : fname,
output : '@0@-from-name.gperf'.format(item[0]),
command : [generate_gperfs, item[0], item[2], '@INPUT@'] + item[3],
capture : true)
fname = '@0@-from-name.inc'.format(item[0])
target1 = custom_target(
input : gperf_file,
output : fname,
output : '@0@-from-name.inc'.format(item[0]),
command : [gperf,
'-L', 'ANSI-C', '-t', '--ignore-case',
'-N', 'lookup_@0@'.format(item[0]),
@@ -156,11 +153,10 @@ foreach item : [
'@INPUT@'],
capture : true)
fname = '@0@-to-name.inc'.format(item[0])
awkscript = '@0@-to-name.awk'.format(item[0])
target2 = custom_target(
input : [awkscript, list_txt],
output : fname,
output : '@0@-to-name.inc'.format(item[0]),
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
@@ -191,19 +187,17 @@ filesystems_gperf_h = custom_target(
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
generate_filesystem_list = find_program('generate-filesystem-list.py')
fname = 'filesystem-list.inc'
filesystem_list_inc = custom_target(
input : 'filesystems-gperf.gperf',
output : fname,
output : 'filesystem-list.inc',
command : [generate_filesystem_list,
'@INPUT@'],
capture : true)
generate_filesystem_switch_case_inc = find_program('generate-filesystem-switch-case.py')
fname = 'filesystem-switch-case.inc'
filesystem_switch_case_inc = custom_target(
input : 'filesystems-gperf.gperf',
output : fname,
output : 'filesystem-switch-case.inc',
command : [generate_filesystem_switch_case_inc,
'@INPUT@'],
capture : true)

View File

@@ -232,10 +232,9 @@ if get_option('tests') != 'false'
endif
generate_syscall_list = find_program('generate-syscall-list.py')
fname = 'syscall-list.inc'
syscall_list_inc = custom_target(
input : syscall_list_txt,
output : fname,
output : 'syscall-list.inc',
command : [generate_syscall_list,
'@INPUT@'],
capture : true)
@@ -266,17 +265,15 @@ ip_protocol_list_txt = custom_target(
command : [env, 'bash', generate_ip_protocol_list, cpp, system_include_args],
capture : true)
fname = 'ip-protocol-from-name.gperf'
gperf_file = custom_target(
input : ip_protocol_list_txt,
output : fname,
output : 'ip-protocol-from-name.gperf',
command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@', '<netinet/in.h>'],
capture : true)
fname = 'ip-protocol-from-name.inc'
target1 = custom_target(
input : gperf_file,
output : fname,
output : 'ip-protocol-from-name.inc',
command : [gperf,
'-L', 'ANSI-C', '-t', '--ignore-case',
'-N', 'lookup_ip_protocol',
@@ -285,11 +282,10 @@ target1 = custom_target(
'@INPUT@'],
capture : true)
fname = 'ip-protocol-to-name.inc'
awkscript = 'ip-protocol-to-name.awk'
target2 = custom_target(
input : [awkscript, ip_protocol_list_txt],
output : fname,
output : 'ip-protocol-to-name.inc',
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
@@ -297,10 +293,9 @@ generated_sources += [target1, target2]
shared_sources += [target1, target2]
ethtool_link_mode_py = files('ethtool-link-mode.py')
fname = 'ethtool-link-mode.inc'
ethtool_link_mode_inc = custom_target(
input : [ethtool_link_mode_py, ethtool_link_mode_sources],
output : fname,
output : 'ethtool-link-mode.inc',
command : [python, ethtool_link_mode_py, '--header', cpp, system_include_args],
capture : true)
@@ -308,10 +303,9 @@ generated_sources += ethtool_link_mode_inc
shared_sources += ethtool_link_mode_inc
sources += shared_sources
fname = 'ethtool-link-mode.xml'
ethtool_link_mode_xml = custom_target(
input : [ethtool_link_mode_py, ethtool_link_mode_sources],
output : fname,
output : 'ethtool-link-mode.xml',
command : [python, ethtool_link_mode_py, '--xml', cpp, system_include_args],
capture : true)
man_page_depends += ethtool_link_mode_xml

View File

@@ -69,17 +69,15 @@ keyboard_keys_list_txt = custom_target(
capture : true)
generate_keyboard_keys_gperf = files('generate-keyboard-keys-gperf.sh')
fname = 'keyboard-keys-from-name.gperf'
gperf_file = custom_target(
input : [generate_keyboard_keys_gperf, keyboard_keys_list_txt],
output : fname,
output : 'keyboard-keys-from-name.gperf',
command : [env, 'bash', '@INPUT@'],
capture : true)
fname = 'keyboard-keys-from-name.inc'
keyboard_keys_from_name_inc = custom_target(
input : gperf_file,
output : fname,
output : 'keyboard-keys-from-name.inc',
command : [gperf,
'-L', 'ANSI-C', '-t',
'-N', 'keyboard_lookup_key',