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

Improve meson build #16

Open
wants to merge 2 commits into
base: main
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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# EditorConfig <https://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

# Markup files
[{*.html,*.xml,*.xml.in,*.yml}]
tab_width = 2
tab_width = 2
File renamed without changes.
43 changes: 23 additions & 20 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
# Install icons
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, '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')
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

i18n.merge_file(
input: meson.project_name() + '.desktop.in',
output: meson.project_name() + '.desktop',
po_dir: join_paths(meson.source_root(), 'po', 'extra'),
# Translate and install our .desktop file so the Applications Menu will see it
i18n.merge_file (
input: meson.project_name () + '.desktop.in',
output: meson.project_name () + '.desktop',
po_dir: join_paths (meson.source_root (), 'po', 'extra'),
type: 'desktop',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
install_dir: join_paths (get_option ('datadir'), 'applications')
)

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'),
# Translate and install our .appdata.xml file so AppCenter will see it
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'),
install: true,
install_dir: join_paths(get_option('datadir'), 'metainfo')
install_dir: join_paths (get_option ('datadir'), 'metainfo')
)

install_data(
meson.project_name() + '.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
# Install gschema
install_data (
meson.project_name () + '.gschema.xml',
install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas')
)
52 changes: 38 additions & 14 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
project('com.manexim.codecard', 'vala', 'c', version: '1.1.0')
# Project name, programming language and version
project (
'com.manexim.codecard',
'c', 'vala',
version: '1.1.0'
)

# Include the translations module
i18n = import('i18n')
# Translation module
i18n = import ('i18n')

# Set our translation domain
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c')
# Project arguments
add_project_arguments (
'-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name ()),
language: 'c'
)

gtk_plus_3_dep = dependency('gtk+-3.0')
granite_dep = dependency('granite')
gtksourceview_dep = dependency('gtksourceview-4')
libhandy_dep = dependency('libhandy-1', version: '>=1.0.0')
config_data = configuration_data ()
config_data.set('APP_ID', meson.project_name ())
config_data.set('APP_VERSION', meson.project_version ())

config_file = configure_file (
input: 'src/Constants.vala.in',
output: '@BASENAME@',
configuration: config_data
)

# Listing dependencies
dependencies = [
gtk_plus_3_dep,
granite_dep,
gtksourceview_dep,
libhandy_dep,
dependency ('gtk+-3.0'),
dependency ('granite'),
dependency('gtksourceview-4'),
dependency ('libhandy-1')
]

subdir('src')
subdir ('src')

# Defining executable
executable (
meson.project_name (),
sources,
config_file,
dependencies: dependencies,
install: true
)

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

Expand Down
27 changes: 12 additions & 15 deletions meson/post_install.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#!/usr/bin/env python3
import os
import subprocess

prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr')
datadir = os.path.join(prefix, 'share')

# Packaging tools define DESTDIR and this isn't needed for them
if 'DESTDIR' not in os.environ:
print('Compiling gsettings schemas...')
schema_dir = os.path.join(datadir, 'glib-2.0/schemas')
subprocess.call(['glib-compile-schemas', schema_dir])
from os import path, environ
import subprocess

print('Updating icon cache...')
icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = path.join(prefix, 'share')
schemadir = path.join(datadir, 'glib-2.0', 'schemas')
desktop_database_dir = path.join(datadir, 'applications')

print('Updating desktop database...')
desktop_database_dir = os.path.join(datadir, 'applications')
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')])
6 changes: 0 additions & 6 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
src/Config/Constants.vala
src/Controllers/CodecardController.vala
src/Models/Codecard.vala
src/Services/Settings.vala
src/Views/CodecardView.vala
src/Application.vala
src/MainWindow.vala
55 changes: 55 additions & 0 deletions po/com.manexim.codecard.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the com.manexim.codecard package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: com.manexim.codecard\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-21 19:53+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: src/MainWindow.vala:105
msgid "Save"
msgstr ""

#: src/MainWindow.vala:112
msgid "Language"
msgstr ""

#: src/MainWindow.vala:132
msgid "Zoom out"
msgstr ""

#: src/MainWindow.vala:140
msgid "Default zoom level"
msgstr ""

#: src/MainWindow.vala:152
msgid "Zoom in"
msgstr ""

#: src/MainWindow.vala:179
msgid "Menu"
msgstr ""

#: src/MainWindow.vala:316
#, c-format
msgid "Saved to %s and copied to clipboard"
msgstr ""

#: src/MainWindow.vala:369
msgid "Could not capture screenshot"
msgstr ""

#: src/MainWindow.vala:370
msgid "Codecard not saved"
msgstr ""
2 changes: 1 addition & 1 deletion po/extra/POTFILES
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
data/com.manexim.codecard.appdata.xml.in
data/com.manexim.codecard.desktop.in
data/com.manexim.codecard.appdata.xml.in
83 changes: 83 additions & 0 deletions po/extra/extra.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the extra package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: extra\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-21 19:53+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: data/com.manexim.codecard.desktop.in:4
#: data/com.manexim.codecard.desktop.in:5
#: data/com.manexim.codecard.appdata.xml.in:7
msgid "Codecard"
msgstr ""

#: data/com.manexim.codecard.desktop.in:6
#: data/com.manexim.codecard.appdata.xml.in:8
#: data/com.manexim.codecard.appdata.xml.in:10
msgid "Share snippets of code as a pretty image, e.g. for social media."
msgstr ""

#: data/com.manexim.codecard.desktop.in:8
msgid "com.manexim.codecard"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:21
#: data/com.manexim.codecard.appdata.xml.in:40
#: data/com.manexim.codecard.appdata.xml.in:57
msgid "New:"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:23
msgid "Use notification instead of toast to notify user"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:24
msgid "Use monospace font"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:26
#: data/com.manexim.codecard.appdata.xml.in:43
#: data/com.manexim.codecard.appdata.xml.in:60
msgid "Improved:"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:29
#: data/com.manexim.codecard.appdata.xml.in:46
#: data/com.manexim.codecard.appdata.xml.in:63
msgid "Fixed:"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:31
#: data/com.manexim.codecard.appdata.xml.in:48
msgid "Add stripe key"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:33
#: data/com.manexim.codecard.appdata.xml.in:50
#: data/com.manexim.codecard.appdata.xml.in:67
msgid "Translations:"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:65
msgid "Fix for autosave"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:74
msgid "Initial release"
msgstr ""

#: data/com.manexim.codecard.appdata.xml.in:96
msgid "Manexim"
msgstr ""
14 changes: 7 additions & 7 deletions po/extra/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
i18n.gettext('extra',
args: [
'--directory=' + meson.source_root(),
'--from-code=UTF-8'
],
preset: 'glib',
install: false
# Install metadata translations
i18n.gettext ('extra',
args: [
'--directory=' + meson.source_root (),
'--from-code=UTF-8'
],
install: false
)
15 changes: 9 additions & 6 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
i18n.gettext(meson.project_name(),
args: [
'--directory=' + meson.source_root(),
'--from-code=UTF-8'
]
# Install main translations
i18n.gettext (meson.project_name (),
args: [
'--directory=' + meson.source_root (),
'--from-code=UTF-8',
'-cTRANSLATORS'
],
preset: 'glib'
)

subdir('extra')
subdir ('extra')
2 changes: 1 addition & 1 deletion src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Utils {
public string replace_home_with_tilde (string path) {
var home_dir = Environment.get_home_dir ();
if (path.has_prefix (home_dir)) {
return "~" + path[home_dir.length:];
return "~" + path;
} else {
return path;
}
Expand Down
Loading