summary refs log tree commit diff
path: root/build.rs
blob: bef02ed5c46026aae897c99fbe45987897b04788 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use std::env;
use std::path::Path;
use std::process::Command;

fn main() {
    println!("cargo:rerun-if-changed=data/tc.mal.lleap.gschema.xml");

    compile_schemas();
    bundle_icons();
}

fn compile_schemas() {
    let out_dir = env::var("OUT_DIR").unwrap();
    let schema_dir = Path::new(&out_dir).join("glib-2.0").join("schemas");

    std::fs::create_dir_all(&schema_dir).unwrap();

    std::fs::copy(
        "data/tc.mal.lleap.gschema.xml",
        schema_dir.join("tc.mal.lleap.gschema.xml"),
    )
    .unwrap();

    Command::new("glib-compile-schemas")
        .arg(&schema_dir)
        .output()
        .unwrap();

    println!(
        "cargo:rustc-env=GSETTINGS_SCHEMA_DIR={}",
        schema_dir.display()
    );
}

fn bundle_icons() {
    relm4_icons_build::bundle_icons(
        // Name of the file that will be generated at `OUT_DIR`
        "icon_names.rs",
        // Optional app ID
        Some("tc.mal.lleap"),
        // Custom base resource path:
        // * defaults to `/com/example/myapp` in this case if not specified explicitly
        // * or `/org/relm4` if app ID was not specified either
        None::<&str>,
        // Directory with custom icons (if any)
        None::<&str>,
        // List of icons to include
        ["settings", "play-large", "pause-large", "subtitles"],
    );
}