From b633e90f7e1676f04fd8ddfcfcc12a8d964543f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20P=C5=82askonka?= Date: Fri, 24 May 2024 13:39:28 +0200 Subject: [PATCH] When in workspace, build will pass package name to cargo. --- src/actions/build.rs | 1 + src/command.rs | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/actions/build.rs b/src/actions/build.rs index 59505da..df7fb99 100644 --- a/src/actions/build.rs +++ b/src/actions/build.rs @@ -48,6 +48,7 @@ impl BuildAction<'_> { self.project.project_root(), &contract.struct_name(), &module_name, + self.project.is_workspace(), ); let source = paths::wasm_path_in_target(&build_contract, self.project.project_root()); let target = diff --git a/src/command.rs b/src/command.rs index 2185dd8..9b77299 100644 --- a/src/command.rs +++ b/src/command.rs @@ -119,20 +119,26 @@ fn cargo(current_dir: PathBuf, command: &str, tail_args: Vec<&str>) { } /// Build wasm files. -pub fn cargo_build_wasm_files(current_dir: PathBuf, contract_name: &str, module_name: &str) { +pub fn cargo_build_wasm_files( + current_dir: PathBuf, + contract_name: &str, + module_name: &str, + is_workspace: bool, +) { env::set_var(ODRA_MODULE_ENV_KEY, contract_name); let build_contract = format!("{}_build_contract", module_name); - cargo( - current_dir, - "build", - vec![ - "--target", - "wasm32-unknown-unknown", - "--bin", - &build_contract, - "--release", - ], - ); + let mut params = vec![ + "--target", + "wasm32-unknown-unknown", + "--bin", + &build_contract, + "--release", + ]; + if is_workspace { + params.push("--package"); + params.push(module_name); + } + cargo(current_dir, "build", params); } /// Build schema files.