Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ members = [
"crates/bevy_system_reflection",
]
resolver = "2"
exclude = ["crates/bevy_api_gen", "crates/macro_tests", "xtask"]
exclude = ["codegen", "crates/macro_tests", "xtask"]

[profile.dev]
debug = 1
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions crates/bevy_api_gen/Cargo.toml → codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "bevy_api_gen"
name = "bevy_mod_scripting_codegen"
version = "0.6.0"
edition = "2024"
description = "Code generator tool for bevy"
Expand All @@ -15,12 +15,15 @@ include = [
"rust-toolchain.toml",
]

[workspace]
members = []

[[bin]]
name = "cargo-bevy-api-gen"
name = "cargo-bms-codegen"
path = "src/bin/main.rs"

[[bin]]
name = "bevy-api-gen-driver"
name = "bms-codegen-driver"
path = "src/bin/driver.rs"

[profile.ephemeral-build]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/src/args.rs → codegen/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
about,
long_about,
disable_help_flag = true,
bin_name = "cargo bevy-api-gen",
bin_name = "cargo bms-codegen",
arg_required_else_help = true
)]
/// A Cargo plugin which can generate reflection powered wrappers for Bevy types,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(rustc_private)]
use bevy_api_gen::{driver::driver_main, *};
use bevy_mod_scripting_codegen::{driver::driver_main, *};

fn main() {
// initially set it to high so no logs are missed, but later when we parse the args we will set it to the correct level
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_api_gen/src/bin/main.rs → codegen/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
process::{Command, Stdio},
};

