First DBUS server
This commit is contained in:
parent
8ce7c1a8a5
commit
09d58154eb
7 changed files with 419 additions and 6 deletions
27
build.rs
Normal file
27
build.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use dbus_codegen::{GenOpts, generate};
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
fn write_to_file(code: &str, path: &Path) {
|
||||
let mut f = File::create(path).unwrap();
|
||||
Write::write_all(&mut f, code.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
fn generate_code(xml: &str, opts: &GenOpts, outfile: &str) {
|
||||
let code = generate(xml, opts).unwrap();
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let path = Path::new(&out_dir).join(outfile);
|
||||
println!("cargo::warning={:?}", path);
|
||||
write_to_file(&code, &path);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let opts = GenOpts::default();
|
||||
generate_code(
|
||||
include_str!("dbus/com.example.mytest.xml"),
|
||||
&opts,
|
||||
"com_example_mytest.rs",
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue