@@ -64,7 +64,7 @@ pub fn build_root_and_contract_dependencies(features: Vec<String>) -> Vec<PathBu
6464 env:: set_var ( "INK_RUSTC_WRAPPER" , rustc_wrapper) ;
6565 }
6666 }
67- build_contracts ( & contract_manifests, features)
67+ build_contracts ( & contract_manifests, features, contract_project . target_dir )
6868}
6969
7070/// Access manifest paths of contracts which are part of the project in which the E2E
@@ -80,7 +80,7 @@ impl ContractProject {
8080 fn new ( ) -> Self {
8181 let mut cmd = cargo_metadata:: MetadataCommand :: new ( ) ;
8282 let env_target_dir = env:: var_os ( "CARGO_TARGET_DIR" )
83- . map ( |target_dir| PathBuf :: from ( target_dir ) )
83+ . map ( PathBuf :: from)
8484 . filter ( |target_dir| target_dir. is_absolute ( ) ) ;
8585 if let Some ( target_dir) = env_target_dir. as_ref ( ) {
8686 cmd. env ( "CARGO_TARGET_DIR" , target_dir) ;
@@ -126,7 +126,7 @@ impl ContractProject {
126126
127127 let package_abi = metadata
128128 . root_package ( )
129- . and_then ( |package| package_abi ( package ) )
129+ . and_then ( package_abi)
130130 . and_then ( Result :: ok) ;
131131 log_info ( & format ! ( "found root package abi: {:?}" , package_abi) ) ;
132132
@@ -170,6 +170,7 @@ impl ContractProject {
170170fn build_contracts (
171171 contract_manifests : & [ PathBuf ] ,
172172 features : Vec < String > ,
173+ target_dir : PathBuf ,
173174) -> Vec < PathBuf > {
174175 static CONTRACT_BUILD_JOBS : OnceLock < Mutex < HashMap < PathBuf , PathBuf > > > =
175176 OnceLock :: new ( ) ;
@@ -183,7 +184,8 @@ fn build_contracts(
183184 let contract_binary_path = match contract_build_jobs. entry ( manifest. clone ( ) ) {
184185 Entry :: Occupied ( entry) => entry. get ( ) . clone ( ) ,
185186 Entry :: Vacant ( entry) => {
186- let contract_binary_path = build_contract ( manifest, features. clone ( ) ) ;
187+ let contract_binary_path =
188+ build_contract ( manifest, features. clone ( ) , target_dir. clone ( ) ) ;
187189 entry. insert ( contract_binary_path. clone ( ) ) ;
188190 contract_binary_path
189191 }
@@ -196,31 +198,27 @@ fn build_contracts(
196198/// Builds the contract at `manifest_path`, returns the path to the contract
197199/// PolkaVM build artifact.
198200fn build_contract (
199- path_to_cargo_toml : & Path ,
200- additional_features : Vec < String > ,
201+ cargo_toml : & Path ,
202+ features : Vec < String > ,
203+ target_dir : PathBuf ,
201204) -> PathBuf {
202- let manifest_path = ManifestPath :: new ( path_to_cargo_toml) . unwrap_or_else ( |err| {
203- panic ! (
204- "Invalid manifest path {}: {err}" ,
205- path_to_cargo_toml. display( )
206- )
205+ let manifest_path = ManifestPath :: new ( cargo_toml) . unwrap_or_else ( |err| {
206+ panic ! ( "Invalid manifest path {}: {err}" , cargo_toml. display( ) )
207207 } ) ;
208- // todo add method in Features to just construct with new(features)
209- let mut features = Features :: default ( ) ;
210- additional_features. iter ( ) . for_each ( |f| features. push ( f) ) ;
211208 let args = ExecuteArgs {
212209 manifest_path,
213210 verbosity : Verbosity :: Default ,
214211 build_mode : BuildMode :: Debug ,
215- features,
212+ features : Features :: from ( features ) ,
216213 network : Network :: Online ,
217- build_artifact : BuildArtifacts :: All ,
214+ build_artifact : BuildArtifacts :: CodeOnly ,
218215 unstable_flags : UnstableFlags :: default ( ) ,
219216 keep_debug_symbols : false ,
220217 extra_lints : false ,
221218 output_type : OutputType :: HumanReadable ,
222219 image : ImageVariant :: Default ,
223220 metadata_spec : None ,
221+ target_dir : Some ( target_dir) ,
224222 } ;
225223
226224 match contract_build:: execute ( args) {
@@ -232,10 +230,7 @@ fn build_contract(
232230 . expect ( "Invalid dest bundle path" )
233231 }
234232 Err ( err) => {
235- panic ! (
236- "contract build for {} failed: {err}" ,
237- path_to_cargo_toml. display( )
238- )
233+ panic ! ( "contract build for {} failed: {err}" , cargo_toml. display( ) )
239234 }
240235 }
241236}
0 commit comments