Added umd switch

This commit is contained in:
Sharad Chand 2018-04-04 20:06:53 +05:45
parent 9723fdd69b
commit 3a83b02de0
2 changed files with 15 additions and 5 deletions

View File

@ -17,6 +17,7 @@ pub struct Bindgen {
path: Option<PathBuf>, path: Option<PathBuf>,
nodejs: bool, nodejs: bool,
browser: bool, browser: bool,
umd: bool,
debug: bool, debug: bool,
typescript: bool, typescript: bool,
} }
@ -36,6 +37,7 @@ impl Bindgen {
path: None, path: None,
nodejs: false, nodejs: false,
browser: false, browser: false,
umd: false,
debug: false, debug: false,
typescript: false, typescript: false,
} }
@ -56,6 +58,11 @@ impl Bindgen {
self self
} }
pub fn umd(&mut self, umd: bool) -> &mut Bindgen {
self.umd = umd;
self
}
pub fn debug(&mut self, debug: bool) -> &mut Bindgen { pub fn debug(&mut self, debug: bool) -> &mut Bindgen {
self.debug = debug; self.debug = debug;
self self

View File

@ -22,6 +22,7 @@ Options:
--out-dir DIR Output directory --out-dir DIR Output directory
--nodejs Generate output that only works in node.js --nodejs Generate output that only works in node.js
--browser Generate output that only works in a browser --browser Generate output that only works in a browser
--umd Generate output that works both in browser and node.js
--typescript Output a TypeScript definition file --typescript Output a TypeScript definition file
--debug Include otherwise-extraneous debug checks in output --debug Include otherwise-extraneous debug checks in output
-V --version Print the version number of wasm-bindgen -V --version Print the version number of wasm-bindgen
@ -31,6 +32,7 @@ Options:
struct Args { struct Args {
flag_nodejs: bool, flag_nodejs: bool,
flag_browser: bool, flag_browser: bool,
flag_umd: bool,
flag_typescript: bool, flag_typescript: bool,
flag_out_dir: Option<PathBuf>, flag_out_dir: Option<PathBuf>,
flag_debug: bool, flag_debug: bool,
@ -45,7 +47,7 @@ fn main() {
if args.flag_version { if args.flag_version {
println!("wasm-bindgen {}", wasm_bindgen_shared::version()); println!("wasm-bindgen {}", wasm_bindgen_shared::version());
return return;
} }
let input = match args.arg_input { let input = match args.arg_input {
@ -55,10 +57,11 @@ fn main() {
let mut b = Bindgen::new(); let mut b = Bindgen::new();
b.input_path(&input) b.input_path(&input)
.nodejs(args.flag_nodejs) .nodejs(args.flag_nodejs)
.browser(args.flag_browser) .browser(args.flag_browser)
.debug(args.flag_debug) .umd(args.flag_umd)
.typescript(args.flag_typescript); .debug(args.flag_debug)
.typescript(args.flag_typescript);
let out_dir = match args.flag_out_dir { let out_dir = match args.flag_out_dir {
Some(ref p) => p, Some(ref p) => p,