etc, meson: new -Dbash-completion feature option.

Let's force having the bash-completion dependency when we want to enable
the feature. Then clearly shows the feature state in the final setup
summary.

Otherwise the risk is that GIMP may not use the correct path on a given
system and a packager who wants this script to be installed may miss
that it is installed in the wrong directory.

(cherry picked from commit 88b4f29ce7)
This commit is contained in:
Jehan 2026-01-23 23:08:52 +01:00
parent c65725d5c2
commit 5b349c7316
3 changed files with 17 additions and 13 deletions

View file

@ -21,20 +21,13 @@ install_data(
)
# Bash completion
have_bash = find_program('bash', required : false).found() # For completion scripts
bash_comp_dep = dependency('bash-completion', version: '>=2.0', required: false)
if have_bash
bash = find_program('bash', required : get_option('bash-completion'))
bash_completion = dependency('bash-completion', version: '>=2.0', required: get_option('bash-completion'))
if bash_completion.found()
bash_comp_inst_dir = ''
if bash_comp_dep.found()
bash_comp_dir_override = bash_comp_dep.version().version_compare('>= 2.10') ? ['datadir', get_option('datadir')] : ['prefix', get_option('prefix')]
bash_comp_inst_dir = bash_comp_dep.get_variable('completionsdir', pkgconfig_define: bash_comp_dir_override)
endif
if bash_comp_inst_dir == ''
message('Found bash-completion but the .pc file did not set \'completionsdir\', fallback to a predefined path')
bash_comp_inst_dir = get_option('datadir') / 'bash-completion' / 'completions'
endif
bash_comp_dir_override = bash_completion.version().version_compare('>= 2.10') ? ['datadir', get_option('datadir')] : ['prefix', get_option('prefix')]
bash_comp_inst_dir = bash_completion.get_variable('completionsdir', pkgconfig_define: bash_comp_dir_override,
default_value: get_option('datadir') / 'bash-completion' / 'completions')
bash_completion_conf = configuration_data()
bash_completion_conf.set('GIMP_MAIN_EXE', gimpmain_exe_name)
@ -50,4 +43,13 @@ if have_bash
configuration: bash_completion_conf,
install: true,
install_dir: bash_comp_inst_dir)
have_bash_completion = 'true (@0@)'.format(bash_comp_inst_dir)
elif get_option('bash-completion').disabled()
have_bash_completion = 'disabled'
else
if not bash.found()
have_bash_completion = 'false (bash not found)'
elif not bash_completion.found()
have_bash_completion = 'false (bash-completion not found)'
endif
endif

View file

@ -2192,6 +2192,7 @@ final_message = [
''' Debug symbols format: @0@'''.format(debugging_format),
''' Binary symlinks: @0@'''.format(enable_default_bin),
''' OpenMP: @0@'''.format(have_openmp),
''' Bash Completion: @0@'''.format(have_bash_completion),
'',
'''Optional Plug-Ins:''',
''' Ascii Art: @0@'''.format(libaa.found()),

View file

@ -34,6 +34,7 @@ option('win-debugging', type: 'combo', value: 'native', description: 'Buil
# Features
option('enable-default-bin',type: 'feature', value: 'auto', description: 'Install unversioned symlinks pointing to versioned executables (on UNIX) or unversioned duplicates (on Windows)')
option('bash-completion', type: 'feature', value: 'auto', description: 'Install a bash completion script')
option('aa', type: 'feature', value: 'auto', description: 'AA plugin')
option('alsa', type: 'feature', value: 'auto', description: 'Alsa support in midi input controller')
option('appdata-test', type: 'feature', value: 'auto', description: 'Validate the appdata file')