summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIñigo Martínez <inigomartinez@gmail.com>2021-07-26 23:12:36 +0200
committerIñigo Martínez <inigomartinez@gmail.com>2021-07-26 23:20:39 +0200
commit5510ee96105e776d7dfb239f5166a8ff6517228d (patch)
tree247b803af335e119e859b1d82862b5f1879cd00f
parentc592eb0772b2824e101ce8368428e2ada98c4752 (diff)
build,meson: make bash-completion file install optional
`qmicli` provides a bash-completion file. To install this file `bash-completion`'s pkg-file is checked to set the proper installation directory. This has been made optional.
-rw-r--r--meson.build17
-rw-r--r--meson_options.txt2
-rw-r--r--meson_post_install.py9
-rw-r--r--src/qmicli/meson.build10
4 files changed, 30 insertions, 8 deletions
diff --git a/meson.build b/meson.build
index 90d5989..6921b20 100644
--- a/meson.build
+++ b/meson.build
@@ -155,7 +155,15 @@ enable_udev = get_option('udev')
gudev_dep = dependency('gudev-1.0', version: '>= 232', required: enable_udev and enable_firmware_update)
config_h.set('WITH_UDEV', gudev_dep.found())
-bash_completion_completionsdir = dependency('bash-completion').get_pkgconfig_variable('completionsdir', define_variable: ['datadir', qmi_datadir])
+enable_bash_completion = get_option('bash_completion')
+if enable_bash_completion
+ bash_completion_dep = dependency('bash-completion')
+ bash_completion_completionsdir = bash_completion_dep.get_pkgconfig_variable(
+ 'completionsdir',
+ # bash-completion 2.10 changed the substitutions
+ define_variable: bash_completion_dep.version().version_compare('>= 2.10') ? ['datadir', qmi_datadir] : ['prefix', qmi_prefix],
+ )
+endif
# rmnet link management support
enable_rmnet = false
@@ -237,11 +245,18 @@ configure_file(
configuration: config_h,
)
+meson.add_install_script(
+ 'meson_post_install.py',
+ get_option('bindir'),
+ enable_bash_completion ? bash_completion_completionsdir : '',
+)
+
output = '\n' + meson.project_name() + ' ' + meson.project_version() + '\n\n'
output += ' Build\n'
output += ' compiler: ' + cc.get_id() + '\n'
output += ' cflags: ' + ' '.join(cc_flags) + '\n'
output += ' Documentation: ' + enable_gtk_doc.to_string() + '\n'
+output += ' bash completion: ' + enable_bash_completion.to_string() + '\n'
output += ' gobject introspection: ' + enable_gir.to_string() + '\n\n'
output += ' System paths\n'
output += ' prefix: ' + qmi_prefix + '\n'
diff --git a/meson_options.txt b/meson_options.txt
index 9b2494d..541cd33 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -13,3 +13,5 @@ option('udevdir', type: 'string', value: '', description: 'where udev base direc
option('introspection', type: 'boolean', value: 'true', description: 'build introspection support')
option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
+
+option('bash_completion', type: 'boolean', value: true, description: 'install bash completion files')
diff --git a/meson_post_install.py b/meson_post_install.py
index cf8e205..08349d9 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -9,6 +9,9 @@ prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
bindir = os.path.join(prefix, sys.argv[1])
subprocess.check_call(['chmod', '755', os.path.join(bindir, 'qmi-network')])
-bash_completion_completionsdir = os.path.join(prefix, sys.argv[2])
-os.rename(os.path.join(bash_completion_completionsdir, 'qmicli-completion'),
- os.path.join(bash_completion_completionsdir, 'qmicli'))
+bash_completion_completionsdir = sys.argv[2]
+if bash_completion_completionsdir:
+ if not os.path.isabs(bash_completion_completionsdir):
+ bash_completion_completionsdir = os.path.join(prefix, bash_completion_completionsdir)
+ os.rename(os.path.join(bash_completion_completionsdir, 'qmicli-completion'),
+ os.path.join(bash_completion_completionsdir, 'qmicli'))
diff --git a/src/qmicli/meson.build b/src/qmicli/meson.build
index b60bb1c..1fb6f61 100644
--- a/src/qmicli/meson.build
+++ b/src/qmicli/meson.build
@@ -49,9 +49,11 @@ qmicli = executable(
install: true,
)
-install_data(
- 'qmicli-completion',
- install_dir: bash_completion_completionsdir,
-)
+if enable_bash_completion
+ install_data(
+ 'qmicli-completion',
+ install_dir: bash_completion_completionsdir,
+ )
+endif
subdir('test')