Skip to content

Commit 4ee0d50

Browse files
committed
Specify dot-png and dot-svg to automatically convert dot files to images
1 parent 0fa64c2 commit 4ee0d50

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

docs/debug.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ These are optional paths that can be enabled at commandline. They allow for a mo
2424
| `--debug dot-latency-problem` | Dot debug the problem graph for latency counting in `solve_latencies_problem.dot` |
2525
| `--debug dot-latency-solution` | Dot debug the solution graph for latency counting in `solve_latencies_solution.dot` |
2626
| `--debug dot-latency-infer` | Dot debug the problem graph for latency inference in `latency_inference_problem.dot` |
27+
| `--debug dot-png` | Use `dot -Tpng` to create a png file from generated dot files (Can be surprisingly slow, prefer svg) |
28+
| `--debug dot-svg` | Use `dot -Tsvg` to create a svg file from generated dot files |
2729
| `--debug lsp-debug` | Instead of regular LSP hover info, provide raw debug info |
2830
| `--debug TEST` | Temporary marker for debugging |
2931

src/dev_aid/dot_graphs.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ fn unique_file_name(
3535
Ok((file, path))
3636
}
3737

38-
fn try_convert_dot_to_image(dot_path: &std::path::Path) {
39-
let output_path = dot_path.with_extension("svg");
38+
fn dot_command(dot_path: &std::path::Path, file_name: &str) {
39+
let output_path = dot_path.with_extension(file_name);
4040
match std::process::Command::new("dot")
41-
.arg("-Tsvg")
41+
.arg(format!("-T{file_name}"))
4242
.arg(dot_path)
4343
.arg("-o")
4444
.arg(&output_path)
@@ -62,6 +62,15 @@ fn try_convert_dot_to_image(dot_path: &std::path::Path) {
6262
}
6363
}
6464

65+
fn try_convert_dot_to_image(dot_path: &std::path::Path) {
66+
if crate::debug::is_enabled("dot-svg") {
67+
dot_command(dot_path, "svg");
68+
}
69+
if crate::debug::is_enabled("dot-png") {
70+
dot_command(dot_path, "png");
71+
}
72+
}
73+
6574
pub fn display_generated_hardware_structure(md_instance: &ModuleTypingContext<'_>) {
6675
let (mut file, path) = unique_file_name(&md_instance.name, "hw_structure").unwrap();
6776
write!(file, "{}", custom_render_hardware_structure(md_instance)).unwrap();

0 commit comments

Comments
 (0)