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 1/2] 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. From 9db54ed9f6f8fad4e96d6b38f00781d468774b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20P=C5=82askonka?= Date: Fri, 24 May 2024 13:50:14 +0200 Subject: [PATCH 2/2] Updated Odra branch constant. --- justfile | 2 +- src/actions/build.rs | 4 +++- src/command.rs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index 9048741..b84aacb 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,4 @@ -DEVELOPMENT_ODRA_BRANCH := "release/1.0.0" +DEVELOPMENT_ODRA_BRANCH := "release/1.1.0" BINARYEN_VERSION := "version_116" BINARYEN_CHECKSUM := "c55b74f3109cdae97490faf089b0286d3bba926bb6ea5ed00c8c784fc53718fd" diff --git a/src/actions/build.rs b/src/actions/build.rs index df7fb99..5c3b122 100644 --- a/src/actions/build.rs +++ b/src/actions/build.rs @@ -49,7 +49,9 @@ impl BuildAction<'_> { &contract.struct_name(), &module_name, self.project.is_workspace(), + contract.module_crate_name(self.project), ); + let source = paths::wasm_path_in_target(&build_contract, self.project.project_root()); let target = paths::wasm_path_in_wasm_dir(&contract.struct_name(), &self.project.project_root()); @@ -63,7 +65,7 @@ impl BuildAction<'_> { .join(contract.module_crate_name(self.project)) .join("wasm"); command::mkdir(module_wasm_dir.clone()); - let mut module_wasm_path = module_wasm_dir.clone().join(&contract.struct_name()); + let mut module_wasm_path = module_wasm_dir.clone().join(contract.struct_name()); module_wasm_path.set_extension("wasm"); log::info(format!("Copying to {}", module_wasm_path.display())); command::cp(source, module_wasm_path); diff --git a/src/command.rs b/src/command.rs index 9b77299..0e58e01 100644 --- a/src/command.rs +++ b/src/command.rs @@ -124,6 +124,7 @@ pub fn cargo_build_wasm_files( contract_name: &str, module_name: &str, is_workspace: bool, + crate_name: String, ) { env::set_var(ODRA_MODULE_ENV_KEY, contract_name); let build_contract = format!("{}_build_contract", module_name); @@ -136,7 +137,7 @@ pub fn cargo_build_wasm_files( ]; if is_workspace { params.push("--package"); - params.push(module_name); + params.push(crate_name.as_str()); } cargo(current_dir, "build", params); }