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
9 changes: 8 additions & 1 deletion .github/workflows/bevy_mod_scripting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ jobs:
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
with:
toolchain: stable
override: true
override: false
- name: Print versions
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
run: |
echo "Rust version: $(rustc --version)"
echo "Clippy version: $(cargo clippy --version)"
echo "Active toolchain: $(rustup show active-toolchain)"
continue-on-error: true
- name: Rust Cache
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
uses: Swatinem/[email protected]
Expand Down
9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "bevy_mod_scripting"
version = "0.15.1"
authors = ["Maksymilian Mozolewski <[email protected]>"]
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
description = "Multi language scripting in Bevy"
repository = "https://github.com/makspll/bevy_mod_scripting"
Expand Down Expand Up @@ -156,12 +156,7 @@ debug = true
[[example]]
name = "game_of_life"
path = "examples/game_of_life.rs"
required-features = [
"lua54",
"rhai",
"bevy/file_watcher",
"bevy/multi_threaded",
]
required-features = ["lua54", "rhai"]

[[example]]
name = "docgen"
Expand Down
10 changes: 6 additions & 4 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ use std::{collections::HashMap, path::PathBuf, sync::LazyLock, time::Duration};

use bevy::{
log::{
tracing, tracing::span, tracing_subscriber, tracing_subscriber::layer::SubscriberExt, Level,
Level, tracing, tracing::span, tracing_subscriber, tracing_subscriber::layer::SubscriberExt,
},
reflect::Reflect,
};
use bevy_mod_scripting_core::bindings::{
FromScript, IntoScript, Mut, Ref, ReflectReference, ScriptValue, Val,
};
use criterion::{
criterion_main, measurement::Measurement, BatchSize, BenchmarkFilter, BenchmarkGroup, Criterion,
BatchSize, BenchmarkFilter, BenchmarkGroup, Criterion, criterion_main, measurement::Measurement,
};
use regex::Regex;
use script_integration_test_harness::{
make_test_lua_plugin, make_test_rhai_plugin, perform_benchmark_with_generator,
run_lua_benchmark, run_plugin_script_load_benchmark, run_rhai_benchmark,
test_functions::rand::Rng,
};
use test_utils::{discover_all_tests, Test};
use test_utils::{Test, discover_all_tests};

