From 15457e1db40cf2433b65aabc4feea13dbc201f34 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sun, 26 Aug 2018 16:43:11 +0300 Subject: [PATCH] App/Build: Use env! macro to fetch the variable env! is resolved at compile time which means we don't need to read and set LOCALDI from build.rs --- podcasts-gtk/build.rs | 16 ---------------- podcasts-gtk/src/app.rs | 4 +--- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/podcasts-gtk/build.rs b/podcasts-gtk/build.rs index ab9e977..45d6332 100644 --- a/podcasts-gtk/build.rs +++ b/podcasts-gtk/build.rs @@ -14,20 +14,4 @@ fn main() { .current_dir("resources") .status() .unwrap(); - - // Generating build globals - let default_locales = "./podcasts-gtk/po".to_string(); - let out_dir = env::var("OUT_DIR").unwrap(); - let localedir = env::var("PODCASTS_LOCALEDIR").unwrap_or(default_locales); - let dest_path = Path::new(&out_dir).join("build_globals.rs"); - let mut f = File::create(&dest_path).unwrap(); - - let globals = format!( - " -pub(crate) static LOCALEDIR: &'static str = \"{}\"; -", - localedir - ); - - f.write_all(&globals.into_bytes()[..]).unwrap(); } diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index 8a15784..b4397c4 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -30,8 +30,6 @@ use i18n::i18n; pub(crate) const APP_ID: &str = "org.gnome.Podcasts"; -include!(concat!(env!("OUT_DIR"), "/build_globals.rs")); - /// Creates an action named `name` in the action map `T with the handler `F` fn action(thing: &T, name: &str, action: F) where @@ -377,7 +375,7 @@ impl App { pub(crate) fn run() { // Set up the textdomain for gettext setlocale(LocaleCategory::LcAll, ""); - bindtextdomain("gnome-podcasts", LOCALEDIR); + bindtextdomain("gnome-podcasts", env!("LOCALEDIR")); textdomain("gnome-podcasts"); let application = gtk::Application::new(APP_ID, gio::ApplicationFlags::empty())