Skip to content

Port build to meson #243

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

Open
wants to merge 1 commit 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
25 changes: 25 additions & 0 deletions data/icons/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
icon_dirs = [
'16x16',
'22x22',
'24x24',
'32x32',
'48x48',
'64x64',
'128x128',
'256x256',
]

hicolor_icondir = get_option('datadir') / 'icons' / 'hicolor'

foreach i:icon_dirs
install_data(
i / 'qalculate.png',
install_dir: hicolor_icondir / i / 'apps',
)
endforeach

install_data(
'scalable' / 'qalculate.svg',
install_dir: hicolor_icondir / 'scalable' / 'apps',
)

3 changes: 3 additions & 0 deletions data/io.github.Qalculate.SearchProvider.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[D-BUS Service]
Name=io.github.Qalculate.SearchProvider
Exec=@libexecdir@/qalculate-search-provider
60 changes: 60 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
flags_generated_sources = gnome.compile_resources(
meson.project_name() + 'flags-resources',
'flags.gresource.xml',
c_name: 'qalculate_gtk_flags',
source_dir: 'flags',
)

ui_generated_sources = gnome.compile_resources(
meson.project_name() + 'ui-resources',
'ui.gresource.xml',
c_name: 'qalculate_gtk_ui',
)

search_provider_generated_src = gnome.gdbus_codegen(
'search-provider-interface',
sources: 'org.gnome.ShellSearchProvider2.xml',
interface_prefix : 'org.gnome.Shell.',
namespace : 'Shell',
)

dbus_config = configuration_data()
dbus_config.set('libexecdir', libexecdir)

configure_file(
input: 'io.github.Qalculate.SearchProvider.service.in',
output: '@BASENAME@',
configuration: dbus_config,
install: true,
install_dir: dbusdir,
)

i18n.merge_file(
input: 'qalculate-gtk.desktop.in',
output: '@BASENAME@',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: datadir / 'applications'
)

i18n.merge_file(
input: 'qalculate-gtk.appdata.xml.in',
output: '@BASENAME@',
po_dir: '../po',
install: true,
install_dir: datadir / 'metainfo'
)

install_man(
'qalculate-gtk.1',
)

if search_provider_enabled
install_data(
'io.github.Qalculate.search-provider.ini',
install_dir: datadir / 'gnome-shell' / 'search-providers'
)
endif

subdir('icons')
12 changes: 6 additions & 6 deletions data/qalculate-gtk.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
<id>qalculate-gtk.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<_name>Qalculate! (GTK+ UI)</_name>
<_summary>Powerful and easy to use calculator</_summary>
<name>Qalculate! (GTK+ UI)</name>
<summary>Powerful and easy to use calculator</summary>
<description>
<_p>
<p>
Qalculate! is a multi-purpose cross-platform desktop calculator.
It is simple to use but provides power and versatility normally
reserved for complicated math packages, as well as useful tools for
everyday needs (such as currency conversion and percent calculation).
</_p>
<_p>
</p>
<p>
Features include a large library of customizable functions, unit
calculations and conversion, physical constants, symbolic calculations
(including integrals and equations), arbitrary precision, uncertainty
propagation, interval arithmetic, plotting, and a user-friendly interface.
</_p>
</p>
</description>
<screenshots>
<screenshot type="default">
Expand Down
8 changes: 4 additions & 4 deletions data/qalculate-gtk.desktop.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Desktop Entry]
Version=1.0
_Name=Qalculate!
_GenericName=Calculator
_Comment=Powerful and easy to use calculator
Name=Qalculate!
GenericName=Calculator
Comment=Powerful and easy to use calculator
TryExec=qalculate-gtk
Exec=qalculate-gtk
Icon=qalculate
Expand All @@ -11,4 +11,4 @@ Type=Application
StartupNotify=true
StartupWMClass=qalculate-gtk
Categories=GTK;Utility;Calculator;Science;Math;
_Keywords=calculation;arithmetic;scientific;financial;
Keywords=calculation;arithmetic;scientific;financial;
4 changes: 4 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
install_subdir(
'html',
install_dir: docdir,
)
17 changes: 17 additions & 0 deletions meson-post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

prefix="${MESON_INSTALL_PREFIX}"
datadir="${prefix}/$1"

