diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..cb5e11d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# EditorConfig +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 diff --git a/icons/128/com.github.parnold-x.nasc.svg b/data/icons/128/com.github.parnold-x.nasc.svg similarity index 100% rename from icons/128/com.github.parnold-x.nasc.svg rename to data/icons/128/com.github.parnold-x.nasc.svg diff --git a/icons/16/com.github.parnold-x.nasc.svg b/data/icons/16/com.github.parnold-x.nasc.svg similarity index 100% rename from icons/16/com.github.parnold-x.nasc.svg rename to data/icons/16/com.github.parnold-x.nasc.svg diff --git a/icons/24/com.github.parnold-x.nasc.svg b/data/icons/24/com.github.parnold-x.nasc.svg similarity index 100% rename from icons/24/com.github.parnold-x.nasc.svg rename to data/icons/24/com.github.parnold-x.nasc.svg diff --git a/icons/32/com.github.parnold-x.nasc.svg b/data/icons/32/com.github.parnold-x.nasc.svg similarity index 100% rename from icons/32/com.github.parnold-x.nasc.svg rename to data/icons/32/com.github.parnold-x.nasc.svg diff --git a/icons/48/com.github.parnold-x.nasc.svg b/data/icons/48/com.github.parnold-x.nasc.svg similarity index 100% rename from icons/48/com.github.parnold-x.nasc.svg rename to data/icons/48/com.github.parnold-x.nasc.svg diff --git a/icons/64/com.github.parnold-x.nasc.svg b/data/icons/64/com.github.parnold-x.nasc.svg similarity index 100% rename from icons/64/com.github.parnold-x.nasc.svg rename to data/icons/64/com.github.parnold-x.nasc.svg diff --git a/data/meson.build b/data/meson.build index b43a297..c3bfc99 100644 --- a/data/meson.build +++ b/data/meson.build @@ -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', @@ -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( @@ -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') ) diff --git a/icons/meson.build b/icons/meson.build deleted file mode 100644 index b6e6ae1..0000000 --- a/icons/meson.build +++ /dev/null @@ -1,8 +0,0 @@ -sizes = ['16', '24', '32', '48', '64', '128'] - -foreach size : sizes - install_data( - join_paths(size, meson.project_name() + '.svg'), - install_dir: join_paths(iconsdir, 'hicolor', size + 'x' + size, 'apps') - ) -endforeach \ No newline at end of file diff --git a/meson.build b/meson.build index dbdc17a..05d4910 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/meson/post_install.py b/meson/post_install.py index 9a54350..bf02d96 100644 --- a/meson/post_install.py +++ b/meson/post_install.py @@ -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')]) \ No newline at end of file diff --git a/src/Config.vala.in b/src/Config.vala.in new file mode 100755 index 0000000..9e48798 --- /dev/null +++ b/src/Config.vala.in @@ -0,0 +1,3 @@ +namespace Constants { + public const string STYLEDIR = "@STYLEDIR@"; +} diff --git a/src/Nasc.vala b/src/Nasc.vala index 702d4cb..86f60fa 100755 --- a/src/Nasc.vala +++ b/src/Nasc.vala @@ -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"; } diff --git a/src/config.vala.in b/src/config.vala.in deleted file mode 100755 index 66fb891..0000000 --- a/src/config.vala.in +++ /dev/null @@ -1,9 +0,0 @@ -namespace Constants { - public const string DATADIR = "@DATADIR@"; - public const string STYLEDIR = "@STYLEDIR@"; - public const string PKGDATADIR = "@PKGDATADIR@"; - public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; - public const string RELEASE_NAME = "@RELEASE_NAME@"; - public const string VERSION = "@VERSION@"; - public const string VERSION_INFO = "@VERSION_INFO@"; -} diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..f653138 --- /dev/null +++ b/src/meson.build @@ -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' +)