@@ -43,7 +43,18 @@ pub fn build_contracts() -> BundleProviderGenerator {
43
43
)
44
44
}
45
45
46
- fn get_contract_crates ( metadata : & Metadata ) -> ( Option < & Package > , impl Iterator < Item = & Package > ) {
46
+ /// Contract package together with the features it should be built with.
47
+ struct FeaturedPackage < ' metadata > {
48
+ package : & ' metadata Package ,
49
+ features_on : Vec < String > ,
50
+ }
51
+
52
+ fn get_contract_crates (
53
+ metadata : & Metadata ,
54
+ ) -> (
55
+ Option < FeaturedPackage > ,
56
+ impl Iterator < Item = FeaturedPackage > ,
57
+ ) {
47
58
let pkg_lookup = |id| {
48
59
metadata
49
60
. packages
@@ -64,7 +75,14 @@ fn get_contract_crates(metadata: &Metadata) -> (Option<&Package>, impl Iterator<
64
75
node. features
65
76
. contains ( & INK_AS_DEPENDENCY_FEATURE . to_string ( ) )
66
77
} )
67
- . map ( move |node| pkg_lookup ( node. id . clone ( ) ) ) ;
78
+ . map ( move |node| {
79
+ let mut features_on = node. features . clone ( ) ;
80
+ features_on. retain ( |feature| feature != INK_AS_DEPENDENCY_FEATURE && feature != "std" ) ;
81
+ FeaturedPackage {
82
+ package : pkg_lookup ( node. id . clone ( ) ) ,
83
+ features_on,
84
+ }
85
+ } ) ;
68
86
69
87
let root = dep_graph
70
88
. root
@@ -75,13 +93,20 @@ fn get_contract_crates(metadata: &Metadata) -> (Option<&Package>, impl Iterator<
75
93
(
76
94
root. features
77
95
. contains_key ( INK_AS_DEPENDENCY_FEATURE )
78
- . then_some ( root) ,
96
+ . then_some ( FeaturedPackage {
97
+ package : root,
98
+ features_on : vec ! [ ] ,
99
+ } ) ,
79
100
contract_deps,
80
101
)
81
102
}
82
103
83
- fn build_contract_crate ( pkg : & Package ) -> ( String , PathBuf ) {
84
- let manifest_path = get_manifest_path ( pkg) ;
104
+ fn build_contract_crate ( pkg : FeaturedPackage ) -> ( String , PathBuf ) {
105
+ let manifest_path = get_manifest_path ( pkg. package ) ;
106
+ let mut features = Features :: default ( ) ;
107
+ for feature in pkg. features_on {
108
+ features. push ( & feature) ;
109
+ }
85
110
86
111
match CONTRACTS_BUILT
87
112
. get_or_init ( || Mutex :: new ( HashMap :: new ( ) ) )
@@ -95,7 +120,7 @@ fn build_contract_crate(pkg: &Package) -> (String, PathBuf) {
95
120
manifest_path,
96
121
verbosity : Verbosity :: Default ,
97
122
build_mode : BuildMode :: Release ,
98
- features : Features :: default ( ) ,
123
+ features,
99
124
network : Network :: Online ,
100
125
build_artifact : BuildArtifacts :: All ,
101
126
unstable_flags : UnstableFlags :: default ( ) ,
@@ -115,7 +140,7 @@ fn build_contract_crate(pkg: &Package) -> (String, PathBuf) {
115
140
. expect ( "Metadata should have been generated" )
116
141
. dest_bundle ;
117
142
118
- let new_entry = ( pkg. name . clone ( ) , bundle_path) ;
143
+ let new_entry = ( pkg. package . name . clone ( ) , bundle_path) ;
119
144
todo. insert ( new_entry. clone ( ) ) ;
120
145
new_entry
121
146
}
0 commit comments