JonahPlusPlus / bevy_atmosphere

A procedural sky plugin for bevy
Apache License 2.0
267 stars 19 forks source link

Update Bevy to 0.12 #61

Closed sphw closed 11 months ago

sphw commented 12 months ago

This PR updates the core plugin to Bevy 0.12. Some examples are not compiling since they rely on the bevy_spectator plugin, which hasn't been updated yet.

UPDATE: I've now updated bevy_spectator to the latest version, and all the examples seem to build

VirxEC commented 11 months ago

This branch works for me on bevy 0.12 :+1:

Shatur commented 11 months ago

Thanks! But why src/ is necessary? Isn't it /src/ by default?

sphw commented 11 months ago

Thanks! But why src/ is necessary? Isn't it /src/ by default?

The root issue is described in this ticket: https://github.com/bevyengine/bevy/issues/10377. Internally embedded_asset calls file!() which if it is in an nested workspace returns something like crate_path/src/foo.rs, but if it is in a normal crate (not in a workspace) it returns src/foo.rs. The default /src/ assumes that the path will always contain that beginning /. My quick workaround was to just use src/.

Shatur commented 11 months ago

Oh, I get it, thanks for the explanation! Could you fix lints and I will merge it?

Shatur commented 11 months ago

Thank you a lot!

Shatur commented 11 months ago

@sphw this is odd, but when I trying cargo publish it fails with the following message:

error: couldn't read /mnt/Files/Code/bevy_atmosphere/target/package/bevy_atmosphere-0.8.0/src/../shaders/nishita.wgsl: No such file or directory (os error 2)
 --> src/collection/nishita.rs:7:10
  |
7 | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
  |          ^^^^^^^^^^^
  |
  = note: this error originates in the macro `include_str` which comes from the expansion of the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

error: couldn't read /mnt/Files/Code/bevy_atmosphere/target/package/bevy_atmosphere-0.8.0/src/../shaders/gradient.wgsl: No such file or directory (os error 2)
 --> src/collection/gradient.rs:7:10
  |
7 | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
  |          ^^^^^^^^^^^
  |
  = note: this error originates in the macro `include_str` which comes from the expansion of the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `HandleUntyped` in `asset`
 --> src/collection/nishita.rs:7:10
  |
7 | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
  |          ^^^^^^^^^^^ could not find `HandleUntyped` in `asset`
  |
  = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `HandleUntyped` in `asset`
 --> src/collection/gradient.rs:7:10
  |
7 | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
  |          ^^^^^^^^^^^ could not find `HandleUntyped` in `asset`
  |
  = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `std::option::Option<&str>: From<&BindGroupDescriptor<'_>>` is not satisfied
  --> src/collection/nishita.rs:7:10
   |
7  | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
   |          ^^^^^^^^^^^ the trait `From<&BindGroupDescriptor<'_>>` is not implemented for `std::option::Option<&str>`
   |
   = help: the following other types implement trait `From<T>`:
             <std::option::Option<Level> as From<LevelFilter>>
             <std::option::Option<bevy::utils::tracing::Id> as From<Span>>
             <std::option::Option<bevy::utils::tracing::Id> as From<tracing_core::span::Current>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a Span>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a EnteredSpan>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a bevy::utils::tracing::Id>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a tracing_core::span::Current>>
             <std::option::Option<&'a bevy::utils::tracing::Id> as From<&'a Span>>
           and 7 others
   = note: required for `&BindGroupDescriptor<'_>` to implement `Into<std::option::Option<&str>>`
note: required by a bound in `RenderDevice::create_bind_group`
  --> /home/gena/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.12.0/src/renderer/render_device.rs:89:21
   |
87 |     pub fn create_bind_group<'a>(
   |            ----------------- required by a bound in this associated function
