diff options
Diffstat (limited to 'cli/flags.rs')
-rw-r--r-- | cli/flags.rs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 9fe25df50..754ccec84 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -29,6 +29,8 @@ pub enum DenoSubcommand { source_file: String, output: Option<PathBuf>, args: Vec<String>, + target: Option<String>, + lite: bool, }, Completions { buf: Box<[u8]>, @@ -447,11 +449,15 @@ fn compile_parse(flags: &mut Flags, matches: &clap::ArgMatches) { let args = script.split_off(1); let source_file = script[0].to_string(); let output = matches.value_of("output").map(PathBuf::from); + let lite = matches.is_present("lite"); + let target = matches.value_of("target").map(String::from); flags.subcommand = DenoSubcommand::Compile { source_file, output, args, + lite, + target, }; } @@ -893,11 +899,24 @@ fn compile_subcommand<'a, 'b>() -> App<'a, 'b> { .help("Output file (defaults to $PWD/<inferred-name>)") .takes_value(true) ) + .arg( + Arg::with_name("target") + .long("target") + .help("Target OS architecture") + .takes_value(true) + .possible_values(&["x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-apple-darwin"]) + ) + .arg( + Arg::with_name("lite") + .long("lite") + .help("Use lite runtime") + ) .about("Compile the script into a self contained executable") .long_about( "Compiles the given script into a self contained executable. - deno compile --unstable https://deno.land/std/http/file_server.ts + deno compile --unstable -A https://deno.land/std/http/file_server.ts deno compile --unstable --output /usr/local/bin/color_util https://deno.land/std/examples/colors.ts + deno compile --unstable --lite --target x86_64-unknown-linux-gnu -A https://deno.land/std/http/file_server.ts Any flags passed which affect runtime behavior, such as '--unstable', '--allow-*', '--v8-flags', etc. are encoded into the output executable and used @@ -910,8 +929,13 @@ The executable name is inferred by default: and the path has no parent, take the file name of the parent path. Otherwise settle with the generic name. - If the resulting name has an '@...' suffix, strip it. + +This commands supports cross-compiling to different target architectures using `--target` flag. +On the first invocation with deno will download proper binary and cache it in $DENO_DIR. -Cross compiling binaries for different platforms is not currently possible.", +It is possible to use \"lite\" binaries when compiling by passing `--lite` flag; these are stripped down versions +of the deno binary that do not contain built-in tooling (eg. formatter, linter). This feature is experimental. +", ) } @@ -3318,6 +3342,7 @@ mod tests { let r = flags_from_vec(svec![ "deno", "compile", + "--lite", "https://deno.land/std/examples/colors.ts" ]); assert_eq!( @@ -3327,6 +3352,8 @@ mod tests { source_file: "https://deno.land/std/examples/colors.ts".to_string(), output: None, args: vec![], + target: None, + lite: true, }, ..Flags::default() } @@ -3344,6 +3371,8 @@ mod tests { source_file: "https://deno.land/std/examples/colors.ts".to_string(), output: Some(PathBuf::from("colors")), args: svec!["foo", "bar"], + target: None, + lite: false, }, unstable: true, import_map_path: Some("import_map.json".to_string()), |