use bevy_api_gen::*;
use bevy_mod_scripting_codegen::*;
use cargo_metadata::camino::{Utf8Path, Utf8PathBuf};
use clap::Parser;
use log::{debug, error, info};
Expand Down Expand Up @@ -87,7 +87,7 @@ fn main() {
workspace_meta.set_env();

match args.cmd {
bevy_api_gen::Command::Print { template } => {
bevy_mod_scripting_codegen::Command::Print { template } => {
println!(
"{}",
TEMPLATE_DIR
Expand All @@ -98,13 +98,13 @@ fn main() {
);
return;
}
bevy_api_gen::Command::ListTemplates => {
bevy_mod_scripting_codegen::Command::ListTemplates => {
for template in TemplateKind::VARIANTS {
println!("{template}");
}
return;
}
bevy_api_gen::Command::Collect {
bevy_mod_scripting_codegen::Command::Collect {
output,
templates,
api_name,
Expand Down Expand Up @@ -317,7 +317,7 @@ fn process_artifact(
}

/// finds best location for bootstrapping crate
/// this will be the nearest target/bevy_api_gen_bootstrap directory
/// this will be the nearest target/bms_codegen_bootstrap directory
fn find_bootstrap_dir() -> PathBuf {
let mut path = env::current_dir().unwrap();
loop {
Expand All @@ -331,7 +331,7 @@ fn find_bootstrap_dir() -> PathBuf {
}

path.push("target");
path.push("bevy_api_gen_bootstrap");
path.push("bms_codegen_bootstrap");

// create all the directories
create_dir_all(&path).unwrap();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl crate::driver::RustcPlugin for BevyAnalyzer {
}

fn driver_name(&self) -> std::borrow::Cow<'static, str> {
"bevy-api-gen-driver".into()
"bms-codegen-driver".into()
}

fn args(&self, target_dir: &Utf8Path) -> RustcPluginArgs<crate::Args> {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 29 additions & 13 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,11 @@ impl App {
arg.arg("--dont-update-ide");
}
}
Xtasks::Build => {
Xtasks::Build { timings } => {
cmd.arg("build");
if timings {
cmd.arg("--timings");
}
}
Xtasks::Check { ide_mode, kind } => {
cmd.arg("check");
Expand Down Expand Up @@ -625,7 +628,15 @@ enum Xtasks {
dont_update_ide: bool,
},
/// Build the main workspace only
Build,
Build {
/// Emit cargo build timings
#[clap(
long,
default_value = "false",
help = "Emit cargo build timings via --timinigs"
)]
timings: bool,
},
/// Build the main workspace, apply all prefferred lints
Check {
#[clap(
Expand Down Expand Up @@ -749,7 +760,7 @@ impl Xtasks {
}

match self {
Xtasks::Build => Self::build(app_settings),
Xtasks::Build { timings } => Self::build(timings, app_settings),
Xtasks::Check { ide_mode, kind } => Self::check(app_settings, ide_mode, kind),
Xtasks::Docs { open, no_rust_docs } => Self::docs(app_settings, open, no_rust_docs),
Xtasks::Test { name, package } => Self::test(app_settings, package, name),
Expand All @@ -770,7 +781,7 @@ impl Xtasks {
for os in <CiOs as strum::VariantArray>::VARIANTS {
for row in output.iter() {
let step_should_run_on_main_os =
matches!(row.subcmd, Xtasks::Build | Xtasks::Docs { .. });
matches!(row.subcmd, Xtasks::Build { .. } | Xtasks::Docs { .. });
let is_coverage_step = row.global_args.coverage;

if !os.is_main_os() && step_should_run_on_main_os {
Expand Down Expand Up @@ -837,7 +848,7 @@ impl Xtasks {

fn codegen_crate_dir(app_settings: &GlobalArgs) -> Result<std::path::PathBuf> {
let workspace_dir = Self::workspace_dir(app_settings)?;
Ok(workspace_dir.join("crates").join("bevy_api_gen"))
Ok(workspace_dir.join("codegen"))
}

fn relative_workspace_dir<P: AsRef<Path>>(
Expand Down Expand Up @@ -915,7 +926,7 @@ impl Xtasks {

args.push(command.to_owned());

if command != "fmt" && command != "bevy-api-gen" && command != "install" {
if command != "fmt" && command != "bms-codegen" && command != "install" {
// fmt doesn't care about features, workspaces or profiles
if command != "run" {
args.push("--workspace".to_owned());
Expand Down Expand Up @@ -978,13 +989,18 @@ impl Xtasks {
}
}

fn build(app_settings: GlobalArgs) -> Result<()> {
fn build(timings: bool, app_settings: GlobalArgs) -> Result<()> {
// build workspace using the given features
let mut args = vec!["--all-targets", "--examples"];
if timings {
args.push("--timings");
}

Self::run_workspace_command(
&app_settings,
"build",
"Failed to build workspace",
vec!["--all-targets"],
args,
None,
false,
)?;
Expand Down Expand Up @@ -1184,8 +1200,8 @@ impl Xtasks {

Self::run_workspace_command(
&bevy_repo_app_settings,
"bevy-api-gen",
"Failed to run bevy-api-gen generate",
"bms-codegen",
"Failed to run bms-codegen generate",
vec![
"generate",
"--bms-core-path",
Expand All @@ -1205,8 +1221,8 @@ impl Xtasks {
// collect
Self::run_workspace_command(
&bevy_repo_app_settings,
"bevy-api-gen",
"Failed to run bevy-api-gen generate",
"bms-codegen",
"Failed to run bms-codegen generate",
vec![
"collect",
"--bms-core-path",
Expand Down Expand Up @@ -1755,7 +1771,7 @@ impl Xtasks {
// replace args with powerset
output.push(App {
global_args: default_args.clone().with_features(feature_set.clone()),
subcmd: Xtasks::Build,
subcmd: Xtasks::Build { timings: false },
})
}

Expand Down
2 changes: 1 addition & 1 deletion xtask/templates/settings.json.tera
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"rust-analyzer.rustc.source": "discover",
"rust-analyzer.linkedProjects": [
"{{ dir }}/crates/bevy_api_gen/Cargo.toml",
"codegen/Cargo.toml",
"Cargo.toml",
"xtask/Cargo.toml"
],
Expand Down
Loading