From 5b349c7316e968fc3e78a64a39ea92cb1b275e8e Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 23 Jan 2026 23:08:52 +0100 Subject: [PATCH] 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 88b4f29ce7f6a47f269bafb86b39bc8f6324fcc8) --- etc/meson.build | 28 +++++++++++++++------------- meson.build | 1 + meson_options.txt | 1 + 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/etc/meson.build b/etc/meson.build index a1a0bd8538..93ec8ce9e2 100644 --- a/etc/meson.build +++ b/etc/meson.build @@ -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 diff --git a/meson.build b/meson.build index 1a6d508f7a..87f7c8a1b9 100644 --- a/meson.build +++ b/meson.build @@ -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()), diff --git a/meson_options.txt b/meson_options.txt index c68081bef5..d995b83eaf 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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')