Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
Improve meson build system
Browse files Browse the repository at this point in the history
  • Loading branch information
casasfernando committed Dec 24, 2021
1 parent 87137bf commit 209208d
Show file tree
Hide file tree
Showing 20 changed files with 175 additions and 165 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ Being this one of my first Vala applications I'm sure that the code can be impro
## Screenshots

### Indicator
![Screenshot](data/screenshot_1.png)
![Screenshot](data/screenshot_2.png)
![Screenshot](data/screenshots/screenshot_1.png)
![Screenshot](data/screenshots/screenshot_2.png)
### Indicator (inc. battery charge percentage):
![Screenshot](data/screenshot_3.png)
![Screenshot](data/screenshots/screenshot_3.png)
### Popover:
![Screenshot](data/screenshot_4.png)
![Screenshot](data/screenshot_5.png)
![Screenshot](data/screenshot_6.png)
![Screenshot](data/screenshots/screenshot_4.png)
![Screenshot](data/screenshots/screenshot_5.png)
![Screenshot](data/screenshots/screenshot_6.png)
### Popover (inc. battery charge percentage):
![Screenshot](data/screenshot_7.png)
![Screenshot](data/screenshots/screenshot_7.png)
### Settings:
![Screenshot](data/screenshot_8.png)
![Screenshot](data/screenshots/screenshot_8.png)

## Building and installation from source

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
</custom>
<screenshots>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_1.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_1.png</image>
</screenshot>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_2.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_2.png</image>
</screenshot>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_3.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_3.png</image>
</screenshot>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_4.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_4.png</image>
</screenshot>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_5.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_5.png</image>
</screenshot>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_6.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_6.png</image>
</screenshot>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_7.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_7.png</image>
</screenshot>
<screenshot type="default">
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshot_8.png</image>
<image>https://github.com/casasfernando/wingpanel-indicator-airpods/raw/master/data/screenshots/screenshot_8.png</image>
</screenshot>
</screenshots>
<developer_name>Fernando Casas Schössow</developer_name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/casasfernando/wingpanel-indicator-airpods">
<file alias="Application.css">Application.css</file>
<file compressed="true" preprocess="xml-stripblanks">icons/airpods-symbolic.svg</file>
<file compressed="true" preprocess="xml-stripblanks">icons/airpods-left-symbolic.svg</file>
<file compressed="true" preprocess="xml-stripblanks">icons/airpods-right-symbolic.svg</file>
<file compressed="true" preprocess="xml-stripblanks">icons/airpods-case-symbolic.svg</file>
<file compressed="true" preprocess="xml-stripblanks">icons/airpods-connected-symbolic.svg</file>
<file compressed="true" preprocess="xml-stripblanks">icons/airpods-disconnected-symbolic.svg</file>
</gresource>
</gresources>
12 changes: 0 additions & 12 deletions data/icons/icons.indicator.gresource.xml

This file was deleted.

73 changes: 27 additions & 46 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,56 +1,37 @@
# 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')
)
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

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 .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')
)

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')
# 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')
)


desktop_file_validate = find_program('desktop-file-validate', required:false)

if desktop_file_validate.found()
test (
'Validate desktop file',
desktop_file_validate,
args: join_paths(meson.current_build_dir (), meson.project_name() + '.desktop')
)
endif

appstreamcli = find_program(['appstreamcli', 'appstream-util'], required:false)

if appstreamcli.found()
test (
'Validate appdata file',
appstreamcli,
args: ['validate', join_paths(meson.current_build_dir (), meson.project_name() + '.appdata.xml')]
)
endif

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

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
135 changes: 71 additions & 64 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,88 +1,95 @@
project('com.github.casasfernando.wingpanel-indicator-airpods', 'vala', 'c')
# Project name, programming language and version
project (
'com.github.casasfernando.wingpanel-indicator-airpods',
'c', 'vala',
version: '0.4.7'
)

# GNOME module
gnome = import ('gnome')

gnome = import('gnome')
i18n = import('i18n')
# Translation module
i18n = import ('i18n')

add_project_arguments(['--vapidir', join_paths(meson.current_source_dir(), 'vapi')], language: 'vala')
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'
)

# common dirs
prefix = get_option('prefix')
datadir = join_paths(prefix, get_option('datadir'))
libdir = join_paths(prefix, get_option('libdir'))
icondir = join_paths(datadir, 'icons', 'hicolor')
add_project_arguments (
['--vapidir', join_paths (meson.current_source_dir (), 'vapi')],
language: 'vala'
)

# deps
wingpanel = dependency('wingpanel')
# Listing dependencies
wingpanel = dependency ('wingpanel')

