mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 06:21:31 +11:00
dump_schedule
utility (#300)
## Description Adds the `dump_schedule` crate which is a simple tool that writes valence's schedule graph to a file named ~~`graph.gv`~~ `graph.svg`. ## Test Plan Steps: 1. `cargo r -p dump_schedule` 2. Paste the contents of `graph.gv` to https://edotor.net/ 3. Look at the pretty graph.
This commit is contained in:
parent
628a0ff3c3
commit
1aae22ca3e
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -15,4 +15,4 @@ rust-mc-bot
|
|||
flamegraph*.svg
|
||||
perf.data
|
||||
perf.data.old
|
||||
/graph.gv
|
||||
/graph.svg
|
||||
|
|
8
crates/dump_schedule/Cargo.toml
Normal file
8
crates/dump_schedule/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "dump_schedule"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bevy_mod_debugdump = "0.7.0"
|
||||
valence = { path = "../valence", version = "0.2.0" }
|
7
crates/dump_schedule/README.md
Normal file
7
crates/dump_schedule/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# dump_schedule
|
||||
|
||||
A simple debugging utility for visualizing Valence's main schedule graph. Generates a SVG file.
|
||||
|
||||
1. Ensure that [Graphviz](https://graphviz.org/) is installed and the `dot` command is available.
|
||||
2. Run the program with `cargo r -p dump_schedule`
|
||||
3. Open the generated `graph.svg` in your browser or other program, e.g. `chromium graph.svg`.
|
36
crates/dump_schedule/src/main.rs
Normal file
36
crates/dump_schedule/src/main.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use std::io;
|
||||
use std::io::Write;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use valence::bevy_app::prelude::*;
|
||||
use valence::config::ServerPlugin;
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let mut app = App::new();
|
||||
|
||||
app.add_plugin(ServerPlugin::new(()));
|
||||
|
||||
let dot_graph = bevy_mod_debugdump::schedule_graph_dot(
|
||||
&mut app,
|
||||
CoreSchedule::Main,
|
||||
&bevy_mod_debugdump::schedule_graph::Settings {
|
||||
ambiguity_enable: false,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
|
||||
let mut child = Command::new("dot")
|
||||
.stdin(Stdio::piped())
|
||||
.arg("-Tsvg")
|
||||
.arg("-o")
|
||||
.arg("graph.svg")
|
||||
.spawn()?;
|
||||
|
||||
if let Some(stdin) = child.stdin.as_mut() {
|
||||
stdin.write_all(dot_graph.as_bytes())?;
|
||||
}
|
||||
|
||||
child.wait_with_output()?;
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -12,7 +12,6 @@ build = "build/main.rs"
|
|||
authors = ["Ryan Johnson <ryanj00a@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
#bevy_mod_debugdump = "0.7.0"
|
||||
anyhow = "1.0.65"
|
||||
arrayvec = "0.7.2"
|
||||
async-trait = "0.1.60"
|
||||
|
|
|
@ -339,20 +339,6 @@ pub fn build_plugin(
|
|||
.add_plugin(PlayerListPlugin)
|
||||
.add_plugin(WeatherPlugin);
|
||||
|
||||
/*
|
||||
println!(
|
||||
"{}",
|
||||
bevy_mod_debugdump::schedule_graph_dot(
|
||||
app,
|
||||
CoreSchedule::Main,
|
||||
&bevy_mod_debugdump::schedule_graph::Settings {
|
||||
ambiguity_enable: false,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
);
|
||||
*/
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue