Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify meson build #151

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig <http://EditorConfig.org>
root = true

# elementary defaults
[*]
charset = utf-8
end_of_line = lf
indent_size = tab
indent_style = space
insert_final_newline = true
max_line_length = 80
tab_width = 4

[{*.xml,*.xml.in,*.yml}]
tab_width = 2
17 changes: 15 additions & 2 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
icon_sizes = ['16', '24', '32', '48', '64', '128']

foreach i : icon_sizes
install_data (
join_paths ('icons', i, meson.project_name () + '.svg'),
install_dir: join_paths (get_option ('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps')
)
install_data (
join_paths ('icons', i, meson.project_name () + '.svg'),
install_dir: join_paths (get_option ('datadir'), 'icons', 'hicolor', i + 'x' + i + '@2', 'apps')
)
endforeach

# Translate and install our .desktop file so the Applications Menu will see it
i18n.merge_file (
input: meson.project_name () + '.desktop.in',
Expand All @@ -19,7 +32,7 @@ i18n.merge_file (

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

install_data(
Expand All @@ -31,5 +44,5 @@ install_data(
'styles/nasc.xml',
'styles/nasc_dark.xml',
'styles/styles.rng',
install_dir: style_dir
install_dir: join_paths(get_option('datadir'), 'nasc', 'styles')
)
8 changes: 0 additions & 8 deletions icons/meson.build

This file was deleted.

125 changes: 42 additions & 83 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,116 +1,75 @@
project(
# Project name, programming language and version
project (
'com.github.parnold-x.nasc',
'vala', 'c', 'cpp',
version: '0.7.3',
default_options: ['cpp_std=c++11']
)

gettext_name = 'nasc'

# check vala compiler version
if meson.get_compiler('vala').version().version_compare('<0.28.0')
error('vala compiler version 0.28.0 or newer is required.')
# Check vala compiler version
if meson.get_compiler ('vala').version ().version_compare ('<0.28.0')
error ('vala compiler version 0.28.0 or newer is required.')
endif

pkg_data_dir = join_paths(
get_option('prefix'),
get_option('datadir'),
'nasc'
)

style_dir = join_paths(
get_option('prefix'),
get_option('datadir'),
'nasc',
'styles'
)


# Translation module
i18n = import ('i18n')

add_project_arguments(
'-DGETTEXT_PACKAGE="@0@"'.format(gettext_name),
# Project arguments
add_project_arguments (
'-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name ()),
language: ['c', 'cpp']
)

conf_data = configuration_data()
conf_data.set('DATADIR', join_paths(get_option('prefix'), get_option('datadir')))
conf_data.set('STYLEDIR', style_dir)
conf_data.set('PKGDATADIR', pkg_data_dir)
conf_data.set('GETTEXT_PACKAGE', gettext_name)
conf_data.set('RELEASE_NAME', meson.project_name())
conf_data.set('VERSION', meson.project_version())
conf_data.set('VERSION_INFO', 'Release')

config_header = configure_file(
input: 'src/config.vala.in',
output: 'config.vala',
conf_data = configuration_data ()
conf_data.set ('STYLEDIR', join_paths (get_option ('prefix'), get_option ('datadir'), 'nasc', 'styles'))

config_header = configure_file (
input: 'src/Config.vala.in',
output: 'Config.vala',
configuration: conf_data
)

# build libqalculate static library
libqalculate = subproject('libqalculate')
libqalculate_dep_static = libqalculate.get_variable('libqalculate_lib_static')

# build com.github.parnold-x.nasc binary
executable(
meson.project_name(),

'src/Calculator.vala',
'src/Controller.vala',
'src/HelpBox.vala',
'src/InputView.vala',
'src/ListFooter.vala',
'src/MainWindow.vala',
'src/Nasc.vala',
'src/NascSettings.vala',
'src/OpenBox.vala',
'src/MathBinDialog.vala',
'src/PeriodicTable.vala',
'src/ResultBoxWidget.vala',
'src/ResultLine.vala',
'src/ResultView.vala',
'src/Tutorial.vala',
# Listing dependencies
dependencies = [
dependency ('gee-0.8'),
dependency ('glib-2.0'),
dependency ('granite'),
dependency ('gtk+-3.0'),
dependency ('gtksourceview-3.0', version: '>=3.10'),
dependency ('webkit2gtk-4.0'),
#dependency ('cln'),
meson.get_compiler ('vala').find_library ('posix'),
meson.get_compiler ('vala').find_library ('QalculateNasc', dirs: [join_paths (meson.current_source_dir (), 'vapi')])
]

# Build libqalculate static library
libqalculate = subproject ('libqalculate')
libqalculate_dep_static = libqalculate.get_variable ('libqalculate_lib_static')

subdir('src')

# Build com.github.parnold-x.nasc binary
executable (
meson.project_name (),

sources,

config_header,

libqalculate.get_variable('definition_resource'),

include_directories: [
include_directories('subprojects/libqalculate/libqalculate')
],

dependencies: [
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('granite'),
dependency('gtk+-3.0'),
dependency('gtksourceview-3.0', version: '>=3.10'),
dependency('webkit2gtk-4.0'),
#dependency('cln'),
meson.get_compiler('vala').find_library('posix'),
meson.get_compiler('vala').find_library('QalculateNasc', dirs: [join_paths(meson.current_source_dir(), 'vapi')])
],
dependencies: dependencies,

link_with: libqalculate_dep_static,

install: true
)

# set up post-install script

python3 = find_program('python3')

schemadir = join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')
iconsdir = join_paths(get_option('prefix'), get_option('datadir'), 'icons')

meson.add_install_script(
python3.path(),
join_paths(meson.current_source_dir(), 'meson', 'post_install.py'),
'--schemadir', schemadir,
'--iconsdir', iconsdir,
)

subdir('data')
subdir('icons')
subdir('po')

meson.add_install_script ('meson/post_install.py')
32 changes: 14 additions & 18 deletions meson/post_install.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import argparse
import os
import subprocess

parser = argparse.ArgumentParser()
parser.add_argument("--schemadir", action="store", required=True)
parser.add_argument("--iconsdir", action="store", required=True)

args = vars(parser.parse_args())
#!/usr/bin/env python3

schemadir = args["schemadir"]
iconsdir = args["iconsdir"]

hicolordir = os.path.join(iconsdir, 'hicolor')
from os import path, environ
import subprocess

if not os.environ.get('DESTDIR'):
print('Compiling gsettings schemas ...')
subprocess.run(['glib-compile-schemas', schemadir])
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')

print('Compiling icon cache ...')
subprocess.run(['gtk-update-icon-cache', hicolordir])
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')])
3 changes: 3 additions & 0 deletions src/Config.vala.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Constants {
public const string STYLEDIR = "@STYLEDIR@";
}
9 changes: 0 additions & 9 deletions src/Nasc.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ namespace Nasc {

construct {
program_name = "NaSC";
exec_name = "nasc";

build_data_dir = Constants.DATADIR;
build_pkg_data_dir = Constants.PKGDATADIR;
build_release_name = Constants.RELEASE_NAME;
build_version = Constants.VERSION;
build_version_info = Constants.VERSION_INFO;

app_launcher = "com.github.parnold-x.nasc.desktop";
application_id = "com.github.parnold-x.nasc";
}

Expand Down
9 changes: 0 additions & 9 deletions src/config.vala.in

This file was deleted.

18 changes: 18 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Listing files to compile
sources = files (
'Calculator.vala',
'Controller.vala',
'HelpBox.vala',
'InputView.vala',
'ListFooter.vala',
'MainWindow.vala',
'MathBinDialog.vala',
'Nasc.vala',
'NascSettings.vala',
'OpenBox.vala',
'PeriodicTable.vala',
'ResultBoxWidget.vala',
'ResultLine.vala',
'ResultView.vala',
'Tutorial.vala'
)