Skip to content

Dev tools abstraction #13582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3050,6 +3050,18 @@ description = "Demonstrates FPS overlay"
category = "Dev tools"
wasm = true

[[example]]
name = "dev_cli"
path = "examples/dev_tools/dev_cli.rs"
doc-scrape-examples = true
required-features = ["bevy_dev_tools"]

[package.metadata.example.dev_cli]
name = "Developer in-game command line interface"
description = "Demonstrates the Bevy Developer CLI with dev tools abstraction"
category = "Dev tools"
wasm = false

[[example]]
name = "visibility_range"
path = "examples/3d/visibility_range.rs"
Expand Down
10 changes: 9 additions & 1 deletion crates/bevy_dev_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
default = ["bevy_ui_debug"]
default = ["bevy_ui_debug", "bevy_cli_dev_tool"]
bevy_ci_testing = ["serde", "ron"]
bevy_ui_debug = []
bevy_cli_dev_tool = ["serde", "ron"]

[dependencies]
# bevy
Expand All @@ -36,10 +37,17 @@ bevy_ui = { path = "../bevy_ui", version = "0.14.0-dev", features = [
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
bevy_window = { path = "../bevy_window", version = "0.14.0-dev" }
bevy_text = { path = "../bevy_text", version = "0.14.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.14.0-dev" }
bevy_state = { path = "../bevy_state", version = "0.14.0-dev" }

# macros
bevy_dev_tools_macros = { path = "macros/", version = "0.14.0-dev" }

# other
serde = { version = "1.0", features = ["derive"], optional = true }
ron = { version = "0.8.0", optional = true }
nom = "7"
rustyline = "14.0.0"

[lints]
workspace = true
Expand Down
17 changes: 17 additions & 0 deletions crates/bevy_dev_tools/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "bevy_dev_tools_macros"
version = "0.14.0-dev"
edition = "2021"
description = "Collection of developer tools for the Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[dependencies]
syn = "1.0"
quote = "1.0"
proc-macro2 = "1.0"

[lib]
proc-macro = true
22 changes: 22 additions & 0 deletions crates/bevy_dev_tools/macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extern crate proc_macro;

use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};

#[proc_macro_derive(DevCommand)]
pub fn dev_command_derive(input: TokenStream) -> TokenStream {
// Parse the input tokens into a syntax tree
let input = parse_macro_input!(input as DeriveInput);

// Get the name of the struct
let name = &input.ident;

// Generate the implementation of DevCommand for the struct
let expanded = quote! {
impl DevCommand for #name {}
};

// Convert the generated code into a TokenStream and return it
TokenStream::from(expanded)
}
Loading
Loading