mirror of
https://github.com/bevyengine/bevy
synced 2025-01-04 17:28:56 +00:00
804c068cc9
* fix: bevy_reflect looking for bevy in dev-deps * fix: support bevy as dev-dep only in bevy_reflect
60 lines
1.7 KiB
Rust
60 lines
1.7 KiB
Rust
use find_crate::{Dependencies, Manifest};
|
|
use proc_macro::TokenStream;
|
|
use syn::Path;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Modules {
|
|
pub bevy_reflect: String,
|
|
}
|
|
|
|
impl Modules {
|
|
pub fn meta(name: &str) -> Modules {
|
|
Modules {
|
|
bevy_reflect: format!("{}::reflect", name),
|
|
}
|
|
}
|
|
|
|
pub fn external() -> Modules {
|
|
Modules {
|
|
bevy_reflect: "bevy_reflect".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn internal() -> Modules {
|
|
Modules {
|
|
bevy_reflect: "crate".to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn get_modules() -> Modules {
|
|
let mut manifest = Manifest::new().unwrap();
|
|
// Only look for regular dependencies in the first pass.
|
|
manifest.dependencies = Dependencies::Release;
|
|
|
|
if let Some(package) = manifest.find(|name| name == "bevy") {
|
|
Modules::meta(&package.name)
|
|
} else if let Some(package) = manifest.find(|name| name == "bevy_internal") {
|
|
Modules::meta(&package.name)
|
|
} else if let Some(_package) = manifest.find(|name| name == "bevy_reflect") {
|
|
Modules::external()
|
|
} else {
|
|
// If reflect is not found as a regular dependency,
|
|
// try dev-dependencies.
|
|
manifest.dependencies = Dependencies::Dev;
|
|
|
|
if let Some(package) = manifest.find(|name| name == "bevy") {
|
|
Modules::meta(&package.name)
|
|
} else if let Some(package) = manifest.find(|name| name == "bevy_internal") {
|
|
Modules::meta(&package.name)
|
|
} else if let Some(_package) = manifest.find(|name| name == "bevy_reflect") {
|
|
Modules::external()
|
|
} else {
|
|
Modules::internal()
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn get_path(path_str: &str) -> Path {
|
|
syn::parse(path_str.parse::<TokenStream>().unwrap()).unwrap()
|
|
}
|