diff --git a/build.rs b/build.rs index 98f9d5a..0035e54 100644 --- a/build.rs +++ b/build.rs @@ -30,9 +30,15 @@ fn main() { assert!(status.success(), "blueprint-compiler failed"); } - // Compile GSettings schema + // Compile GSettings schema into data/ so dev builds can find it let schema_file = data_dir.join("net.jeena.FeedTheMonkey.gschema.xml"); println!("cargo:rerun-if-changed={}", schema_file.display()); + let status = Command::new("glib-compile-schemas") + .arg(&data_dir) + .status() + .expect("failed to run glib-compile-schemas — is it installed?"); + assert!(status.success(), "glib-compile-schemas failed"); + println!("cargo:rustc-env=GSETTINGS_SCHEMA_DIR={}", data_dir.display()); // Compile GResource let gresource_xml = data_dir.join("resources.gresource.xml"); diff --git a/src/main.rs b/src/main.rs index 3b2e3ea..5471cc8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,12 @@ mod app; mod window; fn main() -> glib::ExitCode { + // In development builds, point GSettings at the locally compiled schema. + // In release/installed builds the schema is found via the system path. + if cfg!(debug_assertions) { + std::env::set_var("GSETTINGS_SCHEMA_DIR", env!("GSETTINGS_SCHEMA_DIR")); + } + let app = app::FeedTheMonkeyApp::new(); app.run() }