88 |         &self,
89 |         label: impl Into<wgpu::Label<'a>>,
   |                     ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RenderDevice::create_bind_group`
   = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0061]: this method takes 3 arguments but 1 argument was supplied
  --> src/collection/nishita.rs:7:10
   |
7  | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
   |          ^^^^^^^^^^^ two arguments of type `&BindGroupLayout` and `&[BindGroupEntry<'_>]` are missing
   |
note: method defined here
  --> /home/gena/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.12.0/src/renderer/render_device.rs:87:12
   |
87 |     pub fn create_bind_group<'a>(
   |            ^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the arguments
   |
7  | #[derive(Atmospheric(Atmospheric, /* &BindGroupLayout */, /* &[BindGroupEntry<'_>] */), ShaderType, Reflect, Debug, Clone)]
   |                     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0599]: no associated item named `TYPE_UUID` found for struct `bevy::prelude::Shader` in the current scope
 --> src/collection/nishita.rs:7:10
  |
7 | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
  |          ^^^^^^^^^^^ associated item not found in `Shader`
  |
  = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `std::option::Option<&str>: From<&BindGroupDescriptor<'_>>` is not satisfied
  --> src/collection/gradient.rs:7:10
   |
7  | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
   |          ^^^^^^^^^^^ the trait `From<&BindGroupDescriptor<'_>>` is not implemented for `std::option::Option<&str>`
   |
   = help: the following other types implement trait `From<T>`:
             <std::option::Option<Level> as From<LevelFilter>>
             <std::option::Option<bevy::utils::tracing::Id> as From<Span>>
             <std::option::Option<bevy::utils::tracing::Id> as From<tracing_core::span::Current>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a Span>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a EnteredSpan>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a bevy::utils::tracing::Id>>
             <std::option::Option<bevy::utils::tracing::Id> as From<&'a tracing_core::span::Current>>
             <std::option::Option<&'a bevy::utils::tracing::Id> as From<&'a Span>>
           and 7 others
   = note: required for `&BindGroupDescriptor<'_>` to implement `Into<std::option::Option<&str>>`
note: required by a bound in `RenderDevice::create_bind_group`
  --> /home/gena/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.12.0/src/renderer/render_device.rs:89:21
   |
87 |     pub fn create_bind_group<'a>(
   |            ----------------- required by a bound in this associated function
88 |         &self,
89 |         label: impl Into<wgpu::Label<'a>>,
   |                     ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RenderDevice::create_bind_group`
   = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0061]: this method takes 3 arguments but 1 argument was supplied
  --> src/collection/gradient.rs:7:10
   |
7  | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
   |          ^^^^^^^^^^^ two arguments of type `&BindGroupLayout` and `&[BindGroupEntry<'_>]` are missing
   |
note: method defined here
  --> /home/gena/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.12.0/src/renderer/render_device.rs:87:12
   |
87 |     pub fn create_bind_group<'a>(
   |            ^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the arguments
   |
7  | #[derive(Atmospheric(Atmospheric, /* &BindGroupLayout */, /* &[BindGroupEntry<'_>] */), ShaderType, Reflect, Debug, Clone)]
   |                     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0599]: no associated item named `TYPE_UUID` found for struct `bevy::prelude::Shader` in the current scope
 --> src/collection/gradient.rs:7:10
  |
7 | #[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
  |          ^^^^^^^^^^^ associated item not found in `Shader`
  |
  = note: this error originates in the derive macro `Atmospheric` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0061, E0277, E0433, E0599.
For more information about an error, try `rustc --explain E0061`.
error: could not compile `bevy_atmosphere` (lib) due to 10 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to verify package tarball

Do you have any idea why it might happen? cargo check --examples works just fine...

sphw commented 11 months ago

@sphw this is odd, but when I trying cargo publish it fails with the following message:

I believe this problem is caused by using an outdated version of the derive macro crate. I think you first need to publish the derive macro crate, then bump the version in the primary crate. I've used this tool https://github.com/pksunkara/cargo-workspaces in the past to fix this issue, but that was years ago so I'm not sure it's still the best option.

Shatur commented 11 months ago

Oh, right, thank you! Not the original author, just helping maintain the crate.