From b12f4612a52c4c70aa85c3543590b4ed7219c389 Mon Sep 17 00:00:00 2001 From: Romain Failliot Date: Tue, 11 Aug 2020 13:27:23 -0400 Subject: [PATCH] Add meson build system --- build-scripts/meson-postinstall.py | 15 ++++++++++++++ meson.build | 28 ++++++++++++++++++++++++++ src/etc/{diffuserc => diffuserc.py.in} | 2 +- src/meson.build | 26 ++++++++++++++++++++++++ src/usr/bin/{diffuse => diffuse.py.in} | 2 +- translations/LINGUAS | 14 +++++++++++++ translations/meson.build | 1 + 7 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 build-scripts/meson-postinstall.py create mode 100644 meson.build rename src/etc/{diffuserc => diffuserc.py.in} (74%) create mode 100644 src/meson.build rename src/usr/bin/{diffuse => diffuse.py.in} (99%) create mode 100644 translations/LINGUAS create mode 100644 translations/meson.build diff --git a/build-scripts/meson-postinstall.py b/build-scripts/meson-postinstall.py new file mode 100644 index 0000000..6999cb4 --- /dev/null +++ b/build-scripts/meson-postinstall.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import sysconfig +from compileall import compile_dir +from os import environ, path +from subprocess import call + +prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') +datadir = path.join(prefix, 'share') +destdir = environ.get('DESTDIR', '') + +# Package managers set this so we don't need to run +if not destdir: + print('Updating icon cache...') + call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')]) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..b169d87 --- /dev/null +++ b/meson.build @@ -0,0 +1,28 @@ +project('diffuse', + version: '0.6.0', + meson_version: '>= 0.50', + license: 'GPL-2.0-or-later') + +i18n = import('i18n') +python = import('python') + +py_installation = python.find_installation('python3') + +find_program('gtk-update-icon-cache', required: false) + +prefix = get_option('prefix') + +bindir = prefix / get_option('bindir') +datadir = prefix / get_option('datadir') +localedir = prefix / get_option('localedir') +libexecdir = prefix / get_option('libexecdir') +sysconfdir = prefix / get_option('sysconfdir') +pythondir = py_installation.get_path('purelib') + +pkgdatadir = join_paths(datadir, meson.project_name()) +podir = join_paths(meson.source_root(), 'translations') + +subdir('translations') +subdir('src') + +meson.add_install_script('build-scripts/meson-postinstall.py') diff --git a/src/etc/diffuserc b/src/etc/diffuserc.py.in similarity index 74% rename from src/etc/diffuserc rename to src/etc/diffuserc.py.in index c10ba74..9a2f221 100644 --- a/src/etc/diffuserc +++ b/src/etc/diffuserc.py.in @@ -2,4 +2,4 @@ # # Copyright (C) 2006-2009 Derrick Moser -import ../usr/share/diffuse/syntax/*.syntax +import @PKGDATADIR@/syntax/*.syntax diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..e30b432 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,26 @@ +# Diffuse binary file +diffuse_conf = configuration_data() +diffuse_conf.set('SYSCONFIGDIR', sysconfdir) + +configure_file( + input: 'usr/bin/diffuse.py.in', + output: 'diffuse', + configuration: diffuse_conf, + install: true, + install_dir: bindir +) + +# Diffuse config file +diffuserc_conf = configuration_data() +diffuserc_conf.set('PKGDATADIR', pkgdatadir) + +configure_file( + input: 'etc/diffuserc.py.in', + output: 'diffuserc', + configuration: diffuserc_conf, + install: true, + install_dir: sysconfdir +) + +# Data files +install_subdir('usr/share', install_dir: datadir, strip_directory: true) diff --git a/src/usr/bin/diffuse b/src/usr/bin/diffuse.py.in similarity index 99% rename from src/usr/bin/diffuse rename to src/usr/bin/diffuse.py.in index 9ed6e0c..41142fc 100755 --- a/src/usr/bin/diffuse +++ b/src/usr/bin/diffuse.py.in @@ -8345,7 +8345,7 @@ if __name__ == '__main__': if isWindows(): rc_file = os.path.join(bin_dir, 'diffuserc') else: - rc_file = os.path.join(bin_dir, '../../etc/diffuserc') + rc_file = os.path.join(bin_dir, '@SYSCONFIGDIR@/diffuserc') for rc_file in rc_file, os.path.join(rc_dir, 'diffuserc'): if os.path.isfile(rc_file): rc_files.append(rc_file) diff --git a/translations/LINGUAS b/translations/LINGUAS new file mode 100644 index 0000000..bdb3627 --- /dev/null +++ b/translations/LINGUAS @@ -0,0 +1,14 @@ +# Please keep this list sorted alphabetically +cs +de +es +it +ja +ko +pl +pt +ru +sv +th +zh_CN +zh_TW diff --git a/translations/meson.build b/translations/meson.build new file mode 100644 index 0000000..e9b77d7 --- /dev/null +++ b/translations/meson.build @@ -0,0 +1 @@ +i18n.gettext(meson.project_name(), preset: 'glib')