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:
parent
3339bb5ec8
commit
8db0b16954
2 changed files with 13 additions and 1 deletions
8
build.rs
8
build.rs
|
|
@ -30,9 +30,15 @@ fn main() {
|
||||||
assert!(status.success(), "blueprint-compiler failed");
|
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");
|
let schema_file = data_dir.join("net.jeena.FeedTheMonkey.gschema.xml");
|
||||||
println!("cargo:rerun-if-changed={}", schema_file.display());
|
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
|
// Compile GResource
|
||||||
let gresource_xml = data_dir.join("resources.gresource.xml");
|
let gresource_xml = data_dir.join("resources.gresource.xml");
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,12 @@ mod app;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
fn main() -> glib::ExitCode {
|
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();
|
let app = app::FeedTheMonkeyApp::new();
|
||||||
app.run()
|
app.run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue