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

Meson: Support separate devel/release profiles #44

Merged
merged 4 commits into from
Aug 27, 2024
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ concurrency:
cancel-in-progress: true

jobs:
flatpak:
name: Flathub
flatpak-devel:
name: Flatpak (Devel)
runs-on: ubuntu-latest
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-46
Expand All @@ -20,6 +20,6 @@ jobs:
- uses: actions/checkout@v4
- uses: flathub-infra/flatpak-github-actions/flatpak-builder@master
with:
bundle: butler.flatpak
manifest-path: com.cassidyjames.butler.json
bundle: com.cassidyjames.butler.Devel.flatpak
manifest-path: com.cassidyjames.butler.Devel.json
cache-key: "flatpak-builder-${{ github.sha }}"
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"app-id": "com.cassidyjames.butler",
"app-id": "com.cassidyjames.butler.Devel",
"runtime": "org.gnome.Platform",
"runtime-version": "46",
"sdk": "org.gnome.Sdk",
"command": "com.cassidyjames.butler",
"command": "com.cassidyjames.butler.Devel",
"finish-args": [
"--socket=wayland",
"--socket=fallback-x11",
Expand All @@ -16,6 +16,9 @@
"name": "butler",
"buildsystem": "meson",
"run-tests": true,
"config-opts": [
"-Dprofile=devel"
],
"sources": [
{
"type": "dir",
Expand Down
7 changes: 2 additions & 5 deletions data/gresource.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/cassidyjames/butler/">
<file preprocess="xml-stripblanks">metainfo.xml</file>
<file>style.css</file>
</gresource>
<gresource prefix="/com/cassidyjames/butler/icons/scalable/actions/">
<file alias="app.svg">icons/app.svg</file>
<file preprocess="xml-stripblanks" compressed="true">metainfo.xml.in</file>
<file alias="Devel/style.css">style.css</file>
</gresource>
</gresources>
2 changes: 1 addition & 1 deletion data/gschema.xml → data/gschema.xml.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/com/cassidyjames/butler/" id="com.cassidyjames.butler">
<schema path="/com/cassidyjames/butler/" id="@app_id@">
<key name="current-url" type="s">
<default>""</default>
<summary>Current URL</summary>
Expand Down
File renamed without changes
File renamed without changes
8 changes: 4 additions & 4 deletions data/launcher.desktop → data/launcher.desktop.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[Desktop Entry]
Name=Butler
Name=@app_name@
GenericName=Smart Home Dashboard
Comment=Control your smart home
Categories=Network;GTK;
Exec=com.cassidyjames.butler
Icon=com.cassidyjames.butler
Exec=@app_id@
Icon=@app_id@
Terminal=false
Type=Application
X-GNOME-Gettext-Domain=com.cassidyjames.butler
X-GNOME-Gettext-Domain=@app_id@
Keywords=hass;home;assistant;smart;lights;
46 changes: 34 additions & 12 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
data_config = configuration_data()
data_config.set('app_id', app_id)
data_config.set('app_name', app_name)

install_data(
'icons' / 'app.svg',
'icons' / profile + '.svg',
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps'),
rename: meson.project_name() + '.svg'
rename: app_id + '.svg'
)

install_data(
'icons' / 'symbolic.svg',
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps'),
rename: meson.project_name() + '-symbolic.svg'
rename: app_id + '-symbolic.svg'
)

install_data(
'gschema.xml',
gschema_file = configure_file(
input: files('gschema.xml.in'),
output: app_id + '.gschema.xml',
configuration: data_config,
install: true,
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas',
rename: meson.project_name() + '.gschema.xml'
)

install_data(
'launcher.desktop',
desktop_file = configure_file(
input: files('launcher.desktop.in'),
output: app_id + '.desktop',
configuration: data_config,
install: true,
install_dir: get_option('datadir') / 'applications',
rename: meson.project_name() + '.desktop'
)

install_data(
'metainfo.xml',
metainfo_file = configure_file(
input: files('metainfo.xml.in'),
output: '@BASENAME@',
configuration: data_config,
install: true,
install_dir: get_option('datadir') / 'metainfo',
rename: meson.project_name() + '.metainfo.xml'
)

asresources = gnome.compile_resources(
'as-resources',
'gresource.xml',
source_dir: 'data',
c_name: 'as',
)

desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils, args: [desktop_file])
endif
16 changes: 12 additions & 4 deletions data/metainfo.xml → data/metainfo.xml.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2024 Cassidy James Blaede <[email protected]> -->
<component type="desktop">
<id>com.cassidyjames.butler</id>
<id>@app_id@</id>
<metadata_license>CC-BY-SA-4.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>

<name>Butler</name>
<name>@app_name@</name>
<summary>Companion for Home Assistant</summary>

<branding>
Expand Down Expand Up @@ -38,9 +38,9 @@
</description>

<provides>
<binary>com.cassidyjames.butler</binary>
<binary>@app_id@</binary>
</provides>
<launchable type="desktop-id">com.cassidyjames.butler.desktop</launchable>
<launchable type="desktop-id">@app_id@.desktop</launchable>

<recommends>
<display_length compare="ge">360</display_length>
Expand All @@ -63,6 +63,14 @@
</screenshots>

<releases>
<release version="1.2.0" date="2024-08-27">
<description>
<p>Under the hood</p>
<ul>
<li>Separate development and release profiles to make development easier</li>
</ul>
</description>
</release>
<release version="1.1.3" date="2024-04-23">
<description>
<p>Improved app listing</p>
Expand Down
52 changes: 22 additions & 30 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
project(
'com.cassidyjames.butler',
'vala', 'c',
version: '1.1.3',
meson_version: '>=0.58',
version: '1.2.0',
meson_version: '>=1.1',
)

gnome = import('gnome')
app_id = meson.project_name()
app_name = 'Butler'

add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), language:'c')
profile = get_option('profile')
if profile == 'devel'
app_id += '.Devel'
app_name += ' (Devel)'
endif

asresources = gnome.compile_resources(
'as-resources',
'data' / 'gresource.xml',
source_dir: 'data',
c_name: 'as',
)
summary({
'Profile': profile,
}, section: 'Development')

config_data = configuration_data()
config_include = include_directories('.')

config_data.set_quoted('APP_ID', meson.project_name())
config_data.set_quoted('VERSION', meson.project_version())
config = configuration_data()
config.set_quoted('APP_ID', app_id)
config.set_quoted('APP_NAME', app_name)
config.set_quoted('VERSION', meson.project_version())
config.set_quoted('PROFILE', profile)

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

executable(
meson.project_name(),
'src' / 'App.vala',
'src' / 'MainWindow.vala',
'src' / 'Widgets' / 'WebView.vala',
asresources,
config_file,
dependencies: [
dependency('glib-2.0'),
dependency('gtk4'),
dependency('libadwaita-1', version: '>=1.5'),
dependency('webkitgtk-6.0'),
meson.get_compiler('vala').find_library('posix'),
],
install: true
)
gnome = import('gnome')
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(app_id), language:'c')

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

meson.add_install_script('build-aux' / 'meson'/ 'post_install.py')
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('profile', type: 'combo', choices: ['devel', 'release'], value: 'devel', description: 'Whether this is an in-development or release build; affects app ID, icon, etc.')
2 changes: 2 additions & 0 deletions src/Config.vala.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
public const string APP_ID = @APP_ID@;
public const string APP_NAME = @APP_NAME@;
public const string VERSION = @VERSION@;
public const string PROFILE = @PROFILE@;
18 changes: 9 additions & 9 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public class Butler.MainWindow : Adw.ApplicationWindow {

private Butler.WebView web_view;

public MainWindow (Gtk.Application application) {
public MainWindow (Adw.Application app) {
Object (
application: application,
application: app,
height_request: 294,
icon_name: APP_ID,
resizable: true,
title: APP_NAME,
width_request: 360
);
add_action_entries (ACTION_ENTRIES, this);
Expand All @@ -33,9 +35,10 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
construct {
maximized = App.settings.get_boolean ("window-maximized");
fullscreened = App.settings.get_boolean ("window-fullscreened");
this.add_css_class (PROFILE);

about_dialog = new Adw.AboutDialog.from_appdata (
"/com/cassidyjames/butler/metainfo.xml", VERSION
"/com/cassidyjames/butler/metainfo.xml.in", VERSION
) {
comments = _("Companion app to access your Home Assistant dashboard"),

Expand All @@ -46,18 +49,15 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
"Tobias Bernard https://tobiasbernard.com/",
},
};
about_dialog.application_icon = APP_ID;
about_dialog.application_name = APP_NAME;
about_dialog.copyright = "© 2020–%i %s".printf (
new DateTime.now_local ().get_year (),
about_dialog.developer_name
);
about_dialog.add_link (_("About Home Assistant"), "https://www.home-assistant.io/");
about_dialog.add_link (_("Home Assistant Privacy Policy"), "https://www.home-assistant.io/privacy/");

// Set MainWindow properties from the AppData already fetched and parsed
// by the AboutDialog construction
icon_name = about_dialog.application_icon;
title = about_dialog.application_name;

var home_button = new Gtk.Button.from_icon_name ("go-home-symbolic") {
tooltip_text = _("Go Home")
};
Expand All @@ -74,7 +74,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
// TODO: How do I add shortcuts to the menu?
app_menu.append (_("_Fullscreen"), "win.toggle_fullscreen");
app_menu.append (_("Change _Server…"), "win.set_server");
app_menu.append (_("_About %s").printf (title), "win.about");
app_menu.append (_("_About %s").printf (APP_NAME), "win.about");

var menu = new Menu ();
menu.append_section (null, site_menu);
Expand Down
17 changes: 17 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
executable(
app_id,
'App.vala',
'MainWindow.vala',
'Widgets' / 'WebView.vala',
asresources,
config_file,
include_directories: config_include,
dependencies: [
dependency('glib-2.0'),
dependency('gtk4'),
dependency('libadwaita-1', version: '>=1.5'),
dependency('webkitgtk-6.0'),
meson.get_compiler('vala').find_library('posix'),
],
install: true
)