
This pr uses the `extern crate self as` trick to make proc macros behave the same way inside and outside bevy. # Objective - Removes noise introduced by `crate as` in the whole bevy repo. - Fixes #17004. - Hardens proc macro path resolution. ## TODO - [x] `BevyManifest` needs cleanup. - [x] Cleanup remaining `crate as`. - [x] Add proper integration tests to the ci. ## Notes - `cargo-manifest-proc-macros` is written by me and based/inspired by the old `BevyManifest` implementation and [`bkchr/proc-macro-crate`](https://github.com/bkchr/proc-macro-crate). - What do you think about the new integration test machinery I added to the `ci`? More and better integration tests can be added at a later stage. The goal of these integration tests is to simulate an actual separate crate that uses bevy. Ideally they would lightly touch all bevy crates. ## Testing - Needs RA test - Needs testing from other users - Others need to run at least `cargo run -p ci integration-test` and verify that they work. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
37 lines
1.0 KiB
Rust
37 lines
1.0 KiB
Rust
#![allow(dead_code)]
|
|
use bevy::prelude::*;
|
|
|
|
#[derive(Component)]
|
|
struct MyComponent {
|
|
value: f32,
|
|
}
|
|
|
|
#[derive(Resource)]
|
|
struct MyResource {
|
|
value: f32,
|
|
}
|
|
|
|
fn hello_world(query: Query<&MyComponent>, resource: Res<MyResource>) {
|
|
let component = query.iter().next().unwrap();
|
|
let comp_value = component.value; // rust-analyzer suggestions work
|
|
let res_value_deref = resource.value; // rust-analyzer suggestions don't work but ctrl+click works once it's written, also type inlay hints work correctly
|
|
let res_value_direct = resource.into_inner().value; // rust-analyzer suggestions work
|
|
println!(
|
|
"hello world! Value: {} {} {}",
|
|
comp_value, res_value_deref, res_value_direct
|
|
);
|
|
}
|
|
|
|
fn spawn_component(mut commands: Commands) {
|
|
commands.spawn(MyComponent { value: 10.0 });
|
|
}
|
|
|
|
#[test]
|
|
fn simple_ecs_test() {
|
|
App::new()
|
|
.insert_resource(MyResource { value: 5.0 })
|
|
.add_systems(Startup, spawn_component)
|
|
.add_systems(Update, hello_world)
|
|
.run();
|
|
}
|