From 69d262c49fc4caa0bf988a7af39ae1b83a6988d7 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Thu, 13 Apr 2023 14:11:19 +0200 Subject: [PATCH 1/8] feat/dotgraph: implement dot graph rendering as part of the proc-macro Signed-off-by: Bernhard Schuster --- metered-channel/Cargo.toml | 4 +- orchestra/Cargo.toml | 2 +- orchestra/proc-macro/Cargo.toml | 14 +- orchestra/proc-macro/src/graph.rs | 151 ++++++++++++------ .../src/impl_subsystem_ctx_sender.rs | 14 +- 5 files changed, 123 insertions(+), 62 deletions(-) diff --git a/metered-channel/Cargo.toml b/metered-channel/Cargo.toml index a14d2af..5404f06 100644 --- a/metered-channel/Cargo.toml +++ b/metered-channel/Cargo.toml @@ -15,7 +15,9 @@ derive_more = "0.99" tracing = "0.1.35" thiserror = "1.0.31" crossbeam-queue = "0.3.5" -nanorand = { version = "0.7.0", default-features = false, features = ["wyrand"] } +nanorand = { version = "0.7.0", default-features = false, features = [ + "wyrand", +] } coarsetime = "^0.1.22" [dev-dependencies] diff --git a/orchestra/Cargo.toml b/orchestra/Cargo.toml index 7839907..b38296a 100644 --- a/orchestra/Cargo.toml +++ b/orchestra/Cargo.toml @@ -39,7 +39,7 @@ name = "bench_main" harness = false [features] -default = ["deny_unconsumed_messages","deny_unsent_messages"] +default = ["deny_unconsumed_messages", "deny_unsent_messages"] # Generate a file containing the generated code that # is used via `include_str!`. expand = ["orchestra-proc-macro/expand"] diff --git a/orchestra/proc-macro/Cargo.toml b/orchestra/proc-macro/Cargo.toml index b804fa1..2f47635 100644 --- a/orchestra/proc-macro/Cargo.toml +++ b/orchestra/proc-macro/Cargo.toml @@ -19,10 +19,17 @@ syn = { version = "1.0.109", features = ["full", "extra-traits"] } quote = "1.0.20" proc-macro2 = { version = "1.0.47", features = ["span-locations"] } proc-macro-crate = "1.1.3" -expander = { version = "1.0.0", default-features = false } +expander = { version = "2.0.0", default-features = false } petgraph = "0.6.0" itertools = { version = "0.10.3" } indexmap = "1" +dotlay = { package = "layout-rs", version = "0.1.1", features = [ + "log", +], optional = true } +resvg = { version = "0.28", optional = true } +png = { version = "0.17", optional = true } +fs-err = { version = "2", optional = true } +anyhow = { version = "1", optional = true } [dev-dependencies] assert_matches = "1.5" @@ -31,13 +38,14 @@ thiserror = "1" tracing = "0.1" [features] -default = [] # enable "dotgraph" by default, blocked by +default = [ +] # enable "dotgraph" by default, blocked by # write the expanded version to a `orchestra-expansion.[a-f0-9]{10}.rs` # in the `OUT_DIR` as defined by `cargo` for the `expander` crate. expand = [] # Create directional message consuming / outgoing graph. # Generates: `${OUT_DIR}/${orchestra|lowercase}-subsystem-messaging.dot` -dotgraph = [] +dotgraph = ["dotlay", "anyhow", "png", "fs-err", "resvg"] # Creates a compile error if unconsumed messages are encountered deny_unconsumed_messages = [] # Creates a compile error if unsent messages are encountered diff --git a/orchestra/proc-macro/src/graph.rs b/orchestra/proc-macro/src/graph.rs index 0a668ba..a6d33ab 100644 --- a/orchestra/proc-macro/src/graph.rs +++ b/orchestra/proc-macro/src/graph.rs @@ -178,11 +178,64 @@ impl<'a> ConnectionGraph<'a> { sccs } + #[cfg(feature = "dotgraph")] + fn convert_and_write_all<'b>( + dot: &petgraph::dot::Dot<'b, &'b petgraph::graph::Graph>, + dest: impl AsRef, + ) -> anyhow::Result<()> { + use self::graph_helpers::color_scheme; + use fs_err as fs; + + let dot_content = format!( + r#"digraph {{ +node [colorscheme={}] +{:?} +}}"#, + color_scheme(), + &dot + ); + + let dest = dest.as_ref(); + let dest = dest.to_path_buf(); + + let svg_content = { + let mut parser = dotlay::gv::DotParser::new(dot_content.as_str()); + let graph = parser.process().map_err(|err_msg| anyhow::anyhow!(err_msg))?; + let mut svg = dotlay::backends::svg::SVGWriter::new(); + let mut builder = dotlay::gv::GraphBuilder::default(); + builder.visit_graph(&graph); + let mut vg = builder.get(); + vg.do_it(true, false, false, &mut svg); + svg.finalize() + }; + + let png_content = { + use resvg::{render, tiny_skia::Pixmap, usvg}; + + let rtree = usvg::Tree::from_data(svg_content.as_bytes(), &usvg::Options::default())?; + let mut pixi = + Pixmap::new(rtree.size.width() as u32, rtree.size.height() as u32).unwrap(); + render( + &rtree, + usvg::FitTo::Original, + resvg::tiny_skia::Transform::default(), + pixi.as_mut(), + ) + .ok_or_else(|| anyhow::anyhow!("Failed to render svg to png"))?; + pixi.encode_png()? + }; + fs::write(dest.with_extension("dot"), dot_content)?; + fs::write(dest.with_extension("svg"), svg_content.as_bytes())?; + fs::write(dest.with_extension("png"), png_content)?; + + Ok(()) + } + /// Render a graphviz (aka dot graph) to a file. /// /// Cycles are annotated with the lower #[cfg(feature = "dotgraph")] - pub(crate) fn graphviz(self, dest: &mut impl std::io::Write) -> std::io::Result<()> { + pub(crate) fn render_graphs<'b>(self, dest: impl AsRef) -> anyhow::Result<()> { use self::graph_helpers::*; use petgraph::{ dot::{self, Dot}, @@ -251,41 +304,49 @@ impl<'a> ConnectionGraph<'a> { } let unsent_node_label = r#"label="✨",fillcolor=black,shape=doublecircle,style=filled,fontname="NotoColorEmoji""#; let unconsumed_node_label = r#"label="💀",fillcolor=black,shape=doublecircle,style=filled,fontname="NotoColorEmoji""#; - let edge_attr = |_graph: &Graph, - edge: <&Graph as IntoEdgeReferences>::EdgeRef| - -> String { - let source = edge.source(); - let sink = edge.target(); - - let message_name = - edge.weight().get_ident().expect("Must have a trailing identifier. qed"); - - // use the intersection only, that's the set of cycles the edge is part of - if let Some(edge_intersecting_scc_tags) = scc_lut.get(&source).and_then(|source_set| { - scc_lut.get(&sink).and_then(move |sink_set| { - let intersection = - HashSet::<_, RandomState>::from_iter(source_set.intersection(sink_set)); - if intersection.is_empty() { - None - } else { - Some(intersection) + + let get_edge_attributes = { + |_graph: &Graph, + edge: <&Graph as IntoEdgeReferences>::EdgeRef| + -> String { + let source = edge.source(); + let sink = edge.target(); + + let message_name = + edge.weight().get_ident().expect("Must have a trailing identifier. qed"); + + // use the intersection only, that's the set of cycles the edge is part of + if let Some(edge_intersecting_scc_tags) = + scc_lut.get(&source).and_then(|source_set| { + scc_lut.get(&sink).and_then(move |sink_set| { + let intersection = HashSet::<_, RandomState>::from_iter( + source_set.intersection(sink_set), + ); + if intersection.is_empty() { + None + } else { + Some(intersection) + } + }) + }) { + if edge_intersecting_scc_tags.len() != 1 { + unreachable!( + "Strongly connected components are disjunct by definition. qed" + ); } - }) - }) { - if edge_intersecting_scc_tags.len() != 1 { - unreachable!("Strongly connected components are disjunct by definition. qed"); + let scc_tag = edge_intersecting_scc_tags.iter().next().unwrap(); + let color = get_color_by_tag(scc_tag, color_lut); + let scc_tag_str = + cycle_tags_to_annotation(edge_intersecting_scc_tags, color_lut); + format!( + r#"color="{color}",fontcolor="{color}",xlabel=<{scc_tag_str}>,label="{message_name}""#, + ) + } else { + format!(r#"label="{message_name}""#,) } - let scc_tag = edge_intersecting_scc_tags.iter().next().unwrap(); - let color = get_color_by_tag(scc_tag, color_lut); - let scc_tag_str = cycle_tags_to_annotation(edge_intersecting_scc_tags, color_lut); - format!( - r#"color="{color}",fontcolor="{color}",xlabel=<{scc_tag_str}>,label="{message_name}""#, - ) - } else { - format!(r#"label="{message_name}""#,) } }; - let node_attr = + let get_node_attributes = { |_graph: &Graph, (node_index, subsystem_name): <&Graph as IntoNodeReferences>::NodeRef| -> String { @@ -310,22 +371,18 @@ impl<'a> ConnectionGraph<'a> { } else { format!(r#"label="{subsystem_name}""#) } - }; - let dot = Dot::with_attr_getters( - &graph, config, &edge_attr, // with state, the reference is a trouble maker - &node_attr, + } + }; + // let graph = Box::new(graph); + let dotgraph = Dot::with_attr_getters( + &graph, + config, + &get_edge_attributes, // with state, the reference is a trouble maker + &get_node_attributes, ); - dest.write_all( - format!( - r#"digraph {{ - node [colorscheme={}] - {:?} -}}"#, - color_scheme(), - &dot - ) - .as_bytes(), - )?; + + Self::convert_and_write_all(&dotgraph, dest)?; + Ok(()) } } diff --git a/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs b/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs index f86b7fc..42379df 100644 --- a/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs +++ b/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs @@ -91,18 +91,12 @@ pub(crate) fn impl_subsystem_types_all(info: &OrchestraInfo) -> Result Date: Sat, 1 Jul 2023 10:55:57 +0200 Subject: [PATCH 2/8] chore/deps: bump resvg and usvg Signed-off-by: Bernhard Schuster --- Cargo.lock | 473 +++++++++++++++++++++++++++++- orchestra/proc-macro/Cargo.toml | 2 +- orchestra/proc-macro/src/graph.rs | 4 +- 3 files changed, 474 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 194ceaf..f7d068d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "0.7.19" @@ -17,6 +23,24 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "anyhow" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "assert_matches" version = "1.5.0" @@ -62,6 +86,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" + [[package]] name = "bitflags" version = "1.3.2" @@ -92,6 +122,12 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" + [[package]] name = "cast" version = "0.3.0" @@ -164,6 +200,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "concurrent-queue" version = "2.1.0" @@ -179,6 +221,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "criterion" version = "0.4.0" @@ -278,6 +329,12 @@ dependencies = [ "typenum", ] +[[package]] +name = "data-url" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d7439c3735f405729d52c3fbbe4de140eaf938a1fe47d227c27f8254d4302a5" + [[package]] name = "derive_more" version = "0.99.17" @@ -356,9 +413,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "expander" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" dependencies = [ "blake2", "fs-err", @@ -366,12 +423,59 @@ dependencies = [ "quote", ] +[[package]] +name = "fdeflate" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +dependencies = [ + "simd-adler32", +] + [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + +[[package]] +name = "fontconfig-parser" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ab2e12762761366dcb876ab8b6e0cfa4797ddcd890575919f008b5ba655672a" +dependencies = [ + "roxmltree", +] + +[[package]] +name = "fontdb" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237ff9f0813bbfc9de836016472e0c9ae7802f174a51594607e5f4ff334cb2f5" +dependencies = [ + "fontconfig-parser", + "log", + "memmap2", + "slotmap", + "ttf-parser", +] + [[package]] name = "fs-err" version = "2.8.1" @@ -484,6 +588,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "gif" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "glob" version = "0.3.0" @@ -517,6 +631,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "imagesize" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b72ad49b554c1728b1e83254a1b1565aea4161e28dabbfa171fc15fe62299caf" + [[package]] name = "indexmap" version = "1.9.1" @@ -542,6 +662,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +[[package]] +name = "jpeg-decoder" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" + [[package]] name = "js-sys" version = "0.3.61" @@ -551,6 +677,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kurbo" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd85a5776cd9500c2e2059c8c76c3b01528566b7fcbaf8098b55a33fc298849b" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "layout-rs" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1164ef87cb9607c2d887216eca79f0fc92895affe1789bba805dd38d829584e0" +dependencies = [ + "log", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -578,6 +722,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -587,6 +740,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", + "simd-adler32", +] + [[package]] name = "nanorand" version = "0.7.0" @@ -646,15 +809,20 @@ dependencies = [ name = "orchestra-proc-macro" version = "0.2.1" dependencies = [ + "anyhow", "assert_matches", "expander", + "fs-err", "indexmap", "itertools", + "layout-rs", "orchestra", "petgraph", + "png", "proc-macro-crate", "proc-macro2", "quote", + "resvg", "syn", "thiserror", "tracing", @@ -676,6 +844,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project" version = "1.0.12" @@ -736,6 +910,19 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "png" +version = "0.17.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" +dependencies = [ + "bitflags", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + [[package]] name = "prioritized-metered-channel" version = "0.4.0" @@ -805,6 +992,12 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "rctree" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f" + [[package]] name = "regex" version = "1.6.0" @@ -822,6 +1015,55 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +[[package]] +name = "resvg" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142e83d8ae8c8c639f304698a5567b229ba65caba867bf4387bbc0ae158827cf" +dependencies = [ + "gif", + "jpeg-decoder", + "log", + "pico-args", + "png", + "rgb", + "svgfilters", + "svgtypes", + "tiny-skia", + "usvg", +] + +[[package]] +name = "rgb" +version = "0.8.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20ec2d3e3fc7a92ced357df9cebd5a10b6fb2aa1ee797bf7e9ce2f17dffc8f59" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "rosvgtree" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad747e7384940e7bf33b15ba433b7bad9f44c0c6d5287a67c2cb22cd1743d497" +dependencies = [ + "log", + "roxmltree", + "simplecss", + "siphasher", + "svgtypes", +] + +[[package]] +name = "roxmltree" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8f595a457b6b8c6cda66a48503e92ee8d19342f905948f29c383200ec9eb1d8" +dependencies = [ + "xmlparser", +] + [[package]] name = "rustc_version" version = "0.4.0" @@ -837,6 +1079,22 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +[[package]] +name = "rustybuzz" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162bdf42e261bee271b3957691018634488084ef577dddeb6420a9684cab2a6a" +dependencies = [ + "bitflags", + "bytemuck", + "smallvec", + "ttf-parser", + "unicode-bidi-mirroring", + "unicode-ccc", + "unicode-general-category", + "unicode-script", +] + [[package]] name = "ryu" version = "1.0.11" @@ -895,6 +1153,27 @@ dependencies = [ "serde", ] +[[package]] +name = "simd-adler32" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" + +[[package]] +name = "simplecss" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a11be7c62927d9427e9f40f3444d5499d868648e2edbc4e2116de69e7ec0e89d" +dependencies = [ + "log", +] + +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + [[package]] name = "slab" version = "0.4.7" @@ -904,12 +1183,56 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slotmap" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] + [[package]] name = "subtle" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +[[package]] +name = "svgfilters" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639abcebc15fdc2df179f37d6f5463d660c1c79cd552c12343a4600827a04bce" +dependencies = [ + "float-cmp", + "rgb", +] + +[[package]] +name = "svgtypes" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed4b0611e7f3277f68c0fa18e385d9e2d26923691379690039548f867cef02a7" +dependencies = [ + "kurbo", + "siphasher", +] + [[package]] name = "syn" version = "1.0.109" @@ -956,6 +1279,32 @@ dependencies = [ "syn", ] +[[package]] +name = "tiny-skia" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2986c82f77818c7b9144c70818fdde98db15308e329ae2f7204d767808fd3c" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "png", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7acb0ccda1ac91084353a56d0b69b0e29c311fd809d2088b1ed2f9ae1841c47" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -1023,18 +1372,120 @@ dependencies = [ "toml", ] +[[package]] +name = "ttf-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0609f771ad9c6155384897e1df4d948e692667cc0588548b68eb44d052b27633" + [[package]] name = "typenum" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-bidi-mirroring" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d12260fb92d52f9008be7e4bca09f584780eb2266dc8fecc6a192bec561694" + +[[package]] +name = "unicode-ccc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2520efa644f8268dce4dcd3050eaa7fc044fca03961e9998ac7e2e92b77cf1" + +[[package]] +name = "unicode-general-category" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2281c8c1d221438e373249e065ca4989c4c36952c211ff21a0ee91c44a3869e7" + [[package]] name = "unicode-ident" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +[[package]] +name = "unicode-script" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d817255e1bed6dfd4ca47258685d14d2bdcfbc64fdc9e3819bd5848057b8ecc" + +[[package]] +name = "unicode-vo" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" + +[[package]] +name = "usvg" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b44e14b7678bcc5947b397991432d0c4e02a103958a0ed5e1b9b961ddd08b21" +dependencies = [ + "base64", + "log", + "pico-args", + "usvg-parser", + "usvg-text-layout", + "usvg-tree", + "xmlwriter", +] + +[[package]] +name = "usvg-parser" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90c8251d965c2882a636ffcc054340b1f13a6bce68779cb5b2084d8ffc2535be" +dependencies = [ + "data-url", + "flate2", + "imagesize", + "kurbo", + "log", + "rosvgtree", + "strict-num", + "svgtypes", + "usvg-tree", +] + +[[package]] +name = "usvg-text-layout" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c4fed019d1af07bfe0f3bac13d120d7b51bc65b38cb24809cf4ed0b8b631138" +dependencies = [ + "fontdb", + "kurbo", + "log", + "rustybuzz", + "unicode-bidi", + "unicode-script", + "unicode-vo", + "usvg-tree", +] + +[[package]] +name = "usvg-tree" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7371265c467cdae0ccc3655e2e3f310c695fb9f717c0d25187bf3b333f7b5159" +dependencies = [ + "kurbo", + "rctree", + "strict-num", + "svgtypes", +] + [[package]] name = "version_check" version = "0.9.4" @@ -1121,6 +1572,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + [[package]] name = "winapi" version = "0.3.9" @@ -1151,3 +1608,15 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "xmlparser" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" + +[[package]] +name = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" diff --git a/orchestra/proc-macro/Cargo.toml b/orchestra/proc-macro/Cargo.toml index 2f47635..f9b7a8c 100644 --- a/orchestra/proc-macro/Cargo.toml +++ b/orchestra/proc-macro/Cargo.toml @@ -26,7 +26,7 @@ indexmap = "1" dotlay = { package = "layout-rs", version = "0.1.1", features = [ "log", ], optional = true } -resvg = { version = "0.28", optional = true } +resvg = { version = "0.32", optional = true } png = { version = "0.17", optional = true } fs-err = { version = "2", optional = true } anyhow = { version = "1", optional = true } diff --git a/orchestra/proc-macro/src/graph.rs b/orchestra/proc-macro/src/graph.rs index a6d33ab..33e1e5d 100644 --- a/orchestra/proc-macro/src/graph.rs +++ b/orchestra/proc-macro/src/graph.rs @@ -212,12 +212,12 @@ node [colorscheme={}] let png_content = { use resvg::{render, tiny_skia::Pixmap, usvg}; - let rtree = usvg::Tree::from_data(svg_content.as_bytes(), &usvg::Options::default())?; + let rtree = usvg::Tree::from_str(&svg_content, &usvg::Options::default())?; let mut pixi = Pixmap::new(rtree.size.width() as u32, rtree.size.height() as u32).unwrap(); render( &rtree, - usvg::FitTo::Original, + resvg::FitTo::Original, resvg::tiny_skia::Transform::default(), pixi.as_mut(), ) From 780b92d76e1c59ee2e9ec4fb8bace3368e4fdec8 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 5 Jul 2023 11:55:51 +0200 Subject: [PATCH 3/8] chore/deps: bump Signed-off-by: Bernhard Schuster --- orchestra/proc-macro/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orchestra/proc-macro/Cargo.toml b/orchestra/proc-macro/Cargo.toml index f9b7a8c..21afe3c 100644 --- a/orchestra/proc-macro/Cargo.toml +++ b/orchestra/proc-macro/Cargo.toml @@ -21,8 +21,8 @@ proc-macro2 = { version = "1.0.47", features = ["span-locations"] } proc-macro-crate = "1.1.3" expander = { version = "2.0.0", default-features = false } petgraph = "0.6.0" -itertools = { version = "0.10.3" } -indexmap = "1" +itertools = { version = "0.11" } +indexmap = "2" dotlay = { package = "layout-rs", version = "0.1.1", features = [ "log", ], optional = true } From 774da4bcce7a8267b838f985bdeb747408cb21d9 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 5 Jul 2023 11:56:29 +0200 Subject: [PATCH 4/8] feat/dotgraph: feature gate png generation PNGs generated lack text, and hence are broken until the upstream crates resolve the issue. Signed-off-by: Bernhard Schuster --- Cargo.lock | 143 +++++++++++------- orchestra/proc-macro/Cargo.toml | 14 +- orchestra/proc-macro/src/graph.rs | 46 ++++-- .../src/impl_subsystem_ctx_sender.rs | 5 +- 4 files changed, 129 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7d068d..ed09c84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,7 +175,7 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "bitflags", "clap_lex", - "indexmap", + "indexmap 1.9.1", "textwrap", ] @@ -242,7 +242,7 @@ dependencies = [ "ciborium", "clap", "criterion-plot", - "itertools", + "itertools 0.10.5", "lazy_static", "num-traits", "oorandom", @@ -263,7 +263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -405,6 +405,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "event-listener" version = "2.5.3" @@ -465,15 +471,16 @@ dependencies = [ [[package]] name = "fontdb" -version = "0.13.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237ff9f0813bbfc9de836016472e0c9ae7802f174a51594607e5f4ff334cb2f5" +checksum = "af8d8cbea8f21307d7e84bca254772981296f058a1d36b461bf4d83a7499fc9e" dependencies = [ "fontconfig-parser", "log", "memmap2", "slotmap", - "ttf-parser", + "tinyvec", + "ttf-parser 0.19.1", ] [[package]] @@ -616,6 +623,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -633,9 +646,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "imagesize" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72ad49b554c1728b1e83254a1b1565aea4161e28dabbfa171fc15fe62299caf" +checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" [[package]] name = "indexmap" @@ -644,7 +657,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", ] [[package]] @@ -656,6 +679,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.3" @@ -724,9 +756,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" -version = "0.5.10" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872" dependencies = [ "libc", ] @@ -813,12 +845,11 @@ dependencies = [ "assert_matches", "expander", "fs-err", - "indexmap", - "itertools", + "indexmap 2.0.0", + "itertools 0.11.0", "layout-rs", "orchestra", "petgraph", - "png", "proc-macro-crate", "proc-macro2", "quote", @@ -841,7 +872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.1", ] [[package]] @@ -1017,9 +1048,9 @@ checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "resvg" -version = "0.32.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142e83d8ae8c8c639f304698a5567b229ba65caba867bf4387bbc0ae158827cf" +checksum = "b6554f47c38eca56827eea7f285c2a3018b4e12e0e195cc105833c008be338f1" dependencies = [ "gif", "jpeg-decoder", @@ -1027,7 +1058,6 @@ dependencies = [ "pico-args", "png", "rgb", - "svgfilters", "svgtypes", "tiny-skia", "usvg", @@ -1042,19 +1072,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "rosvgtree" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad747e7384940e7bf33b15ba433b7bad9f44c0c6d5287a67c2cb22cd1743d497" -dependencies = [ - "log", - "roxmltree", - "simplecss", - "siphasher", - "svgtypes", -] - [[package]] name = "roxmltree" version = "0.18.0" @@ -1088,7 +1105,7 @@ dependencies = [ "bitflags", "bytemuck", "smallvec", - "ttf-parser", + "ttf-parser 0.18.1", "unicode-bidi-mirroring", "unicode-ccc", "unicode-general-category", @@ -1213,16 +1230,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" -[[package]] -name = "svgfilters" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639abcebc15fdc2df179f37d6f5463d660c1c79cd552c12343a4600827a04bce" -dependencies = [ - "float-cmp", - "rgb", -] - [[package]] name = "svgtypes" version = "0.11.0" @@ -1281,9 +1288,9 @@ dependencies = [ [[package]] name = "tiny-skia" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce2986c82f77818c7b9144c70818fdde98db15308e329ae2f7204d767808fd3c" +checksum = "7db11798945fa5c3e5490c794ccca7c6de86d3afdd54b4eb324109939c6f37bc" dependencies = [ "arrayref", "arrayvec", @@ -1296,9 +1303,9 @@ dependencies = [ [[package]] name = "tiny-skia-path" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7acb0ccda1ac91084353a56d0b69b0e29c311fd809d2088b1ed2f9ae1841c47" +checksum = "2f60aa35c89ac2687ace1a2556eaaea68e8c0d47408a2e3e7f5c98a489e7281c" dependencies = [ "arrayref", "bytemuck", @@ -1315,6 +1322,21 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "toml" version = "0.5.9" @@ -1378,6 +1400,12 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0609f771ad9c6155384897e1df4d948e692667cc0588548b68eb44d052b27633" +[[package]] +name = "ttf-parser" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33" + [[package]] name = "typenum" version = "1.15.0" @@ -1428,9 +1456,9 @@ checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" [[package]] name = "usvg" -version = "0.32.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b44e14b7678bcc5947b397991432d0c4e02a103958a0ed5e1b9b961ddd08b21" +checksum = "14d09ddfb0d93bf84824c09336d32e42f80961a9d1680832eb24fdf249ce11e6" dependencies = [ "base64", "log", @@ -1443,26 +1471,27 @@ dependencies = [ [[package]] name = "usvg-parser" -version = "0.32.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90c8251d965c2882a636ffcc054340b1f13a6bce68779cb5b2084d8ffc2535be" +checksum = "d19bf93d230813599927d88557014e0908ecc3531666d47c634c6838bc8db408" dependencies = [ "data-url", "flate2", "imagesize", "kurbo", "log", - "rosvgtree", - "strict-num", + "roxmltree", + "simplecss", + "siphasher", "svgtypes", "usvg-tree", ] [[package]] name = "usvg-text-layout" -version = "0.32.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c4fed019d1af07bfe0f3bac13d120d7b51bc65b38cb24809cf4ed0b8b631138" +checksum = "035044604e89652c0a2959b8b356946997a52649ba6cade45928c2842376feb4" dependencies = [ "fontdb", "kurbo", @@ -1476,14 +1505,14 @@ dependencies = [ [[package]] name = "usvg-tree" -version = "0.32.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7371265c467cdae0ccc3655e2e3f310c695fb9f717c0d25187bf3b333f7b5159" +checksum = "7939a7e4ed21cadb5d311d6339730681c3e24c3e81d60065be80e485d3fc8b92" dependencies = [ - "kurbo", "rctree", "strict-num", "svgtypes", + "tiny-skia-path", ] [[package]] diff --git a/orchestra/proc-macro/Cargo.toml b/orchestra/proc-macro/Cargo.toml index 21afe3c..b90f4dc 100644 --- a/orchestra/proc-macro/Cargo.toml +++ b/orchestra/proc-macro/Cargo.toml @@ -26,8 +26,7 @@ indexmap = "2" dotlay = { package = "layout-rs", version = "0.1.1", features = [ "log", ], optional = true } -resvg = { version = "0.32", optional = true } -png = { version = "0.17", optional = true } +resvg = { version = "0.35", optional = true } fs-err = { version = "2", optional = true } anyhow = { version = "1", optional = true } @@ -38,14 +37,19 @@ thiserror = "1" tracing = "0.1" [features] -default = [ -] # enable "dotgraph" by default, blocked by +default = ["dotgraph"] +# enable "dotgraph" by default, blocked by # write the expanded version to a `orchestra-expansion.[a-f0-9]{10}.rs` # in the `OUT_DIR` as defined by `cargo` for the `expander` crate. expand = [] # Create directional message consuming / outgoing graph. # Generates: `${OUT_DIR}/${orchestra|lowercase}-subsystem-messaging.dot` -dotgraph = ["dotlay", "anyhow", "png", "fs-err", "resvg"] +dotgraph = ["dotlay", "anyhow", "fs-err"] +# tiny skia does not support text rendering, the output graphs will NOT have any text +# and will remain rather useless for the time being, hence feature gated tl;dr `cosmic-text` might be a solution in the future +# +dotgraph-broken-png = ["dotgraph", "resvg"] + # Creates a compile error if unconsumed messages are encountered deny_unconsumed_messages = [] # Creates a compile error if unsent messages are encountered diff --git a/orchestra/proc-macro/src/graph.rs b/orchestra/proc-macro/src/graph.rs index 33e1e5d..870620b 100644 --- a/orchestra/proc-macro/src/graph.rs +++ b/orchestra/proc-macro/src/graph.rs @@ -188,6 +188,9 @@ impl<'a> ConnectionGraph<'a> { let dot_content = format!( r#"digraph {{ + fontname="Cantarell" + bgcolor="white" + label = "orchestra message flow between subsystems" node [colorscheme={}] {:?} }}"#, @@ -200,33 +203,48 @@ node [colorscheme={}] let svg_content = { let mut parser = dotlay::gv::DotParser::new(dot_content.as_str()); - let graph = parser.process().map_err(|err_msg| anyhow::anyhow!(err_msg))?; + let graph = parser.process().map_err(|err_msg| { + anyhow::anyhow!(dbg!(err_msg)).context("Failed to parse dotfile") + })?; let mut svg = dotlay::backends::svg::SVGWriter::new(); let mut builder = dotlay::gv::GraphBuilder::default(); builder.visit_graph(&graph); let mut vg = builder.get(); - vg.do_it(true, false, false, &mut svg); + vg.do_it(false, false, false, &mut svg); svg.finalize() }; + // tiny skia does not support text rendering, tl;dr `cosmic-text` might be a solution in the future + // https://github.com/RazrFalcon/tiny-skia/issues/1 + #[cfg(feature = "dotgraph-broken-png")] let png_content = { - use resvg::{render, tiny_skia::Pixmap, usvg}; + use resvg::{tiny_skia::Pixmap, usvg, Tree}; + use usvg::TreeParsing; - let rtree = usvg::Tree::from_str(&svg_content, &usvg::Options::default())?; + let tree = usvg::Tree::from_data(&svg_content.as_bytes(), &usvg::Options::default())?; + let rtree = Tree::from_usvg(&tree); let mut pixi = Pixmap::new(rtree.size.width() as u32, rtree.size.height() as u32).unwrap(); - render( - &rtree, - resvg::FitTo::Original, - resvg::tiny_skia::Transform::default(), - pixi.as_mut(), - ) - .ok_or_else(|| anyhow::anyhow!("Failed to render svg to png"))?; + rtree.render(resvg::tiny_skia::Transform::default(), &mut pixi.as_mut()); pixi.encode_png()? }; - fs::write(dest.with_extension("dot"), dot_content)?; - fs::write(dest.with_extension("svg"), svg_content.as_bytes())?; - fs::write(dest.with_extension("png"), png_content)?; + + fn write_to_disk( + dest: impl AsRef, + ext: &str, + content: impl AsRef<[u8]>, + ) -> std::io::Result<()> { + let dest = dest.as_ref().with_extension(ext); + print!("Writing {} to {} ..", ext, dest.display()); + fs::write(dest, content.as_ref())?; + println!(" OK"); + Ok(()) + } + + write_to_disk(&dest, "dot", &dot_content)?; + write_to_disk(&dest, "svg", &svg_content)?; + #[cfg(feature = "dotgraph-broken-png")] + write_to_disk(&dest, "png", &png_content)?; Ok(()) } diff --git a/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs b/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs index 42379df..22095bc 100644 --- a/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs +++ b/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs @@ -94,9 +94,8 @@ pub(crate) fn impl_subsystem_types_all(info: &OrchestraInfo) -> Result Date: Wed, 5 Jul 2023 11:57:26 +0200 Subject: [PATCH 5/8] feat/lint: enforce dependency related lints Signed-off-by: Bernhard Schuster --- Cargo.lock | 3 --- orchestra/proc-macro/Cargo.toml | 3 --- orchestra/proc-macro/src/lib.rs | 3 +++ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed09c84..e3bd13c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -848,15 +848,12 @@ dependencies = [ "indexmap 2.0.0", "itertools 0.11.0", "layout-rs", - "orchestra", "petgraph", "proc-macro-crate", "proc-macro2", "quote", "resvg", "syn", - "thiserror", - "tracing", ] [[package]] diff --git a/orchestra/proc-macro/Cargo.toml b/orchestra/proc-macro/Cargo.toml index b90f4dc..58f54a2 100644 --- a/orchestra/proc-macro/Cargo.toml +++ b/orchestra/proc-macro/Cargo.toml @@ -32,9 +32,6 @@ anyhow = { version = "1", optional = true } [dev-dependencies] assert_matches = "1.5" -orchestra = { path = "../" } -thiserror = "1" -tracing = "0.1" [features] default = ["dotgraph"] diff --git a/orchestra/proc-macro/src/lib.rs b/orchestra/proc-macro/src/lib.rs index 6b21f8b..89b5e6a 100644 --- a/orchestra/proc-macro/src/lib.rs +++ b/orchestra/proc-macro/src/lib.rs @@ -13,6 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. #![allow(clippy::all)] +#![deny(unused_crate_dependencies)] +#![deny(unused_imports)] +#![deny(unused_import_braces)] use proc_macro2::{Ident, Span, TokenStream}; use syn::{parse_quote, spanned::Spanned, Path}; From 95c21fdbe38d58f2d19e1d5c8b147d45245ec4fb Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 5 Jul 2023 13:05:24 +0200 Subject: [PATCH 6/8] chore: fmt From 12f262e11c24b3ec8977485f951ef7ea30581f7a Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 5 Jul 2023 13:19:56 +0200 Subject: [PATCH 7/8] chore: disable feature dotgraph by default, avoid breaking polkadot CI --- orchestra/proc-macro/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchestra/proc-macro/Cargo.toml b/orchestra/proc-macro/Cargo.toml index 58f54a2..77c73ae 100644 --- a/orchestra/proc-macro/Cargo.toml +++ b/orchestra/proc-macro/Cargo.toml @@ -34,7 +34,7 @@ anyhow = { version = "1", optional = true } assert_matches = "1.5" [features] -default = ["dotgraph"] +default = [] # enable "dotgraph" by default, blocked by # write the expanded version to a `orchestra-expansion.[a-f0-9]{10}.rs` # in the `OUT_DIR` as defined by `cargo` for the `expander` crate. From 483a19d0f516330655bd7552fd0c7c497d28b21f Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 12 Jul 2023 10:25:31 +0200 Subject: [PATCH 8/8] remove: png generation is broken and adds quite a bit of deps and complexity --- Cargo.lock | 449 ------------------------------ README.md | 2 + orchestra/Cargo.toml | 3 +- orchestra/proc-macro/Cargo.toml | 5 - orchestra/proc-macro/src/graph.rs | 17 -- 5 files changed, 4 insertions(+), 472 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e3bd13c..3c69fb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "aho-corasick" version = "0.7.19" @@ -29,18 +23,6 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "assert_matches" version = "1.5.0" @@ -86,12 +68,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base64" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" - [[package]] name = "bitflags" version = "1.3.2" @@ -122,12 +98,6 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" -[[package]] -name = "bytemuck" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" - [[package]] name = "cast" version = "0.3.0" @@ -200,12 +170,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "concurrent-queue" version = "2.1.0" @@ -221,15 +185,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - [[package]] name = "criterion" version = "0.4.0" @@ -329,12 +284,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "data-url" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d7439c3735f405729d52c3fbbe4de140eaf938a1fe47d227c27f8254d4302a5" - [[package]] name = "derive_more" version = "0.99.17" @@ -429,60 +378,12 @@ dependencies = [ "quote", ] -[[package]] -name = "fdeflate" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" -dependencies = [ - "simd-adler32", -] - [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" -[[package]] -name = "flate2" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "float-cmp" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" - -[[package]] -name = "fontconfig-parser" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab2e12762761366dcb876ab8b6e0cfa4797ddcd890575919f008b5ba655672a" -dependencies = [ - "roxmltree", -] - -[[package]] -name = "fontdb" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8d8cbea8f21307d7e84bca254772981296f058a1d36b461bf4d83a7499fc9e" -dependencies = [ - "fontconfig-parser", - "log", - "memmap2", - "slotmap", - "tinyvec", - "ttf-parser 0.19.1", -] - [[package]] name = "fs-err" version = "2.8.1" @@ -595,16 +496,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "gif" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" -dependencies = [ - "color_quant", - "weezl", -] - [[package]] name = "glob" version = "0.3.0" @@ -644,12 +535,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "imagesize" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" - [[package]] name = "indexmap" version = "1.9.1" @@ -694,12 +579,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" -[[package]] -name = "jpeg-decoder" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" - [[package]] name = "js-sys" version = "0.3.61" @@ -709,15 +588,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "kurbo" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd85a5776cd9500c2e2059c8c76c3b01528566b7fcbaf8098b55a33fc298849b" -dependencies = [ - "arrayvec", -] - [[package]] name = "layout-rs" version = "0.1.1" @@ -754,15 +624,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memmap2" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872" -dependencies = [ - "libc", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -772,16 +633,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", - "simd-adler32", -] - [[package]] name = "nanorand" version = "0.7.0" @@ -852,7 +703,6 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "resvg", "syn", ] @@ -872,12 +722,6 @@ dependencies = [ "indexmap 1.9.1", ] -[[package]] -name = "pico-args" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" - [[package]] name = "pin-project" version = "1.0.12" @@ -938,19 +782,6 @@ dependencies = [ "plotters-backend", ] -[[package]] -name = "png" -version = "0.17.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" -dependencies = [ - "bitflags", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide", -] - [[package]] name = "prioritized-metered-channel" version = "0.4.0" @@ -1020,12 +851,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "rctree" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f" - [[package]] name = "regex" version = "1.6.0" @@ -1043,41 +868,6 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" -[[package]] -name = "resvg" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6554f47c38eca56827eea7f285c2a3018b4e12e0e195cc105833c008be338f1" -dependencies = [ - "gif", - "jpeg-decoder", - "log", - "pico-args", - "png", - "rgb", - "svgtypes", - "tiny-skia", - "usvg", -] - -[[package]] -name = "rgb" -version = "0.8.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ec2d3e3fc7a92ced357df9cebd5a10b6fb2aa1ee797bf7e9ce2f17dffc8f59" -dependencies = [ - "bytemuck", -] - -[[package]] -name = "roxmltree" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f595a457b6b8c6cda66a48503e92ee8d19342f905948f29c383200ec9eb1d8" -dependencies = [ - "xmlparser", -] - [[package]] name = "rustc_version" version = "0.4.0" @@ -1093,22 +883,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" -[[package]] -name = "rustybuzz" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162bdf42e261bee271b3957691018634488084ef577dddeb6420a9684cab2a6a" -dependencies = [ - "bitflags", - "bytemuck", - "smallvec", - "ttf-parser 0.18.1", - "unicode-bidi-mirroring", - "unicode-ccc", - "unicode-general-category", - "unicode-script", -] - [[package]] name = "ryu" version = "1.0.11" @@ -1167,27 +941,6 @@ dependencies = [ "serde", ] -[[package]] -name = "simd-adler32" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" - -[[package]] -name = "simplecss" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a11be7c62927d9427e9f40f3444d5499d868648e2edbc4e2116de69e7ec0e89d" -dependencies = [ - "log", -] - -[[package]] -name = "siphasher" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" - [[package]] name = "slab" version = "0.4.7" @@ -1197,46 +950,12 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slotmap" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" -dependencies = [ - "version_check", -] - -[[package]] -name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - -[[package]] -name = "strict-num" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" -dependencies = [ - "float-cmp", -] - [[package]] name = "subtle" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" -[[package]] -name = "svgtypes" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed4b0611e7f3277f68c0fa18e385d9e2d26923691379690039548f867cef02a7" -dependencies = [ - "kurbo", - "siphasher", -] - [[package]] name = "syn" version = "1.0.109" @@ -1283,32 +1002,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tiny-skia" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7db11798945fa5c3e5490c794ccca7c6de86d3afdd54b4eb324109939c6f37bc" -dependencies = [ - "arrayref", - "arrayvec", - "bytemuck", - "cfg-if", - "log", - "png", - "tiny-skia-path", -] - -[[package]] -name = "tiny-skia-path" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f60aa35c89ac2687ace1a2556eaaea68e8c0d47408a2e3e7f5c98a489e7281c" -dependencies = [ - "arrayref", - "bytemuck", - "strict-num", -] - [[package]] name = "tinytemplate" version = "1.2.1" @@ -1319,21 +1012,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "toml" version = "0.5.9" @@ -1391,127 +1069,18 @@ dependencies = [ "toml", ] -[[package]] -name = "ttf-parser" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0609f771ad9c6155384897e1df4d948e692667cc0588548b68eb44d052b27633" - -[[package]] -name = "ttf-parser" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33" - [[package]] name = "typenum" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - -[[package]] -name = "unicode-bidi-mirroring" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d12260fb92d52f9008be7e4bca09f584780eb2266dc8fecc6a192bec561694" - -[[package]] -name = "unicode-ccc" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2520efa644f8268dce4dcd3050eaa7fc044fca03961e9998ac7e2e92b77cf1" - -[[package]] -name = "unicode-general-category" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2281c8c1d221438e373249e065ca4989c4c36952c211ff21a0ee91c44a3869e7" - [[package]] name = "unicode-ident" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" -[[package]] -name = "unicode-script" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d817255e1bed6dfd4ca47258685d14d2bdcfbc64fdc9e3819bd5848057b8ecc" - -[[package]] -name = "unicode-vo" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" - -[[package]] -name = "usvg" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d09ddfb0d93bf84824c09336d32e42f80961a9d1680832eb24fdf249ce11e6" -dependencies = [ - "base64", - "log", - "pico-args", - "usvg-parser", - "usvg-text-layout", - "usvg-tree", - "xmlwriter", -] - -[[package]] -name = "usvg-parser" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19bf93d230813599927d88557014e0908ecc3531666d47c634c6838bc8db408" -dependencies = [ - "data-url", - "flate2", - "imagesize", - "kurbo", - "log", - "roxmltree", - "simplecss", - "siphasher", - "svgtypes", - "usvg-tree", -] - -[[package]] -name = "usvg-text-layout" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "035044604e89652c0a2959b8b356946997a52649ba6cade45928c2842376feb4" -dependencies = [ - "fontdb", - "kurbo", - "log", - "rustybuzz", - "unicode-bidi", - "unicode-script", - "unicode-vo", - "usvg-tree", -] - -[[package]] -name = "usvg-tree" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7939a7e4ed21cadb5d311d6339730681c3e24c3e81d60065be80e485d3fc8b92" -dependencies = [ - "rctree", - "strict-num", - "svgtypes", - "tiny-skia-path", -] - [[package]] name = "version_check" version = "0.9.4" @@ -1598,12 +1167,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "weezl" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" - [[package]] name = "winapi" version = "0.3.9" @@ -1634,15 +1197,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "xmlparser" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" - -[[package]] -name = "xmlwriter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" diff --git a/README.md b/README.md index 5febcda..3fdc551 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,8 @@ The path to the generated file will be displayed and is of the form `${OUT_DIR}/${orchestra|lowercase}-subsystem-messaging.dot`. Use `dot -Tpng ${OUT_DIR}/${orchestra|lowercase}-subsystem-messaging.dot > connectivity.dot` to convert to i.e. a `png` image or use your favorite dot file viewer. +It also creates a `.svg` alongside the `.dot` graph, derived from the `.dot` graph for +direct usage. ## Caveats diff --git a/orchestra/Cargo.toml b/orchestra/Cargo.toml index b38296a..d49defb 100644 --- a/orchestra/Cargo.toml +++ b/orchestra/Cargo.toml @@ -45,7 +45,8 @@ default = ["deny_unconsumed_messages", "deny_unsent_messages"] expand = ["orchestra-proc-macro/expand"] # Generate a connectivity graph in dot-graph form. # Generated file: `${OUT_DIR}/${orchestra|lowercase}-subsystem-messaging.dot` -# Use with `dot $path/to/dot.file -Tpng > connection.graph` +# Use with `dot $path/to/dot.file -Tpng > connection.graph` or use +# the generated `*.svg` file directly. # or use a dot-graph viewer of your choice. dotgraph = ["orchestra-proc-macro/dotgraph"] # Creates a compile error if unconsumed messages are encountered diff --git a/orchestra/proc-macro/Cargo.toml b/orchestra/proc-macro/Cargo.toml index 77c73ae..d338b4a 100644 --- a/orchestra/proc-macro/Cargo.toml +++ b/orchestra/proc-macro/Cargo.toml @@ -26,7 +26,6 @@ indexmap = "2" dotlay = { package = "layout-rs", version = "0.1.1", features = [ "log", ], optional = true } -resvg = { version = "0.35", optional = true } fs-err = { version = "2", optional = true } anyhow = { version = "1", optional = true } @@ -42,10 +41,6 @@ expand = [] # Create directional message consuming / outgoing graph. # Generates: `${OUT_DIR}/${orchestra|lowercase}-subsystem-messaging.dot` dotgraph = ["dotlay", "anyhow", "fs-err"] -# tiny skia does not support text rendering, the output graphs will NOT have any text -# and will remain rather useless for the time being, hence feature gated tl;dr `cosmic-text` might be a solution in the future -# -dotgraph-broken-png = ["dotgraph", "resvg"] # Creates a compile error if unconsumed messages are encountered deny_unconsumed_messages = [] diff --git a/orchestra/proc-macro/src/graph.rs b/orchestra/proc-macro/src/graph.rs index 870620b..9cad334 100644 --- a/orchestra/proc-macro/src/graph.rs +++ b/orchestra/proc-macro/src/graph.rs @@ -214,21 +214,6 @@ node [colorscheme={}] svg.finalize() }; - // tiny skia does not support text rendering, tl;dr `cosmic-text` might be a solution in the future - // https://github.com/RazrFalcon/tiny-skia/issues/1 - #[cfg(feature = "dotgraph-broken-png")] - let png_content = { - use resvg::{tiny_skia::Pixmap, usvg, Tree}; - use usvg::TreeParsing; - - let tree = usvg::Tree::from_data(&svg_content.as_bytes(), &usvg::Options::default())?; - let rtree = Tree::from_usvg(&tree); - let mut pixi = - Pixmap::new(rtree.size.width() as u32, rtree.size.height() as u32).unwrap(); - rtree.render(resvg::tiny_skia::Transform::default(), &mut pixi.as_mut()); - pixi.encode_png()? - }; - fn write_to_disk( dest: impl AsRef, ext: &str, @@ -243,8 +228,6 @@ node [colorscheme={}] write_to_disk(&dest, "dot", &dot_content)?; write_to_disk(&dest, "svg", &svg_content)?; - #[cfg(feature = "dotgraph-broken-png")] - write_to_disk(&dest, "png", &png_content)?; Ok(()) }