Skip to content

Commit

Permalink
When in workspace, build will pass package name to cargo.
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaplas committed May 24, 2024
1 parent a668180 commit b633e90
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/actions/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
30 changes: 18 additions & 12 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b633e90

Please sign in to comment.