Skip to content

Commit 2f266f9

Browse files
committed
build(snip): hidde snip into build
1 parent 75d44c7 commit 2f266f9

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

src/command/build.rs

+16
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,20 @@ impl Build {
311311
info!(&log, "wasm bindings were built at {:#?}.", &self.out_dir);
312312
Ok(())
313313
}
314+
315+
fn set_run_wasm_snip(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
316+
let msg = format!("{}Running WASM-opt...", emoji::RUNNER);
317+
PBAR.step(step, &msg);
318+
319+
snip::set_run_wasm_snip(
320+
// FIXME(csmoe) add wasm_snip_config() in build
321+
self.wasm_snip_config(),
322+
)?;
323+
info!(
324+
&log,
325+
"wasm bindings were snipped at {:#?}.",
326+
&self.crate_path.join("pkg")
327+
);
328+
Ok(())
329+
}
314330
}

src/command/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
pub mod build;
44
mod login;
55
mod pack;
6+
<<<<<<< HEAD
67
/// Data structures and functions for publishing a package.
78
pub mod publish;
89
pub mod test;
910
mod snip;
11+
||||||| merged common ancestors
12+
mod publish;
13+
mod snip;
14+
=======
15+
mod publish;
16+
>>>>>>> build(snip): hidde snip into build
1017
pub mod utils;
1118

1219
use self::build::{Build, BuildOptions};
@@ -84,6 +91,9 @@ pub enum Command {
8491
/// 👩‍🔬 test your wasm!
8592
Test(TestOptions),
8693

94+
#[structopt(name = "snip")]
95+
/// Replace a wasm function with an `unreachable`.
96+
8797
#[structopt(name = "snip")]
8898
/// Replace a wasm function with an `unreachable`.
8999
Snip(SnipOptions),
@@ -125,18 +135,14 @@ pub fn run_wasm_pack(command: Command, log: &Logger) -> result::Result<(), failu
125135
);
126136
login(registry, scope, always_auth, auth_type, &log)
127137
}
128-
<<<<<<< HEAD
129138
Command::Test(test_opts) => {
130139
info!(&log, "Running test command...");
131140
Test::try_from_opts(test_opts).and_then(|t| t.run(&log))
132141
}
133-
||||||| merged common ancestors
134-
=======
135142
Command::Snip(opts) => {
136143
info!(&log, "Running snip command...");
137144
snip(opts)
138145
}
139-
>>>>>>> cmd(snip): rebase
140146
};
141147

142148
match status {

src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ pub mod manifest;
4141
pub mod npm;
4242
pub mod progressbar;
4343
pub mod readme;
44+
<<<<<<< HEAD
4445
pub mod target;
4546
pub mod test;
47+
||||||| merged common ancestors
48+
=======
49+
pub mod snip;
50+
>>>>>>> build(snip): hidde snip into build
4651

4752
use progressbar::ProgressOutput;
4853

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

+3-3
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)