mirror of
https://review.coreboot.org/flashrom.git
synced 2025-08-15 19:40:19 +02:00
util: add bash completion script
Add a bash script for the flashrom CLI that auto-completes the command sequence. The script is generated from a template by substituting a list of enabled programmers. It requires an extra `bash-completion` package to work, but, fortunately, it's installed on most systems. Build system changes: meson: provide option `bash_completion` to determine if the script should be installed (depends on option `classic_cli`). makefile: make a list of enabled programmers (by using CONFIG_* variables) to do substitution manually Change-Id: Ie68bc91c3cea4de2ffdbeffd07e48edd8d5590e1 Signed-off-by: Alexander Goncharov <chat@joursoir.net> Reviewed-on: https://review.coreboot.org/c/flashrom/+/68247 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:

committed by
Anastasia Klimchuk

parent
87531ef11c
commit
58888f78f3
35
meson.build
35
meson.build
@@ -630,6 +630,41 @@ if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool
|
||||
subdir('util/ich_descriptors_tool')
|
||||
endif
|
||||
|
||||
if get_option('bash_completion').auto() or get_option('bash_completion').enabled()
|
||||
if get_option('classic_cli').disabled()
|
||||
if get_option('bash_completion').enabled()
|
||||
error('`bash_completion` can not be enabled without `classic_cli`')
|
||||
endif
|
||||
else
|
||||
bash_comp = dependency('bash-completion', required : false)
|
||||
if bash_comp.found()
|
||||
bash_comp_install_dir = bash_comp.get_variable(
|
||||
pkgconfig : 'completionsdir',
|
||||
pkgconfig_define : ['datadir', get_option('datadir')]
|
||||
)
|
||||
else
|
||||
bash_comp_install_dir = join_paths(get_option('datadir'), 'bash-completion', 'completions')
|
||||
endif
|
||||
|
||||
programmer_names_active_str = ''
|
||||
foreach p_name, p_data : programmer
|
||||
if p_data.get('active')
|
||||
programmer_names_active_str += p_name + ' '
|
||||
endif
|
||||
endforeach
|
||||
|
||||
configure_file(
|
||||
input : 'util/flashrom.bash-completion.tmpl',
|
||||
output : 'flashrom.bash',
|
||||
configuration : {
|
||||
'PROGRAMMERS' : programmer_names_active_str,
|
||||
},
|
||||
install: true,
|
||||
install_dir: bash_comp_install_dir,
|
||||
)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Use `.auto() or .enabled()` instead of `.allowed()` to keep the minimum meson version as low as possible.
|
||||
# `.allowed()` gets introduced in 0.59.0
|
||||
if get_option('tests').auto() or get_option('tests').enabled()
|
||||
|
Reference in New Issue
Block a user