Skip to content

Commit a57d0a0

Browse files
committed
build(snip): hidde snip into build
1 parent a0ce253 commit a57d0a0

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

src/command/build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,20 @@ impl Build {
245245
);
246246
Ok(())
247247
}
248+
249+
fn set_run_wasm_snip(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
250+
let msg = format!("{}Running WASM-opt...", emoji::RUNNER);
251+
PBAR.step(step, &msg);
252+
253+
snip::set_run_wasm_snip(
254+
// FIXME(csmoe) add wasm_snip_config() in build
255+
self.wasm_snip_config(),
256+
)?;
257+
info!(
258+
&log,
259+
"wasm bindings were snipped at {:#?}.",
260+
&self.crate_path.join("pkg")
261+
);
262+
Ok(())
263+
}
248264
}

src/command/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mod build;
44
mod login;
55
mod pack;
66
mod publish;
7-
mod snip;
87
pub mod utils;
98

109
use self::build::{Build, BuildMode, BuildOptions};
@@ -72,10 +71,6 @@ pub enum Command {
7271
/// strategies besides classic username/password entry in legacy npm.
7372
auth_type: Option<String>,
7473
},
75-
76-
#[structopt(name = "snip")]
77-
/// Replace a wasm function with an `unreachable`.
78-
Snip(SnipOptions),
7974
}
8075

8176
/// Run a command with the given logger!
@@ -119,10 +114,6 @@ pub fn run_wasm_pack(command: Command, log: &Logger) -> result::Result<(), Error
119114
);
120115
login(registry, scope, always_auth, auth_type, &log)
121116
}
122-
Command::Snip(opts) => {
123-
info!(&log, "Running snip command...");
124-
snip(opts)
125-
}
126117
};
127118

128119
match status {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub mod manifest;
3232
pub mod npm;
3333
pub mod progressbar;
3434
pub mod readme;
35+
pub mod snip;
3536

3637
use progressbar::ProgressOutput;
3738

src/command/snip.rs renamed to src/snip.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use parity_wasm::elements::{self, Serialize};
33
use wasm_snip;
44

55
#[derive(Clone, Debug, StructOpt)]
6-
pub struct SnipOptions {
6+
pub struct WasmSnipConfig {
77
input: String,
88
#[structopt(long = "output", short = "o")]
99
pub(crate) output: Option<String>,
@@ -16,7 +16,7 @@ pub struct SnipOptions {
1616
snip_rust_panicking_code: bool,
1717
}
1818

19-
impl Into<wasm_snip::Options> for SnipOptions {
19+
impl Into<wasm_snip::Options> for WasmSnipConfig {
2020
fn into(self) -> wasm_snip::Options {
2121
wasm_snip::Options {
2222
input: ::std::path::PathBuf::from(self.input),
@@ -28,7 +28,7 @@ impl Into<wasm_snip::Options> for SnipOptions {
2828
}
2929
}
3030

31-
pub(crate) fn snip(opts: SnipOptions) -> Result<(), Error> {
31+
pub(crate) fn run_wasm_snip(opts: WasmSnipConfig) -> Result<(), Error> {
3232
let module = wasm_snip::snip(opts.clone().into())?;
3333

3434
if let Some(output) = opts.output {

0 commit comments

Comments
 (0)