From 8bf935eaa82be4a429fa6610df53c03729b96d52 Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Sun, 11 Mar 2018 01:16:22 -0800 Subject: [PATCH] Add a cli subcommand for xml objtree output --- src/cli/Cargo.toml | 1 + src/cli/main.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/cli/Cargo.toml b/src/cli/Cargo.toml index 68d7ddfe..ab958e94 100644 --- a/src/cli/Cargo.toml +++ b/src/cli/Cargo.toml @@ -18,3 +18,4 @@ dmm-tools = { path = "../tools" } [features] flame = ["dmm-tools/flame"] +xml = ["dreammaker/xml-rs"] diff --git a/src/cli/main.rs b/src/cli/main.rs index 5a5e201f..272827f3 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -32,6 +32,8 @@ fn main() { println!("Saving flame graph"); flame::dump_html(&mut std::io::BufWriter::new(std::fs::File::create(format!("{}/flame-graph.html", opt.output)).unwrap())).unwrap(); } + + std::process::exit(context.exit_status); } #[derive(Default)] @@ -39,6 +41,7 @@ struct Context { dm_context: dm::Context, objtree: ObjectTree, icon_cache: HashMap, + exit_status: i32, } impl Context { @@ -82,6 +85,14 @@ enum Command { /// Show information about the render-pass list. #[structopt(name = "list-passes")] ListPasses, + /// Dump the object tree to an XML file. + #[cfg(feature="xml")] + #[structopt(name = "objtree")] + ObjectTree { + /// The output filename. + #[structopt(default_value="objtree.xml")] + output: String, + }, /// Build minimaps of the specified maps. #[structopt(name = "minimap")] Minimap { @@ -157,6 +168,18 @@ fn run(opt: &Opt, command: &Command, context: &mut Context) { } }, // -------------------------------------------------------------------- + #[cfg(feature="xml")] + Command::ObjectTree { ref output } => { + context.objtree(opt); + match context.objtree.to_xml(output) { + Ok(()) => println!("saved {}", output), + Err(e) => { + println!("i/o error saving {}:\n{}", output, e); + context.exit_status = 1; + } + } + }, + // -------------------------------------------------------------------- Command::Minimap { ref output, min, max, ref enable, ref disable, ref files, pngcrush, optipng,