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/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
TARGET_DIR = { value = "target", relative = true }

[alias]
xtask = "run --package xtask --"
xtask = "run --manifest-path xtask/Cargo.toml --package xtask --"
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ members = [
"crates/languages/bevy_mod_scripting_rhai",
# "crates/languages/bevy_mod_scripting_rune",
"crates/bevy_mod_scripting_functions",
"crates/xtask",
"crates/testing_crates/test_utils",
"crates/testing_crates/script_integration_test_harness",
"crates/bevy_mod_scripting_derive",
Expand All @@ -125,7 +124,7 @@ members = [
"crates/bevy_system_reflection",
]
resolver = "2"
exclude = ["crates/bevy_api_gen", "crates/macro_tests"]
exclude = ["crates/bevy_api_gen", "crates/macro_tests", "xtask"]

[profile.dev]
debug = 1
Expand Down
19 changes: 16 additions & 3 deletions check.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#!/usr/bin/env pwsh
Set-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Definition)
cargo xtask check --ide-mode
#!/bin/bash
WORKSPACE_DIR="$PWD"

cd "$(dirname "$0")"
# if the path is in /bevy_api_gen then we run the codegen check

if [[ "$WORKSPACE_DIR" == *"/bevy_api_gen"* ]]; then
# save output to file as well as stdout and stderr
cargo xtask check --ide-mode --kind codegen
elif [[ "$WORKSPACE_DIR" == *"/xtask"* ]]; then
cd "$WORKSPACE_DIR"
cargo clippy --workspace --message-format=json --all-targets -- -D warnings
else
cd "$WORKSPACE_DIR"
cargo xtask check --ide-mode --kind main
fi
15 changes: 14 additions & 1 deletion check.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#!/bin/bash
WORKSPACE_DIR="$PWD"

cd "$(dirname "$0")"
cargo xtask check --ide-mode
# if the path is in /bevy_api_gen then we run the codegen check

if [[ "$WORKSPACE_DIR" == *"/bevy_api_gen"* ]]; then
# save output to file as well as stdout and stderr
cargo xtask check --ide-mode --kind codegen
elif [[ "$WORKSPACE_DIR" == *"/xtask"* ]]; then
cd "$WORKSPACE_DIR"
cargo check --quiet --workspace --message-format=json --all-targets
else
cd "$WORKSPACE_DIR"
cargo xtask check --ide-mode --kind main
fi
1 change: 1 addition & 0 deletions codegen_bevy_features.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bevy_asset,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/src/passes/cache_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
DEF_PATHS_GET_TYPE_REGISTRATION, DEF_PATHS_REFLECT, STD_SOURCE_TRAITS,
};

fn dump_traits(tcx: &TyCtxt) -> String{
fn dump_traits(tcx: &TyCtxt) -> String {
let mut buffer = String::new();
for t in tcx.all_traits() {
buffer.push_str(&tcx.def_path_str(t));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 29 additions & 5 deletions crates/xtask/src/main.rs → xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,13 @@ struct CodegenTemplateArgs {
self_is_bms_lua: bool,
}

fn fetch_default_bevy_features() -> String {
let path = "codegen_bevy_features.txt";
std::fs::read_to_string(path)
.with_context(|| format!("Failed to read default bevy features from {path}"))
.unwrap()
}

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, clap::Subcommand, strum::AsRefStr)]
#[clap(
name = "xtask",
Expand Down Expand Up @@ -677,7 +684,7 @@ enum Xtasks {

#[clap(
long,
default_value = "bevy_asset,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded",
default_value = fetch_default_bevy_features(),
help = "The features to enable for the bevy crate"
)]
bevy_features: Vec<String>,
Expand Down Expand Up @@ -814,9 +821,10 @@ impl Xtasks {
/// Reads the metadata from the main workspace
fn main_workspace_cargo_metadata() -> Result<cargo_metadata::Metadata> {
let cargo_manifest_path = std::env::var("MAIN_CARGO_MANIFEST_PATH").unwrap();

let path = PathBuf::from(cargo_manifest_path);
let parent_dir = path.parent().unwrap().parent().unwrap().join("Cargo.toml");
let mut cmd = cargo_metadata::MetadataCommand::new();
cmd.manifest_path(cargo_manifest_path);
cmd.manifest_path(parent_dir.to_string_lossy().to_string());
let out = cmd.exec()?;
Ok(out)
}
Expand Down Expand Up @@ -993,7 +1001,11 @@ impl Xtasks {
if ide_mode {
clippy_args.push("--message-format=json");
}
clippy_args.extend(vec!["--all-targets", "--", "-D", "warnings"]);

let keep_going = std::env::var(XTASK_KEEP_GOING).is_ok();
if !keep_going {
clippy_args.extend(vec!["--all-targets", "--", "-D", "warnings"]);
}

Self::run_workspace_command(
&app_settings,
Expand Down Expand Up @@ -1035,7 +1047,11 @@ impl Xtasks {
if ide_mode {
clippy_args.push("--message-format=json");
}
clippy_args.extend(vec!["--all-targets", "--", "-D", "warnings"]);

let keep_going = std::env::var(XTASK_KEEP_GOING).is_ok();
if !keep_going {
clippy_args.extend(vec!["--all-targets", "--", "-D", "warnings"]);
}

Self::run_workspace_command(
&app_settings,
Expand Down Expand Up @@ -1211,6 +1227,10 @@ impl Xtasks {
}

fn check(app_settings: GlobalArgs, ide_mode: bool, kind: CheckKind) -> Result<()> {
if ide_mode && kind == CheckKind::All {
bail!("Ide mode should not be used with 'all' check kind, each workspace needs to have each own individual check, for toolchains to be properly supported");
}

match kind {
CheckKind::All => {
let err_main = Self::check_main_workspace(app_settings.clone(), ide_mode);
Expand Down Expand Up @@ -2017,7 +2037,9 @@ fn try_main() -> Result<()> {
pretty_env_logger::formatted_builder()
.filter_level(LevelFilter::Info)
.init();

pop_cargo_env()?;

let args = App::try_parse()?;
info!(
"Default toolchain: {:?}",
Expand All @@ -2033,6 +2055,8 @@ fn try_main() -> Result<()> {
Ok(())
}

const XTASK_KEEP_GOING: &str = "XTASK_KEEP_GOING";

fn main() {
if let Err(e) = try_main() {
eprintln!("{e:?}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
"rust-analyzer.rustc.source": "discover",
"rust-analyzer.linkedProjects": [
"{{ dir }}/crates/bevy_api_gen/Cargo.toml",
"Cargo.toml"
"Cargo.toml",
"xtask/Cargo.toml"
],
"rust-analyzer.check.invocationStrategy": "per_workspace",
"rust-analyzer.check.overrideCommand": [
"{{ dir }}/check.sh"
],
"rust-analyzer.cargo.buildScripts.invocationStrategy": "per_workspace",
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"{{ dir }}/check.sh"
]
}
Loading