Skip to content

Commit 5d7d7c9

Browse files
authored
Bevy 0.15 Support (#139)
* bump bevy to 0.15.0-rc.2 * migrate asset loaders * Upgrade reflection API's * bump codegen & codegen new files * Fix errors + regen * pin git again * fix more errors * bump macro tests * clippy fixes to bevy api gen * more bevy api gen clippy fixes * Update game of life examples * fix clippy * fix more clippy * fix more clippy * bump versions to alpha
1 parent 99460d1 commit 5d7d7c9

File tree

50 files changed

+7903
-4293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+7903
-4293
lines changed

.github/workflows/bevy_api_gen.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions-rs/toolchain@v1
2626
with:
2727
profile: minimal
28-
toolchain: nightly-2024-05-20
28+
toolchain: nightly-2024-11-05
2929
override: true
3030
- name: Rust Cache
3131
uses: Swatinem/[email protected]
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
profile: minimal
5454
components: rustfmt
55-
toolchain: nightly-2024-05-20
55+
toolchain: nightly-2024-11-05
5656
override: true
5757
- name: Rust Cache
5858
uses: Swatinem/[email protected]
@@ -75,7 +75,7 @@ jobs:
7575
rm -rf crates
7676
- uses: actions-rs/toolchain@v1
7777
with:
78-
toolchain: nightly-2024-05-20
78+
toolchain: nightly-2024-11-05
7979
components: clippy
8080
override: true
8181
- name: Rust Cache
@@ -98,7 +98,7 @@ jobs:
9898
rm -rf crates
9999
- uses: actions-rs/toolchain@v1
100100
with:
101-
toolchain: nightly-2024-05-20
101+
toolchain: nightly-2024-11-05
102102
override: true
103103
- name: Rust Cache
104104
uses: Swatinem/[email protected]
@@ -120,7 +120,7 @@ jobs:
120120
rm -rf crates
121121
- uses: actions-rs/toolchain@v1
122122
with:
123-
toolchain: nightly-2024-05-20
123+
toolchain: nightly-2024-11-05
124124
override: true
125125
- name: Rust Cache
126126
uses: Swatinem/[email protected]

Cargo.toml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting"
3-
version = "0.7.1"
3+
version = "0.8.0-alpha.0"
44
authors = ["Maksymilian Mozolewski <[email protected]>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"
@@ -63,16 +63,16 @@ rune = ["bevy_mod_scripting_rune"]
6363
[dependencies]
6464
bevy = { workspace = true }
6565
bevy_mod_scripting_core = { workspace = true }
66-
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.7.1", optional = true }
67-
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.7.1", optional = true }
68-
bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.7.1", optional = true }
69-
bevy_script_api = { path = "crates/bevy_script_api", version = "0.7.1", optional = true }
66+
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.8.0-alpha.0", optional = true }
67+
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.8.0-alpha.0", optional = true }
68+
bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.8.0-alpha.0", optional = true }
69+
bevy_script_api = { path = "crates/bevy_script_api", version = "0.8.0-alpha.0", optional = true }
7070

7171

7272
[workspace.dependencies]
73-
bevy = { version = "0.14.2", default-features = false }
74-
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.7.1" }
75-
bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.7.1" }
73+
bevy = { version = "0.15.0-rc.2", default-features = false }
74+
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.8.0-alpha.0" }
75+
bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.8.0-alpha.0" }
7676

7777
[dev-dependencies]
7878
bevy = { workspace = true, default-features = true }
@@ -111,25 +111,26 @@ codegen-units = 8
111111
incremental = false
112112
debug = false
113113

114-
[[example]]
115-
name = "console_integration_lua"
116-
path = "examples/lua/console_integration.rs"
117-
required-features = [
118-
"lua54",
119-
"lua_script_api",
120-
"bevy/file_watcher",
121-
"bevy/multi_threaded",
122-
]
123-
124-
[[example]]
125-
name = "console_integration_rhai"
126-
path = "examples/rhai/console_integration.rs"
127-
required-features = [
128-
"rhai",
129-
"rhai_script_api",
130-
"bevy/file_watcher",
131-
"bevy/multi_threaded",
132-
]
114+
# TODO: bump once bevy is released and the lib is updated
115+
# [[example]]
116+
# name = "console_integration_lua"
117+
# path = "examples/lua/console_integration.rs"
118+
# required-features = [
119+
# "lua54",
120+
# "lua_script_api",
121+
# "bevy/file_watcher",
122+
# "bevy/multi_threaded",
123+
# ]
124+
125+
# [[example]]
126+
# name = "console_integration_rhai"
127+
# path = "examples/rhai/console_integration.rs"
128+
# required-features = [
129+
# "rhai",
130+
# "rhai_script_api",
131+
# "bevy/file_watcher",
132+
# "bevy/multi_threaded",
133+
# ]
133134

134135
[[example]]
135136
name = "complex_game_loop_lua"

check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CURRENT_DIR=$(basename "$PWD")
44

55

66
if [[ "$CURRENT_DIR" == "bevy_api_gen" ]]; then
7-
cargo +nightly-2024-05-20 clippy --all-targets --message-format=json
7+
cargo +nightly-2024-11-05 clippy --all-targets --message-format=json
88
else
99
cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi_threaded"
1010
fi

crates/bevy_api_gen/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,16 @@ source = "discover"
3737
rustc_private = true
3838

3939
[rust-analyzer.check]
40-
overrideCommand = ["cargo", "+nightly-2024-05-20", "a", "--message-format=json"]
40+
overrideCommand = ["cargo", "+nightly-2024-11-05", "a", "--message-format=json"]
4141

4242

4343
[dependencies]
4444
log = "0.4"
4545
env_logger = "0.11"
46-
rustc_plugin = "=0.10.0-nightly-2024-05-20"
46+
rustc_plugin = { git = "https://github.com/makspll/rustc_plugin", branch = "feature/rust-1.82.0" }
4747
indexmap = "2"
4848
tempdir = "0.3"
4949
cargo_metadata = "0.18"
50-
rustc_data_structures = "0.0.1"
5150
serde_json = "1"
5251
serde = "1"
5352
clap = { version = "4", features = ["derive", "string"] }

crates/bevy_api_gen/readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ bevy_api_gen is a Cargo plugin that generates reflection-powered wrappers for Be
88
To install bevy_api_gen, use the following command:
99

1010
```bash
11-
cargo +nightly-2024-05-20 install bevy_api_gen
11+
cargo +nightly-2024-11-05 install bevy_api_gen
1212
```
1313

1414
# Usage
@@ -18,39 +18,39 @@ cargo +nightly-2024-05-20 install bevy_api_gen
1818
To run the main codegen process, use the following command:
1919

2020
```bash
21-
cargo +nightly-2024-05-20 bevy-api-gen generate
21+
cargo +nightly-2024-11-05 bevy-api-gen generate
2222
```
2323

24-
This will perform all parts of the process and generate meta as well as .rs files for each crate in your workspace in your `/target/plugin-nightly-2024-05-20/bevy_api_gen` directory
24+
This will perform all parts of the process and generate meta as well as .rs files for each crate in your workspace in your `/target/plugin-nightly-2024-11-05/bevy_api_gen` directory
2525

2626
## Collect
2727

2828
After generating all the files, you can 'collect' them in a mod.rs file like so:
2929

3030
```bash
31-
cargo +nightly-2024-05-20 bevy-api-gen collect
31+
cargo +nightly-2024-11-05 bevy-api-gen collect
3232
```
3333

3434
## List Types
3535

3636
To see a list of all `Reflect` implementing types in your workspace run:
3737

3838
```bash
39-
cargo +nightly-2024-05-20 bevy-api-gen list-types > all_types.txt
39+
cargo +nightly-2024-11-05 bevy-api-gen list-types > all_types.txt
4040
```
4141

4242
## List Templates
4343

4444
To see the list of all templates which you can override use:
4545

4646
```bash
47-
cargo +nightly-2024-05-20 bevy-api-gen list-templates
47+
cargo +nightly-2024-11-05 bevy-api-gen list-templates
4848
```
4949

5050
## Print Template
5151

5252
You can also print any of the templates to stdout:
5353

5454
```bash
55-
cargo +nightly-2024-05-20 bevy-api-gen print item.tera
55+
cargo +nightly-2024-11-05 bevy-api-gen print item.tera
5656
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
22
components = ["clippy", "rust-src", "rustc-dev", "llvm-tools"]
3-
channel = "nightly-2024-05-20"
3+
channel = "nightly-2024-11-05"

crates/bevy_api_gen/src/bin/driver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(rustc_private)]
12
use bevy_api_gen::*;
23

34
fn main() {

crates/bevy_api_gen/src/bin/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(rustc_private)]
12
use std::{
23
collections::HashMap,
34
env,

crates/bevy_api_gen/src/context.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ impl CachedTraits {
138138
.all(|t| self.std_source_traits.contains_key(*t))
139139
}
140140

141-
pub(crate) fn missing_std_source_traits(&self) -> Vec<String> {
142-
STD_SOURCE_TRAITS
143-
.iter()
144-
.filter(|t| !self.std_source_traits.contains_key(**t))
145-
.map(|s| (*s).to_owned())
146-
.collect()
147-
}
141+
// pub(crate) fn missing_std_source_traits(&self) -> Vec<String> {
142+
// STD_SOURCE_TRAITS
143+
// .iter()
144+
// .filter(|t| !self.std_source_traits.contains_key(**t))
145+
// .map(|s| (*s).to_owned())
146+
// .collect()
147+
// }
148148
}
149149

150150
#[derive(Clone, Debug)]

crates/bevy_api_gen/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#![feature(rustc_private, let_chains)]
22
#![deny(rustc::internal)]
3+
34
extern crate rustc_ast;
45
extern crate rustc_driver;
56
extern crate rustc_errors;
67
extern crate rustc_hir;
7-
extern crate rustc_hir_analysis;
88
extern crate rustc_infer;
99
extern crate rustc_interface;
10-
extern crate rustc_lint;
1110
extern crate rustc_middle;
12-
extern crate rustc_session;
1311
extern crate rustc_span;
1412
extern crate rustc_trait_selection;
1513

crates/bevy_api_gen/src/meta.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl MetaLoader {
9494
let cache = self.cache.borrow();
9595
if cache.contains_key(crate_name) {
9696
trace!("Loading meta from cache for: {}", crate_name);
97-
return cache.get(crate_name).cloned();
97+
cache.get(crate_name).cloned()
9898
} else {
9999
trace!("Loading meta from filesystem for: {}", crate_name);
100100
drop(cache);

crates/bevy_api_gen/src/modifying_file_loader.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
use std::io;
1+
use std::{
2+
io,
3+
sync::atomic::{AtomicBool, Ordering},
4+
};
25

36
use log::trace;
4-
use rustc_data_structures::sync::{AtomicBool, Lrc, Ordering};
7+
use rustc_middle::ty::data_structures::Lrc;
8+
// use rustc_data_structures::sync::{AtomicBool, Lrc};
59
use rustc_span::source_map::{FileLoader, RealFileLoader};
610

711
/// Injects extern statements into the first loaded file (crate root)

crates/bevy_api_gen/src/passes/cache_traits.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
6666
.join(", ")
6767
);
6868

69-
panic!(
70-
"Could not find traits: [{}] in crate: {}, did bootstrapping go wrong?",
71-
ctxt.cached_traits.missing_std_source_traits().join(", "),
72-
tcx.crate_name(LOCAL_CRATE)
73-
)
69+
// TODO: figure out why some crates are missing std::fmt::Display etc
70+
// panic!(
71+
// "Could not find traits: [{}] in crate: {}, did bootstrapping go wrong?",
72+
// ctxt.cached_traits.missing_std_source_traits().join(", "),
73+
// tcx.crate_name(LOCAL_CRATE)
74+
// )
7475
}
7576

7677
true

crates/bevy_api_gen/src/passes/find_methods_and_fields.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use rustc_hir::{
66
Safety,
77
};
88
use rustc_infer::infer::TyCtxtInferExt;
9-
use rustc_middle::ty::{AdtKind, AssocKind, FieldDef, FnSig, ParamEnv, Ty, TyCtxt, TyKind};
9+
use rustc_middle::ty::{
10+
AdtKind, AssocKind, FieldDef, FnSig, ParamEnv, Ty, TyCtxt, TyKind, TypingMode,
11+
};
1012
use rustc_span::Symbol;
1113
use rustc_trait_selection::infer::InferCtxtExt;
1214

@@ -86,7 +88,6 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) ->
8688
let mut all_impls = ctxt
8789
.tcx
8890
.inherent_impls(def_id)
89-
.unwrap()
9091
.iter()
9192
.chain(trait_impls_for_ty.iter().flatten())
9293
.collect::<Vec<_>>();
@@ -390,7 +391,7 @@ fn type_is_supported_as_non_proxy_return_val<'tcx>(
390391
) -> bool {
391392
trace!("Checkign type is supported as non proxy return val: '{ty:?}' with param_env: '{param_env:?}'");
392393
if let TyKind::Ref(region, _, _) = ty.kind() {
393-
if !region.get_name().is_some_and(|rn| rn.as_str() == "'static") {
394+
if region.get_name().is_none_or(|rn| rn.as_str() != "'static") {
394395
return false;
395396
}
396397
}
@@ -410,7 +411,7 @@ pub(crate) fn impls_trait<'tcx>(
410411
trait_did: DefId,
411412
) -> bool {
412413
tcx.infer_ctxt()
413-
.build()
414+
.build(TypingMode::non_body_analysis())
414415
.type_implements_trait(trait_did, [ty], param_env)
415416
.must_apply_modulo_regions()
416417
}

crates/bevy_api_gen/src/passes/find_trait_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_infer::{
66
infer::{InferCtxt, TyCtxtInferExt},
77
traits::{Obligation, ObligationCause},
88
};
9-
use rustc_middle::ty::Ty;
9+
use rustc_middle::ty::{Ty, TypingMode};
1010
use rustc_span::DUMMY_SP;
1111
use rustc_trait_selection::traits::ObligationCtxt;
1212

@@ -105,7 +105,7 @@ fn type_impl_of_trait(
105105
//TODO: false negatives coming from this inference
106106

107107
let ty = tcx.type_of(reflect_ty_did).instantiate_identity();
108-
let infcx = tcx.infer_ctxt().build();
108+
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
109109
let result = impl_matches(&infcx, ty, impl_did);
110110
log::trace!("Result: {:#?}", result);
111111
if result {

crates/bevy_api_gen/src/template.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ pub(crate) fn configure_tera_env(tera: &mut Tera, crate_name: &str) {
195195

196196
let file = syn::parse_file(&str)
197197
.map_err(|e| tera::Error::msg(e.to_string()))
198-
.map_err(|e| {
198+
.inspect_err(|_| {
199199
log::error!("prettyplease error on input: ```\n{}\n```", str);
200-
e
201200
})?;
202201

203202
let out = prettyplease::unparse(&file);

crates/bevy_event_priority/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_event_priority"
3-
version = "0.7.1"
3+
version = "0.8.0-alpha.0"
44
authors = ["Maksymilian Mozolewski <[email protected]>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"

crates/bevy_mod_scripting_common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting_common"
3-
version = "0.7.1"
3+
version = "0.8.0-alpha.0"
44
authors = ["Maksymilian Mozolewski <[email protected]>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"

0 commit comments

Comments
 (0)