File tree Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 1
1
use bevy_macro_utils:: BevyManifest ;
2
2
use encase_derive_impl:: { implement, syn} ;
3
3
4
- const BEVY : & str = "bevy" ;
5
- const BEVY_RENDER : & str = "bevy_render" ;
6
4
const ENCASE : & str = "encase" ;
7
5
8
6
fn bevy_encase_path ( ) -> syn:: Path {
9
7
let bevy_manifest = BevyManifest :: default ( ) ;
10
8
bevy_manifest
11
- . maybe_get_path ( BEVY )
12
- . map ( |bevy_path| {
13
- let mut segments = bevy_path. segments ;
14
- segments. push ( BevyManifest :: parse_str ( "render" ) ) ;
15
- syn:: Path {
16
- leading_colon : None ,
17
- segments,
18
- }
19
- } )
20
- . or_else ( || bevy_manifest. maybe_get_path ( BEVY_RENDER ) )
9
+ . get_subcrate ( "render" )
21
10
. map ( |bevy_render_path| {
22
11
let mut segments = bevy_render_path. segments ;
23
12
segments. push ( BevyManifest :: parse_str ( "render_resource" ) ) ;
Original file line number Diff line number Diff line change @@ -32,12 +32,11 @@ impl Default for BevyManifest {
32
32
}
33
33
}
34
34
}
35
+ const BEVY : & str = "bevy" ;
36
+ const BEVY_INTERNAL : & str = "bevy_internal" ;
35
37
36
38
impl BevyManifest {
37
39
pub fn maybe_get_path ( & self , name : & str ) -> Option < syn:: Path > {
38
- const BEVY : & str = "bevy" ;
39
- const BEVY_INTERNAL : & str = "bevy_internal" ;
40
-
41
40
fn dep_package ( dep : & Value ) -> Option < & str > {
42
41
if dep. as_str ( ) . is_some ( ) {
43
42
None
@@ -103,6 +102,19 @@ impl BevyManifest {
103
102
pub fn parse_str < T : syn:: parse:: Parse > ( path : & str ) -> T {
104
103
syn:: parse ( path. parse :: < TokenStream > ( ) . unwrap ( ) ) . unwrap ( )
105
104
}
105
+
106
+ pub fn get_subcrate ( & self , subcrate : & str ) -> Option < syn:: Path > {
107
+ self . maybe_get_path ( BEVY )
108
+ . map ( |bevy_path| {
109
+ let mut segments = bevy_path. segments ;
110
+ segments. push ( BevyManifest :: parse_str ( subcrate) ) ;
111
+ syn:: Path {
112
+ leading_colon : None ,
113
+ segments,
114
+ }
115
+ } )
116
+ . or_else ( || self . maybe_get_path ( & format ! ( "bevy_{subcrate}" ) ) )
117
+ }
106
118
}
107
119
108
120
/// Derive a label trait
You can’t perform that action at this time.
0 commit comments