-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.rs
33 lines (28 loc) · 1.02 KB
/
build.rs
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 dbus_codegen::{ConnectionType, GenOpts, ServerAccess};
use std::env;
use std::error::Error;
use std::fs;
use std::path::Path;
const INTROSPECTION_PATH: &str = "dbus/introspection.xml";
fn main() -> Result<(), Box<dyn Error>> {
let introspection = fs::read_to_string(INTROSPECTION_PATH)?;
let out_dir = env::var_os("OUT_DIR").ok_or("OUT_DIR is not set")?;
let gen_path = Path::new(&out_dir).join("introspection.rs");
let gen_opts = GenOpts {
methodtype: None,
crossroads: true,
skipprefix: None,
serveraccess: ServerAccess::RefClosure,
genericvariant: false,
connectiontype: ConnectionType::Blocking,
propnewtype: false,
interfaces: None,
..Default::default()
};
let code = dbus_codegen::generate(&introspection, &gen_opts)?;
fs::write(&gen_path, code)?;
println!("D-Bus code generated at {gen_path:?}");
println!("cargo:rerun-if-changed={INTROSPECTION_PATH}");
println!("cargo:rerun-if-changed=build.rs");
Ok(())
}