use std::fs::File;
use std::io::Write;
use parsli::graph::DependencyGraph;
use parsli::task::Task;
fn main() {
let tasks = vec![
Task::dummy("llvm.fetch", vec![]),
Task::dummy("clang.configure", vec!["llvm.fetch"]),
Task::dummy("compiler-rt.configure", vec!["llvm.fetch"]),
Task::dummy("clang.compile", vec!["clang.configure"]),
Task::dummy("compiler-rt.compile", vec!["compiler-rt.configure"]),
Task::dummy("clang.install", vec!["clang.compile"]),
Task::dummy("compiler-rt.install", vec!["compiler-rt.compile"]),
];
let targets = vec!["clang.install".to_string(), "clang.configure".to_string(), "compiler-rt.configure".to_string()];
let mut graph = DependencyGraph::from(tasks);
let mut f = File::options().create(true).write(true).open("before.dot").unwrap();
f.write(graph.to_string().as_bytes()).unwrap();
graph.retain_dependencies(targets);
for t in graph.toposort() {
println!("{}", t);
}
let mut f = File::options().create(true).write(true).open("after.dot").unwrap();
f.write(graph.to_string().as_bytes()).unwrap();
}