summary refs log tree commit diff
path: root/build.rs
blob: 9e7d61e5b8acc811101f5fbbabd9ab10650590bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()
    );
}