-
Notifications
You must be signed in to change notification settings - Fork 2
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 #31
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<img align="left" width="64" height="64" src="https://raw.githubusercontent.com/starfish-app/starfish/main/data/icons/64.svg"> | ||
<img align="left" width="64" height="64" src="https://raw.githubusercontent.com/starfish-app/starfish/main/data/icons/64/hr.from.josipantolis.starfish.svg"> | ||
<h1>Starfish</h1> | ||
|
||
A [Gemini](https://gemini.circumlunar.space/) browser made for [elementary OS](https://elementary.io/). | ||
|
@@ -89,7 +89,7 @@ flatpak run hr.from.josipantolis.starfish | |
|
||
## License | ||
|
||
[GNU GPLv3](COPYING) | ||
[GNU GPLv3](LICENSE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think COPYING is the standard / recommended name for the file containing the full GPL license text. |
||
|
||
Copyright © 2021 Josip Antoliš, [email protected]. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# 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 + '@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', | ||
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') | ||
) | ||
|
||
# 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 gschema | ||
install_data ( | ||
meson.project_name () + '.gschema.xml', | ||
install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas') | ||
) | ||
|
||
# Register gemini MIME type | ||
install_data ( | ||
'gemini-mime-type.xml', | ||
install_dir: join_paths (get_option ('datadir'), 'mime', 'packages'), | ||
rename: meson.project_name () + '.xml' | ||
) | ||
|
||
# Install docs | ||
doc_files = ['index.gmi', 'discover.gmi', 'apps.gmi', 'terminology.gmi'] | ||
|
||
foreach doc_file : doc_files | ||
install_data ( | ||
join_paths ('static', doc_file), | ||
install_dir: join_paths (get_option ('datadir'), 'doc', 'starfish') | ||
) | ||
endforeach |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,182 +1,64 @@ | ||
project('hr.from.josipantolis.starfish', 'vala', 'c') | ||
|
||
# Include required modules | ||
gnome = import('gnome') | ||
i18n = import('i18n') | ||
|
||
# Set translation domain | ||
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c') | ||
# Project name, programming language and version | ||
project ( | ||
'hr.from.josipantolis.starfish', | ||
'c', 'vala', | ||
version: '1.3.1' | ||
) | ||
|
||
# Common build | ||
dependencies = [ | ||
dependency('glib-2.0'), | ||
dependency('gobject-2.0'), | ||
dependency('gee-0.8'), | ||
dependency('gtk+-3.0'), | ||
dependency('granite'), | ||
dependency('libhandy-1'), | ||
dependency('gnutls'), | ||
dependency('gtkspell3-3.0'), | ||
meson.get_compiler('vala').find_library('posix'), | ||
] | ||
# Translation module | ||
i18n = import ('i18n') | ||
|
||
gresource = gnome.compile_resources( | ||
'gresource', | ||
join_paths('data', 'gresource.xml'), | ||
source_dir: 'data' | ||
# Project arguments | ||
add_project_arguments ( | ||
'-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name ()), | ||
language: 'c' | ||
) | ||
|
||
sources = gresource + files( | ||
'src/UI/Application.vala', | ||
'src/UI/Window.vala', | ||
'src/UI/HeaderBar.vala', | ||
'src/UI/CertPopover.vala', | ||
'src/UI/ClientCertListBox.vala', | ||
'src/UI/ClientCertCreateDialog.vala', | ||
'src/UI/PreferencesDialog.vala', | ||
'src/UI/ContentStack.vala', | ||
'src/UI/InputView.vala', | ||
'src/UI/ResponseView.vala', | ||
'src/UI/PageStaticErrorView.vala', | ||
'src/UI/PageCertErrorView.vala', | ||
'src/UI/PageClientCertPickerView.vala', | ||
'src/UI/PageImageView.vala', | ||
'src/UI/PageTextView.vala', | ||
'src/UI/PageDownloadView.vala', | ||
'src/UI/GemtextRef.vala', | ||
'src/UI/GemtextView.vala', | ||
'src/UI/GemtextSearchBar.vala', | ||
'src/UI/TableOfContent.vala', | ||
'src/UI/LinkEventType.vala', | ||
'src/UI/LinkEvent.vala', | ||
'src/UI/TabContent.vala', | ||
'src/UI/TextViewHighlighter.vala', | ||
'src/Templates/Template.vala', | ||
'src/Templates/Bookmarks.vala', | ||
'src/Templates/TempFailure.vala', | ||
'src/Templates/InvalidResponse.vala', | ||
'src/Templates/ConnectionFailed.vala', | ||
'src/Templates/SlowDown.vala', | ||
'src/Templates/NonGeminiRedirect.vala', | ||
'src/Templates/TooManyRedirects.vala', | ||
'src/Templates/NotFound.vala', | ||
'src/Templates/Gone.vala', | ||
'src/Templates/BadRequest.vala', | ||
'src/Templates/UnsuportedSchema.vala', | ||
'src/Templates/PermFailure.vala', | ||
'src/Templates/CertNotApplicable.vala', | ||
'src/Templates/FileAccessDenied.vala', | ||
'src/Core/Client.vala', | ||
'src/Core/CertError.vala', | ||
'src/Core/CertInfo.vala', | ||
'src/Core/CertHash.vala', | ||
'src/Core/CertManager.vala', | ||
'src/Core/ClientCertFactory.vala', | ||
'src/Core/ClientCertRepo.vala', | ||
'src/Core/Uri.vala', | ||
'src/Core/Mime.vala', | ||
'src/Core/Response.vala', | ||
'src/Core/InternalErrorResponse.vala', | ||
'src/Core/Line.vala', | ||
'src/Core/LineType.vala', | ||
'src/Core/TextBody.vala', | ||
'src/Core/GeminiBody.vala', | ||
'src/Core/Storage.vala', | ||
'src/Core/SettingsBackedStorage.vala', | ||
'src/Core/BookmarksManager.vala', | ||
'src/Core/SessionManager.vala', | ||
'src/Core/Session.vala', | ||
'src/Core/Theme.vala', | ||
'src/Core/Tab.vala', | ||
'src/Core/TabManager.vala' | ||
) | ||
# GNOME module | ||
gnome = import ('gnome') | ||
|
||
# Test build | ||
test_sources = files( | ||
'test/TestMain.vala', | ||
'test/TestBase.vala', | ||
'test/Core/MimeTest.vala', | ||
'test/Core/ResponseTest.vala', | ||
'test/Core/LineTest.vala', | ||
'test/Core/BodyTestBase.vala', | ||
'test/Core/TextBodyTest.vala', | ||
'test/Core/GeminiBodyTest.vala', | ||
'test/Core/UriTest.vala' | ||
# Compiling resources | ||
gresource = gnome.compile_resources ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to move this into |
||
'gresource', | ||
join_paths ('data', meson.project_name ()) + '.gresource.xml', | ||
source_dir: 'data', | ||
c_name: 'as' | ||
) | ||
|
||
test_executeable = executable( | ||
meson.project_name() + '-tests', | ||
sources + test_sources, | ||
dependencies: dependencies | ||
) | ||
# Listing dependencies | ||
dependencies = [ | ||
dependency ('glib-2.0'), | ||
dependency ('gobject-2.0'), | ||
dependency ('gee-0.8'), | ||
dependency ('gtk+-3.0'), | ||
dependency ('granite'), | ||
dependency ('libhandy-1'), | ||
dependency ('gnutls'), | ||
dependency ('gtkspell3-3.0'), | ||
meson.get_compiler ('vala').find_library ('posix') | ||
] | ||
|
||
test('tests', test_executeable) | ||
subdir ('src') | ||
|
||
# Production build | ||
executable( | ||
meson.project_name(), | ||
sources + files('src/Main.vala'), | ||
# Defining executable | ||
executable ( | ||
meson.project_name (), | ||
sources, | ||
gresource, | ||
dependencies: dependencies, | ||
install: true | ||
) | ||
|
||
# Install gschema and register gemini MIME type | ||
install_data( | ||
join_paths('data', 'gschema.xml'), | ||
install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas'), | ||
rename: meson.project_name () + '.gschema.xml' | ||
) | ||
install_data( | ||
join_paths('data', 'gemini-mime-type.xml'), | ||
install_dir: join_paths(get_option('datadir'), 'mime', 'packages'), | ||
rename: meson.project_name () + '.xml' | ||
) | ||
meson.add_install_script('meson/post_install.py', meson.project_name ()) | ||
|
||
# Translate and install .desktop file | ||
i18n.merge_file( | ||
input: join_paths('data', 'starfish.desktop.in'), | ||
output: meson.project_name() + '.desktop', | ||
po_dir: join_paths(meson.source_root(), 'po'), | ||
type: 'desktop', | ||
install: true, | ||
install_dir: join_paths(get_option('datadir'), 'applications') | ||
) | ||
|
||
# Translate and install .appdata file | ||
i18n.merge_file( | ||
input: join_paths('data', 'starfish.appdata.xml.in'), | ||
output: meson.project_name() + '.appdata.xml', | ||
po_dir: join_paths(meson.source_root(), 'po'), | ||
install: true, | ||
install_dir: join_paths(get_option('datadir'), 'metainfo') | ||
) | ||
|
||
# Install icons | ||
icon_sizes = ['16', '24', '32', '48', '64', '128'] | ||
|
||
foreach i : icon_sizes | ||
install_data( | ||
join_paths('data', 'icons', i + '.svg'), | ||
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps'), | ||
rename: meson.project_name() + '.svg' | ||
) | ||
install_data( | ||
join_paths('data', 'icons', i + '.svg'), | ||
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i + '@2', 'apps'), | ||
rename: meson.project_name() + '.svg' | ||
) | ||
endforeach | ||
subdir ('test') | ||
|
||
# Install docs | ||
doc_files = ['index.gmi', 'discover.gmi', 'apps.gmi', 'terminology.gmi'] | ||
|
||
foreach doc_file : doc_files | ||
install_data( | ||
join_paths('data', 'static', doc_file), | ||
install_dir: join_paths(get_option('datadir'), 'doc', 'starfish') | ||
) | ||
endforeach | ||
# Defning tests executable | ||
test('tests', executable ( | ||
meson.project_name () + '-tests', | ||
common_sources + test_sources, | ||
dependencies: dependencies | ||
)) | ||
|
||
subdir('data') | ||
subdir('po') | ||
|
||
meson.add_install_script('meson/post_install.py', meson.project_name ()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from os import path, environ | ||
import subprocess | ||
import sys | ||
|
||
project_name = sys.argv[1] | ||
prefix = os.environ['MESON_INSTALL_PREFIX'] | ||
schemadir = os.path.join(prefix, 'share', 'glib-2.0', 'schemas') | ||
schema_file = os.path.join(schemadir, project_name + '.gschema.xml') | ||
mimedir = os.path.join(prefix, 'share', 'mime') | ||
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') | ||
datadir = path.join(prefix, 'share') | ||
schemadir = path.join(datadir, 'glib-2.0', 'schemas') | ||
schema_file = path.join(schemadir, project_name + '.gschema.xml') | ||
desktop_database_dir = path.join(datadir, 'applications') | ||
mimedir = path.join(datadir, 'mime') | ||
|
||
def fill_schema_placeholders(): | ||
with open(schema_file, 'rt') as file: | ||
schema_content = file.read() | ||
for param in os.environ.keys(): | ||
for param in environ.keys(): | ||
key = '{{' + param + '}}' | ||
value = os.environ[param] | ||
value = environ[param] | ||
schema_content = schema_content.replace(key, value) | ||
with open(schema_file, 'wt') as file: | ||
file.write(schema_content) | ||
|
||
if not os.environ.get('DESTDIR'): | ||
print('Replacing gsettings placeholders in ' + schema_file + '...') | ||
if not environ.get('DESTDIR'): | ||
print('Replacing gsettings placeholders in ' + schema_file + '…') | ||
fill_schema_placeholders() | ||
print('Compiling gsettings schemas...') | ||
print('Compiling gsettings schemas…') | ||
subprocess.call(['glib-compile-schemas', schemadir]) | ||
print('Registering text/gemini MIME type...') | ||
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')]) | ||
Antolius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
print('Registering text/gemini MIME type…') | ||
subprocess.call(['update-mime-database', mimedir]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
hr | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to have project name repeated in too many places, such as icon file names, etc.
Ideally it would only be defined in the
project
function call on top of the root meson.build file.Individual files can be renamed in calls to
install_data
function. That approach allows for:Admittedly, I haven't followed this rule in all the places myself, but I plan to clean those up over time.