Analyze dependencies of cargo projects
#![feature(let_chains)]

mod annotations;
mod graph;
mod visualize;

use cargo_metadata::MetadataCommand;
pub use graph::{AnnotationGraph, Measurement, Variable};

fn main() {
    // Skip rebuilding every time by caching the output from `--timings=json` as a local file
    let timings_data = include_bytes!("../timings.stdout");
    let timings = annotations::timings::Output::new(timings_data);
    let self_profile = annotations::self_profile::ProfileCollection::new();

    // Skip rebuilding every time by caching the output from `--unit-graph` as a local file
    let unit_graph_data = include_str!("../unit-graph.json");
    let unit_graph = annotations::unit_graph::UnitGraph::new(unit_graph_data).unwrap();

    let metadata = MetadataCommand::new().exec().unwrap();

    let graph = AnnotationGraph::new(metadata, timings, self_profile, &unit_graph);

    visualize::for_style(visualize::Style::Treemap, &graph);
}