scaffold: compile GSettings schema at build time for dev runs

build.rs now runs glib-compile-schemas on data/ so that debug builds
can find the schema without a system-wide install. main.rs sets
GSETTINGS_SCHEMA_DIR from the build-time constant when running in
debug mode.
This commit is contained in:
Jeena 2026-03-20 11:36:12 +00:00
parent 3339bb5ec8
commit 8db0b16954
2 changed files with 13 additions and 1 deletions

View file

@ -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");

View file

@ -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()
}