From 15b8f4a0c2267b11cfc329aa8f596912eae0adb4 Mon Sep 17 00:00:00 2001 From: Bleak Grey Date: Thu, 12 Jan 2023 22:20:11 +0300 Subject: [PATCH] feat(meson): devel option (#55) * Add new development flatpak manifest * feat(ci): use devel manifest * feat(meson): check if git is available * feat(meson): pass 'check' to run_command there was a warning * chore: install.sh should build devel * fix(meson_options): profile => devel Co-authored-by: Evangelos Paterakis --- .github/workflows/build.yml | 6 ++--- data/meson.build | 7 +++++- dev.geopjr.tooth.Devel.json | 50 +++++++++++++++++++++++++++++++++++++ install.sh | 1 + meson.build | 14 ++++++++++- meson_options.txt | 1 + src/Application.vala | 4 +-- src/Build.vala.in | 2 ++ src/Dialogs/MainWindow.vala | 4 +++ 9 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 dev.geopjr.tooth.Devel.json create mode 100644 meson_options.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6656f91..6b00c5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: options: --privileged steps: - uses: actions/checkout@v3 - - uses: flatpak/flatpak-github-actions/flatpak-builder@master + - uses: flatpak/flatpak-github-actions/flatpak-builder@v5 with: - bundle: "dev.geopjr.tooth.flatpak" - manifest-path: "dev.geopjr.tooth.json" + bundle: "dev.geopjr.tooth.Devel.flatpak" + manifest-path: "dev.geopjr.tooth.Devel.json" diff --git a/data/meson.build b/data/meson.build index 27cfb1a..1a1c6a7 100644 --- a/data/meson.build +++ b/data/meson.build @@ -2,8 +2,13 @@ icons_dir = join_paths(get_option('datadir'), 'icons', 'hicolor') scalable_dir = join_paths(icons_dir, 'scalable', 'apps') symbolic_dir = join_paths(icons_dir, 'symbolic', 'apps') +icon = 'color.svg' +if get_option('devel') + icon = 'color-nightly.svg' +endif + install_data( - join_paths('icons', 'color.svg'), + join_paths('icons', icon), install_dir: scalable_dir, rename: meson.project_name() + '.svg', ) diff --git a/dev.geopjr.tooth.Devel.json b/dev.geopjr.tooth.Devel.json new file mode 100644 index 0000000..9537d86 --- /dev/null +++ b/dev.geopjr.tooth.Devel.json @@ -0,0 +1,50 @@ +{ + "app-id": "dev.geopjr.tooth", + "runtime": "org.gnome.Platform", + "runtime-version": "43", + "sdk": "org.gnome.Sdk", + "sdk-extensions" : ["org.freedesktop.Sdk.Extension.vala"], + "build-options" : { + "prepend-path" : "/usr/lib/sdk/vala/bin/", + "prepend-ld-library-path" : "/usr/lib/sdk/vala/lib" + }, + "command": "dev.geopjr.tooth", + "finish-args": [ + "--device=dri", + "--share=ipc", + "--share=network", + "--socket=fallback-x11", + "--socket=wayland", + "--talk-name=org.gtk.vfs", + "--talk-name=org.gtk.vfs.*", + "--filesystem=xdg-run/gvfsd" + ], + "cleanup": [ + "/include", + "/lib/pkgconfig", + "/man", + "/share/doc", + "/share/gtk-doc", + "/share/man", + "/share/pkgconfig", + "/share/vala", + "*.la", + "*.a" + ], + "modules": [ + { + "name": "tooth", + "builddir": true, + "buildsystem": "meson", + "config-opts" : [ + "-Ddevel=true" + ], + "sources": [ + { + "type": "dir", + "path": "." + } + ] + } + ] +} \ No newline at end of file diff --git a/install.sh b/install.sh index 9636cc8..6e36868 100755 --- a/install.sh +++ b/install.sh @@ -2,6 +2,7 @@ set -e meson setup build --prefix=/usr +meson configure build -Ddevel=true cd build ninja sudo ninja install diff --git a/meson.build b/meson.build index 18d77b4..844dc4a 100644 --- a/meson.build +++ b/meson.build @@ -16,20 +16,32 @@ add_global_arguments( language: 'c', ) +devel = get_option('devel') config = configuration_data() config.set('EXEC_NAME', meson.project_name()) config.set('GETTEXT_PACKAGE', meson.project_name()) config.set('RESOURCES', '/' + '/'.join(meson.project_name().split('.')) + '/') config.set('VERSION', meson.project_version()) config.set('PREFIX', get_option('prefix')) +config.set('PROFILE', devel ? 'development' : 'production') config.set('NAME', 'Tooth') config.set('WEBSITE', 'https://github.com/GeopJr/tooth') config.set('SUPPORT_WEBSITE', 'https://github.com/GeopJr/tooth/issues') config.set( 'COPYRIGHT', - '© 2018-2021 bleak_grey\n© 2022 Evangelos \"GeopJr\" Paterakis', + '© 2022 bleak_grey\n© 2022 Evangelos \"GeopJr\" Paterakis', ) +if devel + git = find_program('git') + if git.found() + branch = run_command('git', 'branch', '--show-current', check: true).stdout().strip() + revision = run_command('git', 'rev-parse', '--short', 'HEAD', check: true).stdout().strip() + version = '@0@-@1@'.format(branch, revision) + config.set('VERSION', version) + endif +endif + gnome = import('gnome') i18n = import('i18n') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..4bb398c --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('devel', type: 'boolean', value: false) \ No newline at end of file diff --git a/src/Application.vala b/src/Application.vala index 52b0475..265c754 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -200,9 +200,9 @@ namespace Tooth { refresh (); } - string troubleshooting = "flatpak: %s\nversion: %s\ngtk: %u.%u.%u (%d.%d.%d)\nlibadwaita: %u.%u.%u (%d.%d.%d)\nlibsoup: %u.%u.%u (%d.%d.%d)\n".printf( + string troubleshooting = "flatpak: %s\nversion: %s (%s)\ngtk: %u.%u.%u (%d.%d.%d)\nlibadwaita: %u.%u.%u (%d.%d.%d)\nlibsoup: %u.%u.%u (%d.%d.%d)\n".printf( (GLib.Environment.get_variable("FLATPAK_ID") != null || GLib.File.new_for_path("/.flatpak-info").query_exists()).to_string(), - Build.VERSION, + Build.VERSION, Build.PROFILE, Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version(), Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION, Adw.get_major_version(), Adw.get_minor_version(), Adw.get_micro_version(), diff --git a/src/Build.vala.in b/src/Build.vala.in index 1d5a47a..b2885ce 100644 --- a/src/Build.vala.in +++ b/src/Build.vala.in @@ -8,6 +8,7 @@ public class Build { public const string SUPPORT_WEBSITE = "@SUPPORT_WEBSITE@"; public const string COPYRIGHT = "@COPYRIGHT@"; public const string PREFIX = "@PREFIX@"; + public const string PROFILE = "@PROFILE@"; public static string SYSTEM_INFO; @@ -23,6 +24,7 @@ public class Build { SYSTEM_INFO = @"$NAME $VERSION"; SYSTEM_INFO += @"\nRunning on: $os_name $os_ver"; SYSTEM_INFO += @"\nBuild prefix: \"$PREFIX\""; + SYSTEM_INFO += @"\nBuild profile: \"$PROFILE\""; var lines = SYSTEM_INFO.split ("\n"); foreach (unowned string line in lines) { diff --git a/src/Dialogs/MainWindow.vala b/src/Dialogs/MainWindow.vala index a23cebc..a4673c7 100644 --- a/src/Dialogs/MainWindow.vala +++ b/src/Dialogs/MainWindow.vala @@ -32,6 +32,10 @@ public class Tooth.Dialogs.MainWindow: Adw.ApplicationWindow, Saveable { ); sidebar.set_sidebar_selected_item(0); open_view (new Views.Main ()); + + if (Build.PROFILE == "development") { + this.add_css_class ("devel"); + } } public Views.Base open_view (Views.Base view) {