From fe5a542e0835694337de0f7cc7002c50d2648c60 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 1 Dec 2018 14:27:03 +0200 Subject: [PATCH 1/3] meson: Declare dependencies Close #109 --- meson.build | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 91d0ff7..a0baf6c 100644 --- a/meson.build +++ b/meson.build @@ -7,6 +7,34 @@ project( license: 'GPLv3', ) +# FIXME: look for cargo and optionally cargo-vendor +# dependency('cargo') + +dependency('sqlite3', version: '>= 3.20') +dependency('openssl', version: '>= 1.0') +dependency('dbus-1') + +dependency('glib-2.0', version: '>= 2.56') +dependency('gio-2.0', version: '>= 2.56') +dependency('gdk-pixbuf-2.0') +dependency('gtk+-3.0', version: '>= 3.22') +dependency('libhandy-0.0', version: '>= 0.0.4') + +dependency('gstreamer-1.0', version: '>= 1.12') +dependency('gstreamer-base-1.0', version: '>= 1.12') +dependency('gstreamer-audio-1.0', version: '>= 1.12') +dependency('gstreamer-video-1.0', version: '>= 1.12') +dependency('gstreamer-player-1.0', version: '>= 1.12') +dependency('gstreamer-plugins-base-1.0', version: '>= 1.12') +dependency('gstreamer-plugins-bad-1.0', version: '>= 1.12') +dependency('gstreamer-bad-audio-1.0', version: '>= 1.12') +dependency('gstreamer-bad-video-1.0', version: '>= 1.12') + +cargo = find_program('cargo', required: true) +gresource = find_program('glib-compile-resources', required: true) +gschemas = find_program('glib-compile-schemas', required: true) +cargo_vendor = find_program('cargo-vendor', required: false) + if get_option('profile') == 'development' profile = 'Devel' vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip() @@ -43,9 +71,6 @@ podcasts_conf.set('bindir', podcasts_bindir) datadir = get_option('datadir') subdir('podcasts-gtk/resources') -cargo = find_program('cargo', required: false) -gresource = find_program('glib-compile-resources', required: false) -cargo_vendor = find_program('cargo-vendor', required: false) cargo_script = find_program('scripts/cargo.sh') cargo_release = custom_target('cargo-build', From fc9de568bd6709c4f438177cb8063777dd1e992f Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 1 Dec 2018 14:42:31 +0200 Subject: [PATCH 2/3] meson: remove dead code --- meson.build | 7 ------- 1 file changed, 7 deletions(-) diff --git a/meson.build b/meson.build index a0baf6c..f2d729d 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,3 @@ -# Adatped from: -# https://gitlab.gnome.org/danigm/fractal/blob/6e2911f9d2353c99a18a6c19fab7f903c4bbb431/meson.build - project( 'gnome-podcasts', 'rust', version: '0.4.6', @@ -55,10 +52,6 @@ subdir('podcasts-gtk/po') podir = join_paths (meson.source_root (), 'podcasts-gtk', 'po') podcasts_version = meson.project_version() -version_array = podcasts_version.split('.') -podcasts_major_version = version_array[0].to_int() -podcasts_minor_version = version_array[1].to_int() -podcasts_version_micro = version_array[2].to_int() podcasts_prefix = get_option('prefix') podcasts_bindir = join_paths(podcasts_prefix, get_option('bindir')) From b72ba8c66add65455719c61dc44cd4f820298a8c Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 1 Dec 2018 22:08:34 +0200 Subject: [PATCH 3/3] podcasts-gtk: make it possible to compile with just cargo This is not supported at all, and it still won't run with cargo run, thankfully, you should use meson instead... The only purpose of this commit is to make it possible for cargo check, and by extension rls, to function and work properly. Part of #110 --- podcasts-gtk/src/app.rs | 22 +++++++++++++++++----- podcasts-gtk/src/widgets/aboutdialog.rs | 4 ++-- podcasts-gtk/src/widgets/empty.rs | 2 +- scripts/test.sh | 3 --- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index a3757e8..63f4261 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -48,8 +48,20 @@ use std::sync::Arc; use crate::i18n::i18n; -pub(crate) const APP_ID: &str = env!("APP_ID"); -pub(crate) const VERSION: &str = env!("VERSION"); +#[rustfmt::skip] +lazy_static! { + pub static ref APP_ID: &'static str = { + option_env!("APP_ID").unwrap_or("org.gnome.Podcasts") + }; + + pub static ref VERSION: &'static str = { + option_env!("VERSION").unwrap_or("0.0.1") + }; + + pub static ref LOCALEDIR: &'static str = { + option_env!("LOCALEDIR").unwrap_or("./podcasts-gtk/po") + }; +} /// Creates an action named `name` in the action map `T with the handler `F` fn action(thing: &T, name: &str, action: F) @@ -404,10 +416,10 @@ impl App { pub(crate) fn run() { // Set up the textdomain for gettext setlocale(LocaleCategory::LcAll, ""); - bindtextdomain("gnome-podcasts", env!("LOCALEDIR")); + bindtextdomain("gnome-podcasts", *LOCALEDIR); textdomain("gnome-podcasts"); - let application = gtk::Application::new(APP_ID, gio::ApplicationFlags::empty()) + let application = gtk::Application::new(*APP_ID, gio::ApplicationFlags::empty()) .expect("Application initialization failed..."); application.set_resource_base_path("/org/gnome/Podcasts"); @@ -438,7 +450,7 @@ impl App { // Weird magic I copy-pasted that sets the Application Name in the Shell. glib::set_application_name(&i18n("Podcasts")); glib::set_prgname(Some("gnome-podcasts")); - gtk::Window::set_default_icon_name(APP_ID); + gtk::Window::set_default_icon_name(*APP_ID); let args: Vec = env::args().collect(); ApplicationExtManual::run(&application, &args); } diff --git a/podcasts-gtk/src/widgets/aboutdialog.rs b/podcasts-gtk/src/widgets/aboutdialog.rs index 0fc6dcf..f29ce06 100644 --- a/podcasts-gtk/src/widgets/aboutdialog.rs +++ b/podcasts-gtk/src/widgets/aboutdialog.rs @@ -47,12 +47,12 @@ pub(crate) fn about_dialog(window: >k::ApplicationWindow) { ]; let dialog = gtk::AboutDialog::new(); - dialog.set_logo_icon_name(APP_ID); + dialog.set_logo_icon_name(*APP_ID); dialog.set_comments(i18n("Podcast Client for the GNOME Desktop.").as_str()); dialog.set_copyright("© 2017, 2018 Jordan Petridis"); dialog.set_license_type(gtk::License::Gpl30); dialog.set_modal(true); - dialog.set_version(VERSION); + dialog.set_version(*VERSION); dialog.set_program_name(&i18n("Podcasts")); dialog.set_website("https://wiki.gnome.org/Apps/Podcasts"); dialog.set_website_label(i18n("Learn more about GNOME Podcasts").as_str()); diff --git a/podcasts-gtk/src/widgets/empty.rs b/podcasts-gtk/src/widgets/empty.rs index 8abd6ce..fcf4d55 100644 --- a/podcasts-gtk/src/widgets/empty.rs +++ b/podcasts-gtk/src/widgets/empty.rs @@ -36,7 +36,7 @@ impl Default for EmptyView { let builder = gtk::Builder::new_from_resource("/org/gnome/Podcasts/gtk/empty_view.ui"); let view: gtk::Box = builder.get_object("empty_view").unwrap(); let image: gtk::Image = builder.get_object("image").unwrap(); - image.set_from_icon_name(format!("{}-symbolic", APP_ID).as_str(), 256); + image.set_from_icon_name(format!("{}-symbolic", *APP_ID).as_str(), 256); EmptyView(view) } } diff --git a/scripts/test.sh b/scripts/test.sh index 5665a36..12c7724 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -23,9 +23,6 @@ flatpak-builder --run \ # Run the tests xvfb-run -a -s "-screen 0 1024x768x24" \ flatpak-builder --run \ - --env=APP_ID="org.gnome.PodcastsDevel" \ - --env=LOCALEDIR="./podcasts-gtk/po" \ - --env=VERSION="0.0.0" \ --env=CARGO_HOME="target/cargo-home" \ --env=CARGO_TARGET_DIR="target_test/" \ app ${MANIFEST_PATH} \