icons_gresource = gnome.compile_resources(
'gresource_icons',
'data/icons/icons.indicator.gresource.xml',
source_dir: 'data/icons',
common_dependencies = [
dependency ('granite'),
dependency ('gtk+-3.0'),
dependency ('gee-0.8'),
dependency ('glib-2.0'),
dependency ('gobject-2.0'),
wingpanel
]

executable_dependencies = [
common_dependencies,
dependency ('libhandy-1'),
meson.get_compiler ('c').find_library ('m', required : false),
meson.get_compiler ('vala').find_library ('posix')
]

indicator_dependencies = [
common_dependencies,
dependency ('libnotify')
]

# Compiling resources
asresources = gnome.compile_resources (
'as-resources',
join_paths ('data', meson.project_name ()) + '.gresource.xml',
source_dir: 'data',
c_name: 'as'
)

config_data = configuration_data()
config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
# Config
config_data = configuration_data ()
config_data.set_quoted ('GETTEXT_PACKAGE', meson.project_name ())

configure_file(output: 'config.h', configuration: config_data)
config_h_dir = include_directories('.')
configure_file (output: 'config.h', configuration: config_data)

c_args = [
'-include', 'config.h',
'-w',
]

executable(
meson.project_name(),
icons_gresource,
'src/Application.vala',
'src/MainWindow.vala',
'src/Widgets/ComboRow.vala',
'src/Widgets/SpinRow.vala',
'src/Widgets/Toggles.vala',
subdir ('src')

# Define executable
executable (
meson.project_name (),
executable_sources,
asresources,
c_args: c_args,
dependencies: [
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('granite'),
dependency('gtk+-3.0'),
dependency('libhandy-1'),
wingpanel,
meson.get_compiler('c').find_library('m', required : false),
meson.get_compiler('vala').find_library('posix')
],
dependencies: executable_dependencies,
install: true
)

shared_module(
# Define indicator
shared_module (
'wingpanel-indicator-airpods',
'src/Indicator.vala',
'src/Services/Airpods.vala',
'src/Services/Bluez.vala',
'src/Services/Dbus.vala',
'src/Services/Mpris.vala',
'src/Services/Upower.vala',
'src/Widgets/DisplayWidget.vala',
'src/Widgets/IndicatorWidget.vala',
'src/Widgets/PopoverWidget.vala',
'src/Widgets/PopoverWidgetRowIconic.vala',
icons_gresource,
indicator_sources,
asresources,
c_args: c_args,
dependencies: [
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('libnotify'),
dependency('granite'),
dependency('gtk+-3.0'),
wingpanel,
],
dependencies: indicator_dependencies,
install: true,
install_dir : wingpanel.get_pkgconfig_variable('indicatorsdir', define_variable: ['libdir', libdir]),
install_dir : wingpanel.get_pkgconfig_variable('indicatorsdir', define_variable: ['libdir', join_paths (get_option ('prefix'), get_option ('libdir'))]),
)

subdir('data')
subdir('po')
meson.add_install_script('meson/post_install.py')

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

meson.add_install_script ('meson/post_install.py')
30 changes: 11 additions & 19 deletions meson/post_install.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
#!/usr/bin/env python3

import os
from os import path, environ
import subprocess

prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = os.path.join(prefix, 'share')
schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas')
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')

# Packaging tools define DESTDIR and this isn't needed for them
if 'DESTDIR' not in os.environ:
print('Updating icon cache...')
icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
if not os.path.exists(icon_cache_dir):
os.makedirs(icon_cache_dir)
subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])

print('Updating desktop database...')
desktop_database_dir = os.path.join(datadir, 'applications')
if not os.path.exists(desktop_database_dir):
os.makedirs(desktop_database_dir)
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('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])
print('Updating icon cache…')
subprocess.call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
11 changes: 7 additions & 4 deletions po/extra/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
i18n.gettext('extra',
args: '--directory=' + meson.source_root(),
preset: 'glib',
install: false
# Install metadata translations
i18n.gettext ('extra',
args: [
'--directory=' + meson.source_root (),
'--from-code=UTF-8'
],
install: false
)
10 changes: 7 additions & 3 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
i18n.gettext(meson.project_name(),
args: '--directory=' + meson.source_root(),
preset: 'glib'
# Install main translations
i18n.gettext (meson.project_name (),
args: [
'--directory=' + meson.source_root (),
'--from-code=UTF-8',
'-cTRANSLATORS'
]
)

subdir ('extra')
Loading

0 comments on commit 209208d

Please sign in to comment.