summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/main.rs5
-rw-r--r--cli/tests/integration_tests.rs26
-rw-r--r--cli/tools/standalone.rs23
3 files changed, 46 insertions, 8 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 2b958ff55..93639d34f 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -344,7 +344,7 @@ async fn compile_command(
// Select base binary based on `target` and `lite` arguments
let original_binary =
- tools::standalone::get_base_binary(deno_dir, target, lite).await?;
+ tools::standalone::get_base_binary(deno_dir, target.clone(), lite).await?;
let final_bin = tools::standalone::create_standalone_binary(
original_binary,
@@ -354,7 +354,8 @@ async fn compile_command(
info!("{} {}", colors::green("Emit"), output.display());
- tools::standalone::write_standalone_binary(output.clone(), final_bin).await?;
+ tools::standalone::write_standalone_binary(output.clone(), target, final_bin)
+ .await?;
Ok(())
}
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index c6ccf3ba0..de5cc6aae 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -7,6 +7,7 @@ use deno_runtime::deno_fetch::reqwest;
use deno_runtime::deno_websocket::tokio_tungstenite;
use std::fs;
use std::io::{BufRead, Read, Write};
+use std::path::Path;
use std::process::Command;
use tempfile::TempDir;
use test_util as util;
@@ -5248,6 +5249,31 @@ console.log("finish");
}
#[test]
+ #[cfg(windows)]
+ // https://github.com/denoland/deno/issues/9667
+ fn compile_windows_ext() {
+ let dir = TempDir::new().expect("tempdir fail");
+ let exe = dir.path().join("welcome_9667");
+ let output = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("compile")
+ .arg("--unstable")
+ .arg("--output")
+ .arg(&exe)
+ .arg("--target")
+ .arg("x86_64-unknown-linux-gnu")
+ .arg("./test_util/std/examples/welcome.ts")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ assert!(output.status.success());
+ let exists = Path::new(&exe).exists();
+ assert!(exists, true);
+ }
+
+ #[test]
fn standalone_args() {
let dir = TempDir::new().expect("tempdir fail");
let exe = if cfg!(windows) {
diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs
index 884d2a31d..062b80732 100644
--- a/cli/tools/standalone.rs
+++ b/cli/tools/standalone.rs
@@ -129,14 +129,25 @@ pub fn create_standalone_binary(
/// is not already standalone binary it will return error instead.
pub async fn write_standalone_binary(
output: PathBuf,
+ target: Option<String>,
final_bin: Vec<u8>,
) -> Result<(), AnyError> {
- let output =
- if cfg!(windows) && output.extension().unwrap_or_default() != "exe" {
- PathBuf::from(output.display().to_string() + ".exe")
- } else {
- output
- };
+ let output = match target {
+ Some(target) => {
+ if target.contains("windows") {
+ PathBuf::from(output.display().to_string() + ".exe")
+ } else {
+ output
+ }
+ }
+ None => {
+ if cfg!(windows) && output.extension().unwrap_or_default() != "exe" {
+ PathBuf::from(output.display().to_string() + ".exe")
+ } else {
+ output
+ }
+ }
+ };
if output.exists() {
// If the output is a directory, throw error