Skip to content

Commit

Permalink
meson: multiple fixes
Browse files Browse the repository at this point in the history
* fix `--gnome_shell_libdir`
* add `--chrome_nmhdir`, `--chromium_nmhdir` and `--mozilla_nmhdir`
* don't clobber relative paths if DESTDIR is unset
  • Loading branch information
andyholmes committed Sep 21, 2018
1 parent dccdfa1 commit 46273a8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 18 deletions.
42 changes: 30 additions & 12 deletions meson.build
Expand Up @@ -16,22 +16,13 @@ gschemadir = join_paths(datadir, 'glib-2.0', 'schemas')
if get_option('gnome_shell_libdir') != ''
gnome_shell_libdir = get_option('gnome_shell_libdir')
else
gnome_shell_dir = libdir
endif

# Mozilla LIBDIR
if get_option('mozilla_libdir') != ''
mozilla_libdir = get_option('mozilla_libdir')
else
mozilla_dir = libdir
gnome_shell_libdir = libdir
endif

# Configuration
extconfig = configuration_data()
extconfig.set('VERSION', meson.project_version())
extconfig.set('LIBDIR', libdir)
extconfig.set('GNOME_SHELL_LIBDIR', gnome_shell_libdir)
extconfig.set('MOZILLA_LIBDIR', mozilla_libdir)
extconfig.set('LOCALEDIR', localedir)
extconfig.set('EXTDATADIR', extdatadir)
extconfig.set('GSCHEMADIR', gschemadir)
Expand Down Expand Up @@ -107,19 +98,46 @@ endif

# WebExtension Manifests
if get_option('webextension')

# Chrome
if get_option('chrome_nmhdir') != ''
chrome_nmhdir = get_option('chrome_nmhdir')
else
chrome_nmhdir = sysconfdir
endif

# Chromium
if get_option('chromium_nmhdir') != ''
chromium_nmhdir = get_option('chromium_nmhdir')
else
chromium_nmhdir = sysconfdir
endif

configure_file(
input: 'data/org.gnome.shell.extensions.gsconnect.json-chrome',
output: 'org.gnome.shell.extensions.gsconnect.json-chrome',
configuration: extconfig
)

# HACK: use 'rename' in meson >=0.46.0
meson.add_install_script('meson/nmh.sh', sysconfdir)
meson.add_install_script(
'meson/nmh.sh',
join_paths(chrome_nmhdir, 'opt', 'chrome', 'native-messaging-hosts'),
join_paths(chromium_nmhdir, 'chromium', 'native-messaging-hosts')
)

# Mozilla
if get_option('mozilla_nmhdir') != ''
mozilla_nmhdir = get_option('mozilla_nmhdir')
else
mozilla_nmhdir = libdir
endif

configure_file(
input: 'data/org.gnome.shell.extensions.gsconnect.json-mozilla',
output: 'org.gnome.shell.extensions.gsconnect.json',
configuration: extconfig,
install_dir: join_paths(mozilla_libdir, 'mozilla', 'native-messaging-hosts')
install_dir: join_paths(mozilla_nmhdir, 'mozilla', 'native-messaging-hosts')
)
endif

Expand Down
24 changes: 19 additions & 5 deletions meson/nmh.sh
@@ -1,11 +1,25 @@
#!/bin/bash

DESTDIR_SYSCONFDIR=${DESTDIR}/${1}
# Use DESTDIR if defined
if [ -n "${DESTDIR}" ]; then
CHROME_NMHDIR=${DESTDIR}/${1}
else
CHROME_NMHDIR=${1}
fi

mkdir -p ${DESTDIR_SYSCONFDIR}/opt/chrome/native-messaging-hosts/
mkdir -p ${CHROME_NMHDIR}
cp ${MESON_BUILD_ROOT}/org.gnome.shell.extensions.gsconnect.json-chrome \
${DESTDIR_SYSCONFDIR}/opt/chrome/native-messaging-hosts/org.gnome.shell.extensions.gsconnect.json
${CHROME_NMHDIR}/org.gnome.shell.extensions.gsconnect.json

mkdir -p ${DESTDIR_SYSCONFDIR}/chromium/native-messaging-hosts/

# Use DESTDIR if defined
if [ -n "${DESTDIR}" ]; then
CHROMIUM_NMHDIR=${DESTDIR}/${2}
else
CHROME_NMHDIR=${2}

This comment has been minimized.

Copy link
@jtojnar

jtojnar Sep 22, 2018

Contributor

This should be CHROMIUM_NMHDIR.

fi

mkdir -p ${CHROMIUM_NMHDIR}/chromium/native-messaging-hosts

This comment has been minimized.

Copy link
@jtojnar

jtojnar Sep 22, 2018

Contributor

This should not contain chromium/native-messaging-hosts

cp ${MESON_BUILD_ROOT}/org.gnome.shell.extensions.gsconnect.json-chrome \
${DESTDIR_SYSCONFDIR}/chromium/native-messaging-hosts/org.gnome.shell.extensions.gsconnect.json
${CHROMIUM_NMHDIR}/org.gnome.shell.extensions.gsconnect.json

9 changes: 8 additions & 1 deletion meson_options.txt
@@ -1,5 +1,12 @@
# See https://github.com/andyholmes/gnome-shell-extension-gsconnect/wiki/Packaging

option('gnome_shell_libdir', type: 'string', value: '', description: 'LIBDIR for Gnome Shell')
option('mozilla_libdir', type: 'string', value: '', description: 'LIBDIR for Mozilla')

option('session_bus_services_dir', type: 'string', value: '', description: 'DBus session services directory')
option('nautilus', type: 'boolean', value: true, description: 'enable nautilus-python extension')

option('webextension', type: 'boolean', value: true, description: 'enable WebExtension for Chrome/Firefox')
option('chrome_nmhdir', type: 'string', value: '', description: 'Native Messaging Host directory for Chrome')
option('chromium_nmhdir', type: 'string', value: '', description: 'Native Messaging Host directory for Chromium')
option('mozilla_nmhdir', type: 'string', value: '', description: 'Native Messaging Host directory for Mozilla')

0 comments on commit 46273a8

Please sign in to comment.