@@ -34,6 +34,7 @@ pub struct Crate {
34
34
pub ( crate ) target : Option < String > ,
35
35
pub ( crate ) out_dir : Option < AbsPathBuf > ,
36
36
pub ( crate ) proc_macro_dylib_path : Option < AbsPathBuf > ,
37
+ pub ( crate ) is_workspace_member : bool ,
37
38
}
38
39
39
40
impl ProjectJson {
@@ -43,32 +44,42 @@ impl ProjectJson {
43
44
crates : data
44
45
. crates
45
46
. into_iter ( )
46
- . map ( |crate_data| Crate {
47
- root_module : base. join ( crate_data. root_module ) ,
48
- edition : crate_data. edition . into ( ) ,
49
- deps : crate_data
50
- . deps
51
- . into_iter ( )
52
- . map ( |dep_data| Dependency {
53
- crate_id : CrateId ( dep_data. krate as u32 ) ,
54
- name : dep_data. name ,
55
- } )
56
- . collect :: < Vec < _ > > ( ) ,
57
- cfg : {
58
- let mut cfg = CfgOptions :: default ( ) ;
59
- for entry in & crate_data. cfg {
60
- match split_delim ( entry, '=' ) {
61
- Some ( ( key, value) ) => {
62
- cfg. insert_key_value ( key. into ( ) , value. into ( ) ) ;
47
+ . map ( |crate_data| {
48
+ let is_workspace_member = crate_data. is_workspace_member . unwrap_or_else ( || {
49
+ crate_data. root_module . is_relative ( )
50
+ && !crate_data. root_module . starts_with ( ".." )
51
+ || crate_data. root_module . starts_with ( base)
52
+ } ) ;
53
+ Crate {
54
+ root_module : base. join ( crate_data. root_module ) ,
55
+ edition : crate_data. edition . into ( ) ,
56
+ deps : crate_data
57
+ . deps
58
+ . into_iter ( )
59
+ . map ( |dep_data| Dependency {
60
+ crate_id : CrateId ( dep_data. krate as u32 ) ,
61
+ name : dep_data. name ,
62
+ } )
63
+ . collect :: < Vec < _ > > ( ) ,
64
+ cfg : {
65
+ let mut cfg = CfgOptions :: default ( ) ;
66
+ for entry in & crate_data. cfg {
67
+ match split_delim ( entry, '=' ) {
68
+ Some ( ( key, value) ) => {
69
+ cfg. insert_key_value ( key. into ( ) , value. into ( ) ) ;
70
+ }
71
+ None => cfg. insert_atom ( entry. into ( ) ) ,
63
72
}
64
- None => cfg. insert_atom ( entry. into ( ) ) ,
65
73
}
66
- }
67
- cfg
68
- } ,
69
- target : crate_data. target ,
70
- out_dir : crate_data. out_dir . map ( |it| base. join ( it) ) ,
71
- proc_macro_dylib_path : crate_data. proc_macro_dylib_path . map ( |it| base. join ( it) ) ,
74
+ cfg
75
+ } ,
76
+ target : crate_data. target ,
77
+ out_dir : crate_data. out_dir . map ( |it| base. join ( it) ) ,
78
+ proc_macro_dylib_path : crate_data
79
+ . proc_macro_dylib_path
80
+ . map ( |it| base. join ( it) ) ,
81
+ is_workspace_member,
82
+ }
72
83
} )
73
84
. collect :: < Vec < _ > > ( ) ,
74
85
}
@@ -91,6 +102,7 @@ struct CrateData {
91
102
target : Option < String > ,
92
103
out_dir : Option < PathBuf > ,
93
104
proc_macro_dylib_path : Option < PathBuf > ,
105
+ is_workspace_member : Option < bool > ,
94
106
}
95
107
96
108
#[ derive( Deserialize ) ]
0 commit comments