toolbox/completion/meson.build
Ondřej Míchal bafbbe81c9 Generate & install completion scripts in build system
The previous commit added a means to generating the completion scripts
and this one plugs that into the build system.

A new build option 'install_completions' has been introduced. Set to
'True' by default.

Completions for bash and fish use pkg-config for getting the preferred
install locations for the completions. If the packages are not
available, fallbacks are in-place.

The 'completion' subdir has been kept to work around the ideology of
Meson that does not allow creating/outputing files in subdirectories nor
using the output of custom_target() in install_data().

https://github.com/containers/toolbox/pull/840
2022-02-21 15:15:30 +02:00

36 lines
1.3 KiB
Meson

generate_completions_program = find_program('generate_completions.py')
if bash_completion.found()
bash_comp_dir = bash_completion.get_pkgconfig_variable('completionsdir')
else
bash_comp_dir = get_option('datadir') / 'bash-completion' / 'completions'
message('bash-completion not found: using', get_option('prefix') / bash_comp_dir, 'as a falback install directory')
endif
if fish.found()
fish_comp_dir = fish.get_pkgconfig_variable('completionsdir')
else
fish_comp_dir = get_option('datadir') / 'fish' / 'completions'
message('fish not found: using', get_option('prefix') / fish_comp_dir, 'as a fallback install directory')
endif
completion_bash = custom_target('bash-completion',
capture: true,
command: [generate_completions_program, meson.global_source_root() / 'src', 'bash'],
install: true,
install_dir: bash_comp_dir,
output: 'toolbox')
completion_zsh = custom_target('zsh-completion',
capture: true,
command: [generate_completions_program, meson.global_source_root() / 'src', 'zsh'],
install: true,
install_dir: get_option('datadir') / 'zsh' / 'site_functions',
output: '_toolbox')
completion_fish = custom_target('fish-completion',
capture: true,
command: [generate_completions_program, meson.global_source_root() / 'src', 'fish'],
install: true,
install_dir: fish_comp_dir,
output: 'toolbox.fish')