Skip to content

Commit

Permalink
sc-meta install wasm-opt
Browse files Browse the repository at this point in the history
  • Loading branch information
laurci committed Apr 5, 2024
1 parent 2b6f7a7 commit 595709d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions framework/meta/src/cli_args/cli_args_standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ pub enum InstallCommand {

#[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 @@ -321,3 +324,6 @@ pub struct InstallMxScenarioGoArgs {

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

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

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

use self::install_scenario_go::ScenarioGoInstaller;

Expand All @@ -16,9 +18,11 @@ pub fn install(args: &InstallArgs) {
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),
}
}

Expand All @@ -27,5 +31,9 @@ fn install_scenario_go(sg_args: &InstallMxScenarioGoArgs) {
}

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

fn install_wasm_opt(_wasm_opt_args: &InstallWasmOptArgs) {
install_wasm_tools::install_wasm_opt();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@ pub fn 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 595709d

Please sign in to comment.