# Distro packagers define DESTDIR and they don't
# want/need us to do the below
if [[ -z $DESTDIR ]]; then
echo "Compiling GSchema..."
glib-compile-schemas $datadir"/glib-2.0/schemas"

echo "Updating icon cache..."
gtk-update-icon-cache -f -t $datadir"/icons/hicolor"

echo "Updating desktop database..."
update-desktop-database -q $datadir"/applications"
fi
115 changes: 115 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
project(
'qalculate-gtk',
['c', 'cpp'],
version: '3.17.0',
meson_version: '>=0.50.0',
default_options: ['warning_level=2', 'c_std=c11', 'cpp_std=c++11'],

)

conf = configuration_data()
i18n = import('i18n')
gnome = import ('gnome')

glib_dep = dependency('glib-2.0', version: '>=2.4')
gobject_dep = dependency('gobject-2.0', version: '>=2.4')
gio_dep = dependency('gio-2.0', version: '>=2.4')
gtk_dep = dependency('gtk+-3.0', version: '>=3.10')
libxml_dep = dependency('libxml-2.0')
gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0')
libqalculate_dep = dependency('libqalculate', version: '>=@0@'.format(meson.project_version()))

qalculate_gtk_deps = [
glib_dep,
gobject_dep,
gio_dep,
gtk_dep,
libxml_dep,
gdk_pixbuf_dep,
libqalculate_dep,
]

if get_option('webkitgtk').enabled()
conf.set('USE_WEBKITGTK', 1)
qalculate_gtk_deps += [
dependency('webkit2gtk-4.0')
]
endif

if get_option('gnome-search').enabled()
search_provider_deps = [
dependency('gio-unix-2.0'),
glib_dep,
gtk_dep,
libqalculate_dep,
]
search_provider_enabled = true
else
search_provider_enabled = false
endif

if get_option('local-help')
conf.set('LOCAL_HELP', 1)
local_help_enabled = true
else
local_help_enabled = false
endif

gettext_package = meson.project_name()
prefix = get_option('prefix')
datadir = prefix / get_option('datadir')
dbusdir = datadir / 'dbus-1' / 'services'
docdir = datadir / 'doc' / 'qalculate-gtk'
libexecdir = prefix / get_option('libexecdir')
localedir = prefix / get_option('localedir')

conf.set_quoted(
'GETTEXT_PACKAGE',
gettext_package,
)
conf.set_quoted(
'PACKAGE_LOCALE_DIR',
localedir,
)
conf.set_quoted(
'PACKAGE_DATA_DIR',
datadir,
)
conf.set_quoted(
'PACKAGE_DOC_DIR',
docdir,
)
conf.set_quoted(
'VERSION',
meson.project_version(),
)
add_project_arguments(
'-DHAVE_CONFIG_H=1',
language: 'cpp',
)

cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.check_header('unordered_map')
conf.set('HAVE_UNORDERED_MAP', 1)
endif

configure_file(
output: 'config.h',
configuration: conf,
)

# Include the config.h we just generated
incs = include_directories('.')

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

if local_help_enabled
subdir('doc')
endif

meson.add_install_script(
'meson-post-install.sh',
get_option('datadir'),
)
20 changes: 20 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
option(
'webkitgtk',
type: 'feature',
value: 'auto',
description: 'use WebKitGTK for display of the user manual.'
)

option(
'gnome-search',
type: 'feature',
value: 'auto',
description: 'GNOME shell search provider.'
)

option(
'local-help',
type: 'boolean',
value: true,
description: 'Use local help files instead of online manual',
)
7 changes: 7 additions & 0 deletions po/LINGUAS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
es
fr
nl
pt_BR
sl
sv
zh_CN
4 changes: 4 additions & 0 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
i18n.gettext(
gettext_package,
preset: 'glib',
)
32 changes: 32 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
qalculate_gtk_src = [
'callbacks.cc',
'interface.cc',
'main.cc',
flags_generated_sources,
ui_generated_sources,
]

executable(
meson.project_name(),
qalculate_gtk_src,
dependencies: qalculate_gtk_deps,
include_directories: incs,
install: true,
link_args: '-rdynamic',
)

if search_provider_enabled
search_provider_src = [
'searchprovider.cc',
search_provider_generated_src,
]

executable(
'qalculate-search-provider',
search_provider_src,
dependencies: search_provider_deps,
include_directories: incs,
install: true,
link_args: '-rdynamic',
)
endif