summary refs log tree commit diff
path: root/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..9e7d61e
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,33 @@
+use std::env;
+use std::path::Path;
+use std::process::Command;
+
+fn main() {
+    // Tell cargo to rerun this build script if the schema file changes
+    println!("cargo:rerun-if-changed=data/tc.mal.lleap.gschema.xml");
+
+    let out_dir = env::var("OUT_DIR").unwrap();
+    let schema_dir = Path::new(&out_dir).join("glib-2.0").join("schemas");
+
+    // Create the schema directory
+    std::fs::create_dir_all(&schema_dir).unwrap();
+
+    // Copy the schema file to the output directory
+    std::fs::copy(
+        "data/tc.mal.lleap.gschema.xml",
+        schema_dir.join("tc.mal.lleap.gschema.xml"),
+    )
+    .unwrap();
+
+    // Compile the schema using glib-compile-schemas
+    Command::new("glib-compile-schemas")
+        .arg(&schema_dir)
+        .output()
+        .unwrap();
+
+    // Set environment variable for the schema directory
+    println!(
+        "cargo:rustc-env=GSETTINGS_SCHEMA_DIR={}",
+        schema_dir.display()
+    );
+}