bevy/crates
Jonathan Cornaz 1b8453d9a0 Fix path used by macro not considering that we can use a sub-crate (#3178)
# Problem

Let's say I am writting a simple bevy plugin, and I want to depend on `bevy_ecs` crate instead of depending on the full `bevy`. 

So I write the following:

*Cargo.toml*:
```toml
[dependencies]
bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", rev = "94db0176fecfac7e7e9763f2dc7458a54c105886" }
```

*lib.rs*:
```rust
use bevy_ecs::prelude::*;

#[derive(Debug, Default, Component)
pub struct MyFancyComponent;
```

So far, so good. Everything works. But let's say I want to write some examples for using my plugin. And for theses I'd like to use the `bevy` crate, so that I can write complete examples (rendering stuff, etc.) that are simple and look like what the consumer of my plugin will do (`use bevy::prelude::*` and `DefaultPlugins`)

So I amend my *Cargo.toml*:
```toml
[dependencies]
bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", rev = "94db0176fecfac7e7e9763f2dc7458a54c105886" }

[dev-dependencies]
bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "94db0176fecfac7e7e9763f2dc7458a54c105886", default-features = false }
```

And that  leads to a complilation error 

```
error[E0433]: failed to resolve: use of undeclared crate or module `bevy`
```

Basically, because `bevy` is in the `dev-dependencies`, the macro (of the production code) decides to use the `bevy::ecs` path instead of `bevy_ecs`. But `bevy` is not available there.

## Solution

This PR fixes the problem. I amend the macro utility responsible of finding the path of a module.

If we try to find a path, we first test if this correspond to a crate that the user directly depend on. (Like, if we search for `bevy_ecs`, we first check if there is a `bevy_ecs` dependency). If yes, we can depend on that directly. Otherwise, we proceed with the existing logic (testing `bevy` and `bevy_internal`)
2021-11-29 23:10:31 +00:00
..
bevy_app Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_asset Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_audio Remove wasm audio feature flag for 2021 (#3000) 2021-11-11 01:17:38 +00:00
bevy_core default features from bevy_asset and bevy_ecs can actually be disabled (#3097) 2021-11-13 21:15:22 +00:00
bevy_derive Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_diagnostic Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_dylib Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_dynamic_plugin Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_ecs Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_ecs_compile_fail_tests Assert compiler errors for compile_fail tests (#3067) 2021-11-13 22:43:19 +00:00
bevy_gilrs Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_gltf Fix MIME type support for glTF buffer Data URIs (#3101) 2021-11-11 01:58:57 +00:00
bevy_input Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_internal Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_log Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_macro_utils Fix path used by macro not considering that we can use a sub-crate (#3178) 2021-11-29 23:10:31 +00:00
bevy_math Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_pbr Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_reflect Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_render fix: as_rgba_linear used wrong variant (#3192) 2021-11-26 12:57:05 +00:00
bevy_scene Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_sprite Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_tasks Add readme to errors crate and clean up cargo files (#3125) 2021-11-13 23:06:48 +00:00
bevy_text Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_transform Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_ui Add docstring comment to Style to reference CSS (#2936) 2021-11-06 20:53:10 +00:00
bevy_utils Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_wgpu Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_window Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_winit Merge New Renderer 2021-11-22 23:57:42 -08:00
crevice Update vendored Crevice to 0.8.0 + PR for arrays (#3059) 2021-11-12 01:39:25 +00:00