Skip to content

Commit

Permalink
Merge pull request #1539 from multiversx/sc-meta-install-wasm32
Browse files Browse the repository at this point in the history
sc-meta install wasm32 target and wasm-opt
  • Loading branch information
laurci authored Apr 5, 2024
2 parents 605aa85 + 595709d commit 3aa7d70
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
12 changes: 12 additions & 0 deletions framework/meta/src/cli_args/cli_args_standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ pub enum InstallCommand {

#[command(about = "Installs the `mx-scenario-go` tool")]
MxScenarioGo(InstallMxScenarioGoArgs),

#[command(name = "wasm32", about = "Installs the `wasm32` target")]
Wasm32(InstallWasm32Args),

#[command(name = "wasm-opt", about = "Installs the `wasm-opt` tool")]
WasmOpt(InstallWasmOptArgs),
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
Expand All @@ -315,3 +321,9 @@ pub struct InstallMxScenarioGoArgs {
#[arg(long, verbatim_doc_comment)]
pub tag: Option<String>,
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
pub struct InstallWasm32Args {}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
pub struct InstallWasmOptArgs {}
17 changes: 16 additions & 1 deletion framework/meta/src/cmd/standalone/install.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
mod install_scenario_go;
mod install_wasm_tools;
mod system_info;

use crate::cli_args::{InstallArgs, InstallCommand, InstallMxScenarioGoArgs};
use crate::cli_args::{
InstallArgs, InstallCommand, InstallMxScenarioGoArgs, InstallWasm32Args, InstallWasmOptArgs,
};

use self::install_scenario_go::ScenarioGoInstaller;

Expand All @@ -14,11 +17,23 @@ pub fn install(args: &InstallArgs) {
match command {
InstallCommand::All => {
install_scenario_go(&InstallMxScenarioGoArgs::default());
install_wasm32(&InstallWasm32Args::default());
install_wasm_opt(&InstallWasmOptArgs::default());
},
InstallCommand::MxScenarioGo(sg_args) => install_scenario_go(sg_args),
InstallCommand::Wasm32(wam32_args) => install_wasm32(wam32_args),
InstallCommand::WasmOpt(wasm_opt_args) => install_wasm_opt(wasm_opt_args),
}
}

fn install_scenario_go(sg_args: &InstallMxScenarioGoArgs) {
ScenarioGoInstaller::new(sg_args.tag.clone()).install();
}

fn install_wasm32(_wasm32_args: &InstallWasm32Args) {
install_wasm_tools::install_wasm32_target();
}

fn install_wasm_opt(_wasm_opt_args: &InstallWasmOptArgs) {
install_wasm_tools::install_wasm_opt();
}
23 changes: 23 additions & 0 deletions framework/meta/src/cmd/standalone/install/install_wasm_tools.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::process::Command;

pub fn install_wasm32_target() {
let cmd = Command::new("rustup")
.args(vec!["target", "add", "wasm32-unknown-unknown"])
.status()
.expect("failed to execute `rustup`");

assert!(cmd.success(), "failed to install wasm32 target");

println!("wasm32 target installed successfully");
}

pub fn install_wasm_opt() {
let cmd = Command::new("cargo")
.args(vec!["install", "wasm-opt"])
.status()
.expect("failed to execute `cargo`");

assert!(cmd.success(), "failed to install wasm-opt");

println!("wasm-opt installed successfully");
}

0 comments on commit 3aa7d70

Please sign in to comment.