static ENABLE_PROFILING: LazyLock<bool> =
LazyLock::new(|| std::env::var("ENABLE_PROFILING").is_ok());
Expand Down Expand Up @@ -147,7 +147,9 @@ fn script_benchmarks(criterion: &mut Criterion, filter: Option<Regex>) {

fn maybe_with_profiler(f: impl Fn(bool)) {
if *ENABLE_PROFILING {
println!("profiling enabled, make sure to run tracy. If using it across windows/WSL you can use something like `tracy-capture.exe -o output.tracy -a localhost` on windows");
println!(
"profiling enabled, make sure to run tracy. If using it across windows/WSL you can use something like `tracy-capture.exe -o output.tracy -a localhost` on windows"
);
// set global tracing subscriber so bevy doesn't set it itself first
let subscriber = tracing_subscriber::Registry::default();
let tracy_layer = tracing_tracy::TracyLayer::default();
Expand Down
16 changes: 0 additions & 16 deletions build_scripts.sh

This file was deleted.

2 changes: 1 addition & 1 deletion crates/bevy_api_gen/Cargo.bootstrap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[package]
name = "bevy_analyzer_deps_bootstrap"
version = "0.1.0"
edition = "2021"
edition = "2024"

[dependencies]
bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" }
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_api_gen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_api_gen"
version = "0.6.0"
edition = "2021"
edition = "2024"
description = "Code generator tool for bevy"
license = "MIT OR Apache-2.0"
repository = "https://github.com/makspll/bevy_mod_scripting"
Expand Down Expand Up @@ -37,7 +37,6 @@ rustc_private = true
[dependencies]
log = "0.4"
env_logger = "0.11"
rustc_plugin = "0.12.0-nightly-2024-12-15"
indexmap = "2"
cargo_metadata = "0.18"
serde_json = "1"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
components = ["clippy", "rust-src", "rustc-dev", "llvm-tools"]
channel = "nightly-2024-12-15"
channel = "nightly-2025-06-27"
6 changes: 3 additions & 3 deletions crates/bevy_api_gen/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ impl WorkspaceMeta {
}

pub fn set_env(&self) {
std::env::set_var(Self::CRATES_ENV_NAME, self.crates.join(","));
std::env::set_var(Self::PLUGIN_DIR_NAME, &self.plugin_target_dir);
unsafe { std::env::set_var(Self::CRATES_ENV_NAME, self.crates.join(",")) };
unsafe { std::env::set_var(Self::PLUGIN_DIR_NAME, &self.plugin_target_dir) };
if let Some(include_crates) = &self.include_crates {
std::env::set_var(Self::INCLUDE_CRATES_ENV_NAME, include_crates.join(","));
unsafe { std::env::set_var(Self::INCLUDE_CRATES_ENV_NAME, include_crates.join(",")) };
}
}
}
6 changes: 3 additions & 3 deletions crates/bevy_api_gen/src/bin/driver.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![feature(rustc_private)]
use bevy_api_gen::*;
use bevy_api_gen::{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
std::env::set_var("RUST_LOG", "trace");
unsafe { std::env::set_var("RUST_LOG", "trace") };
env_logger::init();
rustc_plugin::driver_main(BevyAnalyzer);
driver_main(BevyAnalyzer);
}
50 changes: 26 additions & 24 deletions crates/bevy_api_gen/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::{
collections::HashMap,
env,
fs::{create_dir_all, File},
fs::{File, create_dir_all},
io::{BufRead, Write},
path::{Path, PathBuf},
process::{Command, Stdio},
Expand All @@ -22,7 +22,7 @@ fn main() {
let args = Args::parse_from(env::args().skip(1));

if env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", args.verbose.get_rustlog_value());
unsafe { env::set_var("RUST_LOG", args.verbose.get_rustlog_value()) };
}
env_logger::init();

Expand Down Expand Up @@ -52,8 +52,9 @@ fn main() {
);

info!(
"Computing all transitive dependencies for enabled top-level features: {}",
args.features.join(",")
"Computing all transitive dependencies for enabled top-level features: {}. using default features: {}",
args.features.join(","),
!args.no_default_features
);

let dependencies = feature_graph
Expand Down Expand Up @@ -99,7 +100,7 @@ fn main() {
}
bevy_api_gen::Command::ListTemplates => {
for template in TemplateKind::VARIANTS {
println!("{}", template);
println!("{template}");
}
return;
}
Expand All @@ -109,7 +110,7 @@ fn main() {
api_name,
} => {
let tera = configure_tera("no_crate", &templates);
info!("Collecting from: {}", output);
info!("Collecting from: {output}");
if !output.is_dir() {
panic!("Output is not a directory");
}
Expand Down Expand Up @@ -175,15 +176,17 @@ fn main() {
.join(" ");

debug!("bootstrap paths: {bootstrap_rlibs:?}");
env::set_var(
"RUSTFLAGS",
format!(
"{} {} -L dependency={}",
env::var("RUSTFLAGS").unwrap_or("".to_owned()),
extern_args,
bootstrap_rlibs.iter().next().unwrap().1.parent().unwrap()
),
);
unsafe {
env::set_var(
"RUSTFLAGS",
format!(
"{} {} -L dependency={}",
env::var("RUSTFLAGS").unwrap_or("".to_owned()),
extern_args,
bootstrap_rlibs.iter().next().unwrap().1.parent().unwrap()
),
)
};
} else {
panic!("Could not find 'libmlua' artifact among bootstrap crate artifacts, stopping.");
}
Expand All @@ -193,9 +196,9 @@ fn main() {
debug!("RUSTFLAGS={}", env::var("RUSTFLAGS").unwrap_or_default());

// disable incremental compilation
env::set_var("CARGO_INCREMENTAL", "0");
unsafe { env::set_var("CARGO_INCREMENTAL", "0") };

rustc_plugin::cli_main(BevyAnalyzer);
driver::cli_main(BevyAnalyzer);

// just making sure the temp dir lives until everything is done
drop(temp_dir);
Expand Down Expand Up @@ -290,7 +293,7 @@ fn build_bootstrap(
}
}
Err(e) => {
panic!("Failed to wait on cargo build process: {}", e);
panic!("Failed to wait on cargo build process: {e}");
}
}

Expand All @@ -305,12 +308,11 @@ fn process_artifact(
let file_name = artifact.file_name().unwrap_or_default();
let lib_name = file_name.split('-').next().unwrap().strip_prefix("lib");

if let Some(lib_name) = lib_name {
if BOOTSTRAP_DEPS.contains(&lib_name)
&& artifact.extension().is_some_and(|ext| ext == "rlib")
{
bootstrap_rlibs.insert(lib_name.to_owned(), artifact);
}
if let Some(lib_name) = lib_name
&& BOOTSTRAP_DEPS.contains(&lib_name)
&& artifact.extension().is_some_and(|ext| ext == "rlib")
{
bootstrap_rlibs.insert(lib_name.to_owned(), artifact);
}
}

Expand Down
10 changes: 8 additions & 2 deletions crates/bevy_api_gen/src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use log::{info, trace};
use rustc_hir::def_id::LOCAL_CRATE;
use tera::Context;

use crate::{Args, TemplateKind, WorkspaceMeta, ALL_PASSES};
use crate::{
ALL_PASSES, Args, TemplateKind, WorkspaceMeta, modifying_file_loader::ModifyingFileLoader,
};

pub(crate) struct BevyAnalyzerCallbacks {
args: Args,
Expand Down Expand Up @@ -59,7 +61,7 @@ impl rustc_driver::Callbacks for BevyAnalyzerCallbacks {
// tera environment for import processor
let tera = crate::configure_tera(tcx.crate_name(LOCAL_CRATE).as_str(), &templates_dir);

info!("Using meta directories: {:?}", meta_dirs);
info!("Using meta directories: {meta_dirs:?}");
let mut ctxt = crate::BevyCtxt::new(
tcx,
&meta_dirs,
Expand Down Expand Up @@ -89,4 +91,8 @@ impl rustc_driver::Callbacks for BevyAnalyzerCallbacks {

rustc_driver::Compilation::Continue
}

fn config(&mut self, config: &mut rustc_interface::interface::Config) {
config.file_loader = Some(Box::new(ModifyingFileLoader));
}
}
21 changes: 21 additions & 0 deletions crates/bevy_api_gen/src/driver/license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Cognitive Engineering Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading