Skip to content

Instantly share code, notes, and snippets.

@pczarn
Forked from alexcrichton/deps.rs
Last active March 20, 2016 07:28
Show Gist options
  • Save pczarn/19ee08f2995f2b84231d to your computer and use it in GitHub Desktop.
Save pczarn/19ee08f2995f2b84231d to your computer and use it in GitHub Desktop.
Rust: dependency graph
use std::io;
fn main() {
println!("digraph {{");
let mut input = io::stdin();
let mut lines = input.lines();
loop {
match lines.next() {
Some(line) => {
let line = line.unwrap();
let line = line.as_slice();
if !line.starts_with("DEPS_") { continue }
let mut parts = line.as_slice().words();
let name = parts.next().unwrap();
let name = name.slice_from(5);
let _ign = parts.next();
for dep in parts {
if dep.starts_with("native:") { continue }
if dep == "\\" {
let newline = lines.next().unwrap().unwrap();
for word in newline.as_slice().words() {
if word.starts_with("native:") { continue }
println!(" {} -> {};", name, word);
}
} else {
println!(" {} -> {};", name, dep);
}
}
}
None => break
}
}
println!("}}");
}
cat rust/mk/crates.mk | ./deps | dot -Tpdf > deps.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment