summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWu Xiaotian <[email protected]>2019-05-11 00:42:21 +0800
committerraveit65 <[email protected]>2019-05-21 09:16:57 +0200
commitd98d60a74976e544c2a844f41dd00db9d9ac999a (patch)
tree8de0408116be4acb09c0769132c25c4c2c71aac2
parent2beed2049f2822066eb2c571aa289f7a2a9f2dc5 (diff)
downloadmozo-d98d60a74976e544c2a844f41dd00db9d9ac999a.tar.bz2
mozo-d98d60a74976e544c2a844f41dd00db9d9ac999a.tar.xz
use meson to build
-rw-r--r--Mozo/meson.build27
-rw-r--r--data/icons/meson.build19
-rw-r--r--data/meson.build21
-rw-r--r--meson.build34
-rw-r--r--po/meson.build1
-rw-r--r--post_install.py30
6 files changed, 132 insertions, 0 deletions
diff --git a/Mozo/meson.build b/Mozo/meson.build
new file mode 100644
index 0000000..6dbd12e
--- /dev/null
+++ b/Mozo/meson.build
@@ -0,0 +1,27 @@
+config_py = configuration_data()
+config_py.set('prefix', prefix)
+config_py.set('datadir', datadir)
+config_py.set('pkgdatadir', join_paths(datadir, meson.project_name()))
+config_py.set('PACKAGE', meson.project_name())
+config_py.set('VERSION', meson.project_version())
+config_py.set('GETTEXT_PACKAGE', meson.project_name())
+
+config = configure_file(
+ input: 'config.py.in',
+ output: 'config.py',
+ configuration: config_py,
+ )
+
+mozo_sources = [
+ config,
+ '__init__.py',
+ 'MainWindow.py',
+ 'MenuEditor.py',
+ 'util.py',
+]
+
+py_inst = python.find_installation('python3')
+py_inst.install_sources(mozo_sources,
+ pure: true,
+ subdir: 'Mozo'
+ )
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..412ef9a
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,19 @@
+icon_files = {
+ '16x16': 'hicolor_apps_16x16_mozo.png',
+ '22x22': 'hicolor_apps_22x22_mozo.png',
+ '24x24': 'hicolor_apps_24x24_mozo.png',
+ '32x32': 'hicolor_apps_32x32_mozo.png',
+ '48x48': 'hicolor_apps_48x48_mozo.png',
+ '256x256': 'hicolor_apps_256x256_mozo.png',
+}
+
+icondir = join_paths(datadir, 'icons', 'hicolor')
+
+# Remember to call gtk-update-icon-cache when installing / uninstalling.
+foreach size, file : icon_files
+ install_data(file,
+ install_dir: join_paths(icondir, size, 'apps'),
+ rename: '@[email protected]'.format(meson.project_name()),
+ )
+endforeach
+
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..f471366
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,21 @@
+subdir('icons')
+
+desktop_in = configuration_data()
+desktop_in.set('VERSION', meson.project_version())
+
+desktop_file = 'mozo.desktop'
+i18n.merge_file(desktop_file,
+ input: configure_file(
+ input: desktop_file + '.in.in',
+ output: desktop_file + '.in',
+ configuration : desktop_in,
+ ),
+ output: desktop_file,
+ po_dir: join_paths(meson.source_root(), 'po'),
+ type: 'desktop',
+ install: true,
+ install_dir : join_paths(datadir, 'applications')
+ )
+
+install_man('mozo.1')
+install_data('mozo.ui', install_dir: join_paths(datadir, meson.project_name()))
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..b162c15
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,34 @@
+project('mozo',
+ version : '1.23.0',
+ meson_version: '>= 0.47.0'
+ )
+
+i18n = import('i18n')
+python = import('python')
+py3 = find_program('python3', required:true)
+
+dependency('libmate-menu', version: '>= 1.21.0')
+dependency('pygobject-3.0')
+
+prefix = get_option('prefix')
+datadir = join_paths(prefix, get_option('datadir'))
+
+mozo_in = configuration_data()
+mozo_in.set('PYTHON', py3.path())
+mozo_in.set('PYOPTIONS', '-OOt')
+
+mozo = configure_file(input: 'mozo.in',
+ output: 'mozo',
+ configuration: mozo_in,
+ )
+
+install_data(mozo,
+ install_mode: 'rwxr-xr-x',
+ install_dir: get_option('bindir')
+ )
+
+subdir('po')
+subdir('Mozo')
+subdir('data')
+
+meson.add_install_script('post_install.py')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..7f6dab8
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(meson.project_name(), preset: 'glib',)
diff --git a/post_install.py b/post_install.py
new file mode 100644
index 0000000..c9f4d9e
--- /dev/null
+++ b/post_install.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+
+import os
+import glob
+import subprocess
+import sysconfig
+from compileall import compile_dir
+
+prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = os.path.join(prefix, 'share')
+destdir = os.environ.get('DESTDIR', '')
+
+if __name__=="__main__":
+ print('Compiling python bytecode...')
+ puredir = sysconfig.get_path('purelib', vars={'base': str(prefix)})
+ module_dir = os.path.join(destdir + os.path.join(puredir, 'Mozo'))
+ compile_dir(module_dir, optimize=2)
+
+ if destdir == '':
+ print('Updating icon cache...')
+ icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
+ if not os.path.exists(icon_cache_dir):
+ os.makedirs(icon_cache_dir)
+ subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
+
+ print('Updating desktop database...')
+ desktop_database_dir = os.path.join(datadir, 'applications')
+ if not os.path.exists(desktop_database_dir):
+ os.makedirs(desktop_database_dir)
+ subprocess.call(['update-desktop-database', '-q', desktop_database_dir])