Skip to content

Commit

Permalink
Improve meson integration and project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBnm committed Jan 31, 2020
1 parent 89c8cbf commit 67bcd4a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 38 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ foreach i : icon_sizes
endforeach

install_data(
'gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas'),
rename: meson.project_name() + '.gschema.xml'
meson.project_name() + '.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
)

i18n.merge_file(
Expand All @@ -32,7 +31,6 @@ i18n.merge_file(
input: meson.project_name() + '.appdata.xml.in',
output: meson.project_name() + '.appdata.xml',
po_dir: join_paths(meson.source_root(), 'po', 'extra'),
type: 'xml',
install: true,
install_dir: join_paths(get_option('datadir'), 'metainfo')
)
36 changes: 29 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
project('com.github.eudaldgr.elements', 'vala', 'c')
project('com.github.eudaldgr.elements', 'vala', 'c', version: '0.0.5')

gnome = import('gnome')
i18n = import('i18n')

add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), language:'c')
add_project_arguments(
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
language: 'c'
)

asresources = gnome.compile_resources(
'as-resources', join_paths('data', 'gresource.xml'),
source_dir: 'data',
c_name: 'as'
'as-resources',
'data/' + meson.project_name() + '.gresource.xml',
source_dir: 'data',
c_name: 'as'
)

dependencies = [
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('gio-2.0'),
dependency('granite'),
dependency('gtk+-3.0'),
meson.get_compiler('c').find_library('m', required : false)
]

subdir('src')

executable(
meson.project_name(),
sources,
asresources,
dependencies: dependencies,
install: true
)

subdir('data')
subdir('po')
subdir('src')

meson.add_install_script(join_paths('meson', 'post_install.py'))
meson.add_install_script('meson/post_install.py')
16 changes: 11 additions & 5 deletions meson/post_install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/env python3

import os
from os import path, environ
import subprocess

install_prefix = os.environ['MESON_INSTALL_PREFIX']
schemadir = os.path.join(install_prefix, 'share/glib-2.0/schemas')
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
schemadir = path.join(environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas')
datadir = path.join(prefix, 'share')
desktop_database_dir = path.join(datadir, 'applications')

if not os.environ.get('DESTDIR'):
print('compiling the gsettings schemas ...')
if not environ.get('DESTDIR'):
print('Compiling gsettings schemas')
subprocess.call(['glib-compile-schemas', schemadir])
print('Updating desktop database…')
subprocess.call(['update-desktop-database', '-q', desktop_database_dir])
print('Updating icon cache…')
subprocess.call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
9 changes: 8 additions & 1 deletion po/extra/meson.build
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
i18n.gettext('extra', preset: 'glib', install: false)
i18n.gettext('extra',
args: [
'--directory=' + meson.source_root(),
'--from-code=UTF-8'
],
preset: 'glib',
install: false
)
8 changes: 7 additions & 1 deletion po/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
i18n.gettext(meson.project_name(), preset: 'glib')
i18n.gettext(meson.project_name(),
args: [
'--directory=' + meson.source_root(),
'--from-code=UTF-8'
],
preset: 'glib'
)

subdir('extra')
29 changes: 9 additions & 20 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
executable(
meson.project_name(),
join_paths('Application.vala'),
join_paths('MainWindow.vala'),
join_paths('Layouts', 'HeaderBar.vala'),
join_paths('Layouts', 'Popover.vala'),
join_paths('Layouts', 'Stack.vala'),
join_paths('Lib', 'Elements.vala'),
join_paths('Lib', 'Types.vala'),
join_paths('Views', 'Main.vala'),
asresources,
dependencies: [
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('gio-2.0'),
dependency('granite'),
dependency('gtk+-3.0'),
meson.get_compiler('c').find_library('m', required : false)
],
install: true
sources = files(
'Application.vala',
'MainWindow.vala',
'Layouts/HeaderBar.vala',
'Layouts/Popover.vala',
'Layouts/Stack.vala',
'Lib/Elements.vala',
'Lib/Types.vala',
'Views/Main.vala'
)

0 comments on commit 67bcd4a

Please sign in to comment.