-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da468b1
commit b4aab00
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::fmt::Debug; | ||
use std::process::Command; | ||
use std::sync::Arc; | ||
|
||
use async_trait::async_trait; | ||
use fluvio_extension_common::Terminal; | ||
use clap::Parser; | ||
use fluvio::Fluvio; | ||
|
||
use crate::Result; | ||
use crate::client::cmd::ClientCmd; | ||
|
||
/// Builds the SmartModule in the current working directory into a WASM file | ||
#[derive(Debug, Parser)] | ||
pub struct BuildSmartModuleOpt; | ||
|
||
#[async_trait] | ||
impl ClientCmd for BuildSmartModuleOpt { | ||
async fn process_client<O: Terminal + Debug + Send + Sync>( | ||
self, | ||
_out: Arc<O>, | ||
_fluvio: &Fluvio, | ||
) -> Result<()> { | ||
let mut cmd = Command::new("cargo"); | ||
let cwd = std::env::current_dir()?; | ||
|
||
cmd.current_dir(cwd) | ||
.arg("build") | ||
.arg("--release") | ||
.arg("--lib"); | ||
cmd.arg("--target").arg("wasm32-unknown-unknown"); | ||
|
||
let status = cmd.status()?; | ||
|
||
if status.success() { | ||
return Ok(()); | ||
} | ||
|
||
panic!("An error ocurred running \"cargo run\"!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters