Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for building contracts in workspace #87

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
5 changes: 4 additions & 1 deletion src/actions/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ impl BuildAction<'_> {
self.project.project_root(),
&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());
Expand All @@ -62,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);
Expand Down
31 changes: 19 additions & 12 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,27 @@ 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,
crate_name: String,
) {
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(crate_name.as_str());
}
cargo(current_dir, "build", params);
}

/// Build schema files.
Expand Down
Loading