2023-01-02 21:00:42 +00:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2021-01-08 02:08:51 +00:00
|
|
|
|
2023-01-18 00:18:24 +00:00
|
|
|
use crate::args::CaData;
|
2022-06-27 20:54:09 +00:00
|
|
|
use crate::args::CompileFlags;
|
2022-12-09 14:40:48 +00:00
|
|
|
use crate::args::Flags;
|
2022-11-26 00:04:30 +00:00
|
|
|
use crate::cache::DenoDir;
|
2022-12-09 14:40:48 +00:00
|
|
|
use crate::graph_util::create_graph_and_maybe_check;
|
|
|
|
use crate::graph_util::error_for_any_npm_specifier;
|
2022-12-13 02:30:44 +00:00
|
|
|
use crate::http_util::HttpClient;
|
2022-02-24 13:28:00 +00:00
|
|
|
use crate::standalone::Metadata;
|
|
|
|
use crate::standalone::MAGIC_TRAILER;
|
2022-11-28 22:28:54 +00:00
|
|
|
use crate::util::path::path_has_trailing_slash;
|
2022-12-14 13:47:18 +00:00
|
|
|
use crate::util::progress_bar::ProgressBar;
|
|
|
|
use crate::util::progress_bar::ProgressBarStyle;
|
2022-02-24 13:28:00 +00:00
|
|
|
use crate::ProcState;
|
2021-11-16 14:02:28 +00:00
|
|
|
use deno_core::anyhow::bail;
|
2022-02-24 13:28:00 +00:00
|
|
|
use deno_core::anyhow::Context;
|
2022-03-28 18:38:15 +00:00
|
|
|
use deno_core::error::generic_error;
|
2021-01-08 02:08:51 +00:00
|
|
|
use deno_core::error::AnyError;
|
2022-03-28 18:38:15 +00:00
|
|
|
use deno_core::resolve_url_or_path;
|
2021-01-08 02:08:51 +00:00
|
|
|
use deno_core::serde_json;
|
2022-02-15 12:33:46 +00:00
|
|
|
use deno_graph::ModuleSpecifier;
|
2022-12-09 14:40:48 +00:00
|
|
|
use deno_runtime::colors;
|
2021-01-19 02:40:22 +00:00
|
|
|
use std::env;
|
2022-12-08 16:50:09 +00:00
|
|
|
use std::fs;
|
2021-01-08 02:08:51 +00:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::Read;
|
|
|
|
use std::io::Seek;
|
|
|
|
use std::io::SeekFrom;
|
|
|
|
use std::io::Write;
|
2021-01-19 02:40:22 +00:00
|
|
|
use std::path::Path;
|
2021-01-08 02:08:51 +00:00
|
|
|
use std::path::PathBuf;
|
2022-12-09 14:40:48 +00:00
|
|
|
use std::sync::Arc;
|
2021-01-08 02:08:51 +00:00
|
|
|
|
2022-03-28 18:38:15 +00:00
|
|
|
use super::installer::infer_name_from_url;
|
|
|
|
|
2022-12-09 14:40:48 +00:00
|
|
|
pub async fn compile(
|
|
|
|
flags: Flags,
|
|
|
|
compile_flags: CompileFlags,
|
|
|
|
) -> Result<(), AnyError> {
|
2023-01-13 21:39:19 +00:00
|
|
|
let ps = ProcState::build(flags).await?;
|
2022-12-09 14:40:48 +00:00
|
|
|
let module_specifier = resolve_url_or_path(&compile_flags.source_file)?;
|
|
|
|
let deno_dir = &ps.dir;
|
|
|
|
|
2023-02-10 15:11:11 +00:00
|
|
|
let output_path =
|
|
|
|
resolve_compile_executable_output_path(&compile_flags).await?;
|
2022-12-09 14:40:48 +00:00
|
|
|
|
|
|
|
let graph = Arc::try_unwrap(
|
|
|
|
create_graph_and_maybe_check(module_specifier.clone(), &ps).await?,
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// at the moment, we don't support npm specifiers in deno_compile, so show an error
|
|
|
|
error_for_any_npm_specifier(&graph)?;
|
|
|
|
|
|
|
|
let parser = ps.parsed_source_cache.as_capturing_parser();
|
|
|
|
let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;
|
|
|
|
|
|
|
|
log::info!(
|
|
|
|
"{} {}",
|
|
|
|
colors::green("Compile"),
|
|
|
|
module_specifier.to_string()
|
|
|
|
);
|
|
|
|
|
|
|
|
// Select base binary based on target
|
|
|
|
let original_binary =
|
2022-12-13 02:30:44 +00:00
|
|
|
get_base_binary(&ps.http_client, deno_dir, compile_flags.target.clone())
|
|
|
|
.await?;
|
2022-12-09 14:40:48 +00:00
|
|
|
|
|
|
|
let final_bin = create_standalone_binary(
|
|
|
|
original_binary,
|
|
|
|
eszip,
|
2023-01-13 21:39:19 +00:00
|
|
|
module_specifier,
|
2022-12-09 14:40:48 +00:00
|
|
|
&compile_flags,
|
|
|
|
ps,
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
log::info!("{} {}", colors::green("Emit"), output_path.display());
|
|
|
|
|
|
|
|
write_standalone_binary(output_path, final_bin).await?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn get_base_binary(
|
2022-12-13 02:30:44 +00:00
|
|
|
client: &HttpClient,
|
2021-01-19 02:40:22 +00:00
|
|
|
deno_dir: &DenoDir,
|
|
|
|
target: Option<String>,
|
|
|
|
) -> Result<Vec<u8>, AnyError> {
|
2021-04-26 17:28:38 +00:00
|
|
|
if target.is_none() {
|
2021-01-19 02:40:22 +00:00
|
|
|
let path = std::env::current_exe()?;
|
|
|
|
return Ok(tokio::fs::read(path).await?);
|
|
|
|
}
|
|
|
|
|
|
|
|
let target = target.unwrap_or_else(|| env!("TARGET").to_string());
|
2023-01-27 15:43:16 +00:00
|
|
|
let binary_name = format!("deno-{target}.zip");
|
2021-01-19 02:40:22 +00:00
|
|
|
|
|
|
|
let binary_path_suffix = if crate::version::is_canary() {
|
|
|
|
format!("canary/{}/{}", crate::version::GIT_COMMIT_HASH, binary_name)
|
|
|
|
} else {
|
|
|
|
format!("release/v{}/{}", env!("CARGO_PKG_VERSION"), binary_name)
|
|
|
|
};
|
|
|
|
|
2022-11-26 00:04:30 +00:00
|
|
|
let download_directory = deno_dir.dl_folder_path();
|
2021-01-19 02:40:22 +00:00
|
|
|
let binary_path = download_directory.join(&binary_path_suffix);
|
|
|
|
|
|
|
|
if !binary_path.exists() {
|
2022-12-13 02:30:44 +00:00
|
|
|
download_base_binary(client, &download_directory, &binary_path_suffix)
|
|
|
|
.await?;
|
2021-01-19 02:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let archive_data = tokio::fs::read(binary_path).await?;
|
2023-01-26 14:02:25 +00:00
|
|
|
let temp_dir = secure_tempfile::TempDir::new()?;
|
|
|
|
let base_binary_path = crate::tools::upgrade::unpack_into_dir(
|
|
|
|
archive_data,
|
|
|
|
target.contains("windows"),
|
|
|
|
&temp_dir,
|
|
|
|
)?;
|
2021-01-19 02:40:22 +00:00
|
|
|
let base_binary = tokio::fs::read(base_binary_path).await?;
|
2023-01-26 14:02:25 +00:00
|
|
|
drop(temp_dir); // delete the temp dir
|
2021-01-19 02:40:22 +00:00
|
|
|
Ok(base_binary)
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn download_base_binary(
|
2022-12-13 02:30:44 +00:00
|
|
|
client: &HttpClient,
|
2021-01-19 02:40:22 +00:00
|
|
|
output_directory: &Path,
|
|
|
|
binary_path_suffix: &str,
|
|
|
|
) -> Result<(), AnyError> {
|
2023-01-27 15:43:16 +00:00
|
|
|
let download_url = format!("https://dl.deno.land/{binary_path_suffix}");
|
2022-12-14 13:47:18 +00:00
|
|
|
let maybe_bytes = {
|
|
|
|
let progress_bars = ProgressBar::new(ProgressBarStyle::DownloadBars);
|
|
|
|
let progress = progress_bars.update(&download_url);
|
2021-01-19 02:40:22 +00:00
|
|
|
|
2022-12-14 13:47:18 +00:00
|
|
|
client
|
|
|
|
.download_with_progress(download_url, &progress)
|
|
|
|
.await?
|
|
|
|
};
|
|
|
|
let bytes = match maybe_bytes {
|
|
|
|
Some(bytes) => bytes,
|
|
|
|
None => {
|
|
|
|
log::info!("Download could not be found, aborting");
|
|
|
|
std::process::exit(1)
|
|
|
|
}
|
2021-01-19 02:40:22 +00:00
|
|
|
};
|
|
|
|
|
2022-11-18 01:59:10 +00:00
|
|
|
std::fs::create_dir_all(output_directory)?;
|
2021-01-19 02:40:22 +00:00
|
|
|
let output_path = output_directory.join(binary_path_suffix);
|
2022-11-18 01:59:10 +00:00
|
|
|
std::fs::create_dir_all(output_path.parent().unwrap())?;
|
2022-12-14 13:47:18 +00:00
|
|
|
tokio::fs::write(output_path, bytes).await?;
|
2021-01-19 02:40:22 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2021-01-08 02:08:51 +00:00
|
|
|
/// This functions creates a standalone deno binary by appending a bundle
|
|
|
|
/// and magic trailer to the currently executing binary.
|
2022-12-09 14:40:48 +00:00
|
|
|
async fn create_standalone_binary(
|
2021-01-19 02:40:22 +00:00
|
|
|
mut original_bin: Vec<u8>,
|
2022-02-15 12:33:46 +00:00
|
|
|
eszip: eszip::EszipV2,
|
|
|
|
entrypoint: ModuleSpecifier,
|
2022-12-08 16:50:09 +00:00
|
|
|
compile_flags: &CompileFlags,
|
2022-02-24 13:28:00 +00:00
|
|
|
ps: ProcState,
|
2021-01-19 02:40:22 +00:00
|
|
|
) -> Result<Vec<u8>, AnyError> {
|
2022-02-15 12:33:46 +00:00
|
|
|
let mut eszip_archive = eszip.into_bytes();
|
|
|
|
|
2023-01-18 00:18:24 +00:00
|
|
|
let ca_data = match ps.options.ca_data() {
|
|
|
|
Some(CaData::File(ca_file)) => {
|
2023-01-27 15:43:16 +00:00
|
|
|
Some(fs::read(ca_file).with_context(|| format!("Reading: {ca_file}"))?)
|
2022-02-24 13:28:00 +00:00
|
|
|
}
|
2023-01-18 00:18:24 +00:00
|
|
|
Some(CaData::Bytes(bytes)) => Some(bytes.clone()),
|
2022-12-08 16:50:09 +00:00
|
|
|
None => None,
|
2022-02-24 13:28:00 +00:00
|
|
|
};
|
2023-01-25 20:13:40 +00:00
|
|
|
let maybe_import_map = ps
|
|
|
|
.options
|
|
|
|
.resolve_import_map(&ps.file_fetcher)
|
|
|
|
.await?
|
|
|
|
.map(|import_map| (import_map.base_url().clone(), import_map.to_json()));
|
2021-01-08 02:08:51 +00:00
|
|
|
let metadata = Metadata {
|
2022-12-08 16:50:09 +00:00
|
|
|
argv: compile_flags.args.clone(),
|
|
|
|
unstable: ps.options.unstable(),
|
|
|
|
seed: ps.options.seed(),
|
|
|
|
location: ps.options.location_flag().clone(),
|
|
|
|
permissions: ps.options.permissions_options(),
|
|
|
|
v8_flags: ps.options.v8_flags().clone(),
|
|
|
|
unsafely_ignore_certificate_errors: ps
|
|
|
|
.options
|
|
|
|
.unsafely_ignore_certificate_errors()
|
2021-08-09 14:53:21 +00:00
|
|
|
.clone(),
|
2022-12-08 16:50:09 +00:00
|
|
|
log_level: ps.options.log_level(),
|
|
|
|
ca_stores: ps.options.ca_stores().clone(),
|
2021-01-08 02:08:51 +00:00
|
|
|
ca_data,
|
2022-02-15 12:33:46 +00:00
|
|
|
entrypoint,
|
2022-02-24 13:28:00 +00:00
|
|
|
maybe_import_map,
|
2021-01-08 02:08:51 +00:00
|
|
|
};
|
|
|
|
let mut metadata = serde_json::to_string(&metadata)?.as_bytes().to_vec();
|
|
|
|
|
2022-02-15 12:33:46 +00:00
|
|
|
let eszip_pos = original_bin.len();
|
|
|
|
let metadata_pos = eszip_pos + eszip_archive.len();
|
2021-01-08 02:08:51 +00:00
|
|
|
let mut trailer = MAGIC_TRAILER.to_vec();
|
2022-02-15 12:33:46 +00:00
|
|
|
trailer.write_all(&eszip_pos.to_be_bytes())?;
|
2021-01-08 02:08:51 +00:00
|
|
|
trailer.write_all(&metadata_pos.to_be_bytes())?;
|
|
|
|
|
2022-02-15 12:33:46 +00:00
|
|
|
let mut final_bin = Vec::with_capacity(
|
|
|
|
original_bin.len() + eszip_archive.len() + trailer.len(),
|
|
|
|
);
|
2021-01-08 02:08:51 +00:00
|
|
|
final_bin.append(&mut original_bin);
|
2022-02-15 12:33:46 +00:00
|
|
|
final_bin.append(&mut eszip_archive);
|
2021-01-08 02:08:51 +00:00
|
|
|
final_bin.append(&mut metadata);
|
|
|
|
final_bin.append(&mut trailer);
|
|
|
|
|
2021-01-19 02:40:22 +00:00
|
|
|
Ok(final_bin)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This function writes out a final binary to specified path. If output path
|
|
|
|
/// is not already standalone binary it will return error instead.
|
2022-12-09 14:40:48 +00:00
|
|
|
async fn write_standalone_binary(
|
2022-03-28 18:38:15 +00:00
|
|
|
output_path: PathBuf,
|
2021-01-19 02:40:22 +00:00
|
|
|
final_bin: Vec<u8>,
|
|
|
|
) -> Result<(), AnyError> {
|
2022-03-28 18:38:15 +00:00
|
|
|
if output_path.exists() {
|
2021-01-08 02:08:51 +00:00
|
|
|
// If the output is a directory, throw error
|
2022-03-28 18:38:15 +00:00
|
|
|
if output_path.is_dir() {
|
2022-03-18 23:18:50 +00:00
|
|
|
bail!(
|
|
|
|
concat!(
|
|
|
|
"Could not compile to file '{}' because a directory exists with ",
|
|
|
|
"the same name. You can use the `--output <file-path>` flag to ",
|
|
|
|
"provide an alternative name."
|
|
|
|
),
|
2022-03-28 18:38:15 +00:00
|
|
|
output_path.display()
|
2022-03-18 23:18:50 +00:00
|
|
|
);
|
2021-01-08 02:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we don't overwrite any file not created by Deno compiler.
|
|
|
|
// Check for magic trailer in last 24 bytes.
|
|
|
|
let mut has_trailer = false;
|
2022-03-28 18:38:15 +00:00
|
|
|
let mut output_file = File::open(&output_path)?;
|
2021-01-08 02:08:51 +00:00
|
|
|
// This seek may fail because the file is too small to possibly be
|
|
|
|
// `deno compile` output.
|
|
|
|
if output_file.seek(SeekFrom::End(-24)).is_ok() {
|
|
|
|
let mut trailer = [0; 24];
|
|
|
|
output_file.read_exact(&mut trailer)?;
|
|
|
|
let (magic_trailer, _) = trailer.split_at(8);
|
|
|
|
has_trailer = magic_trailer == MAGIC_TRAILER;
|
|
|
|
}
|
|
|
|
if !has_trailer {
|
2022-03-18 23:18:50 +00:00
|
|
|
bail!(
|
|
|
|
concat!(
|
|
|
|
"Could not compile to file '{}' because the file already exists ",
|
|
|
|
"and cannot be overwritten. Please delete the existing file or ",
|
|
|
|
"use the `--output <file-path` flag to provide an alternative name."
|
|
|
|
),
|
2022-03-28 18:38:15 +00:00
|
|
|
output_path.display()
|
2022-03-18 23:18:50 +00:00
|
|
|
);
|
2021-01-08 02:08:51 +00:00
|
|
|
}
|
2021-04-23 10:33:45 +00:00
|
|
|
|
|
|
|
// Remove file if it was indeed a deno compiled binary, to avoid corruption
|
|
|
|
// (see https://github.com/denoland/deno/issues/10310)
|
2022-03-28 18:38:15 +00:00
|
|
|
std::fs::remove_file(&output_path)?;
|
2022-01-11 04:24:39 +00:00
|
|
|
} else {
|
2022-03-28 18:38:15 +00:00
|
|
|
let output_base = &output_path.parent().unwrap();
|
2022-01-11 04:24:39 +00:00
|
|
|
if output_base.exists() && output_base.is_file() {
|
2022-03-18 23:18:50 +00:00
|
|
|
bail!(
|
|
|
|
concat!(
|
|
|
|
"Could not compile to file '{}' because its parent directory ",
|
|
|
|
"is an existing file. You can use the `--output <file-path>` flag to ",
|
|
|
|
"provide an alternative name.",
|
|
|
|
),
|
|
|
|
output_base.display(),
|
|
|
|
);
|
2022-01-11 04:24:39 +00:00
|
|
|
}
|
|
|
|
tokio::fs::create_dir_all(output_base).await?;
|
2021-01-08 02:08:51 +00:00
|
|
|
}
|
2022-01-11 04:24:39 +00:00
|
|
|
|
2022-03-28 18:38:15 +00:00
|
|
|
tokio::fs::write(&output_path, final_bin).await?;
|
2021-01-08 02:08:51 +00:00
|
|
|
#[cfg(unix)]
|
|
|
|
{
|
|
|
|
use std::os::unix::fs::PermissionsExt;
|
|
|
|
let perms = std::fs::Permissions::from_mode(0o777);
|
2022-03-28 18:38:15 +00:00
|
|
|
tokio::fs::set_permissions(output_path, perms).await?;
|
2021-01-08 02:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-02-10 15:11:11 +00:00
|
|
|
async fn resolve_compile_executable_output_path(
|
2022-03-28 18:38:15 +00:00
|
|
|
compile_flags: &CompileFlags,
|
|
|
|
) -> Result<PathBuf, AnyError> {
|
|
|
|
let module_specifier = resolve_url_or_path(&compile_flags.source_file)?;
|
2023-02-10 15:11:11 +00:00
|
|
|
|
|
|
|
let mut output = compile_flags.output.clone();
|
|
|
|
|
|
|
|
if let Some(out) = output.as_ref() {
|
|
|
|
if path_has_trailing_slash(out) {
|
|
|
|
if let Some(infer_file_name) = infer_name_from_url(&module_specifier)
|
|
|
|
.await
|
|
|
|
.map(PathBuf::from)
|
|
|
|
{
|
|
|
|
output = Some(out.join(infer_file_name));
|
|
|
|
}
|
2022-03-28 18:38:15 +00:00
|
|
|
} else {
|
2023-02-10 15:11:11 +00:00
|
|
|
output = Some(out.to_path_buf());
|
2022-03-28 18:38:15 +00:00
|
|
|
}
|
2023-02-10 15:11:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if output.is_none() {
|
|
|
|
output = infer_name_from_url(&module_specifier)
|
|
|
|
.await
|
|
|
|
.map(PathBuf::from)
|
|
|
|
}
|
|
|
|
|
|
|
|
output.ok_or_else(|| generic_error(
|
2022-03-28 18:38:15 +00:00
|
|
|
"An executable name was not provided. One could not be inferred from the URL. Aborting.",
|
|
|
|
)).map(|output| {
|
2022-09-22 15:49:27 +00:00
|
|
|
get_os_specific_filepath(output, &compile_flags.target)
|
2022-03-28 18:38:15 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-09-22 15:49:27 +00:00
|
|
|
fn get_os_specific_filepath(
|
|
|
|
output: PathBuf,
|
|
|
|
target: &Option<String>,
|
|
|
|
) -> PathBuf {
|
|
|
|
let is_windows = match target {
|
|
|
|
Some(target) => target.contains("windows"),
|
|
|
|
None => cfg!(windows),
|
|
|
|
};
|
|
|
|
if is_windows && output.extension().unwrap_or_default() != "exe" {
|
|
|
|
if let Some(ext) = output.extension() {
|
|
|
|
// keep version in my-exe-0.1.0 -> my-exe-0.1.0.exe
|
|
|
|
output.with_extension(format!("{}.exe", ext.to_string_lossy()))
|
|
|
|
} else {
|
|
|
|
output.with_extension("exe")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
output
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-28 18:38:15 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
pub use super::*;
|
|
|
|
|
2023-02-10 15:11:11 +00:00
|
|
|
#[tokio::test]
|
|
|
|
async fn resolve_compile_executable_output_path_target_linux() {
|
2022-03-28 18:38:15 +00:00
|
|
|
let path = resolve_compile_executable_output_path(&CompileFlags {
|
|
|
|
source_file: "mod.ts".to_string(),
|
|
|
|
output: Some(PathBuf::from("./file")),
|
|
|
|
args: Vec::new(),
|
|
|
|
target: Some("x86_64-unknown-linux-gnu".to_string()),
|
|
|
|
})
|
2023-02-10 15:11:11 +00:00
|
|
|
.await
|
2022-03-28 18:38:15 +00:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// no extension, no matter what the operating system is
|
|
|
|
// because the target was specified as linux
|
|
|
|
// https://github.com/denoland/deno/issues/9667
|
|
|
|
assert_eq!(path.file_name().unwrap(), "file");
|
|
|
|
}
|
|
|
|
|
2023-02-10 15:11:11 +00:00
|
|
|
#[tokio::test]
|
|
|
|
async fn resolve_compile_executable_output_path_target_windows() {
|
2022-03-28 18:38:15 +00:00
|
|
|
let path = resolve_compile_executable_output_path(&CompileFlags {
|
|
|
|
source_file: "mod.ts".to_string(),
|
|
|
|
output: Some(PathBuf::from("./file")),
|
|
|
|
args: Vec::new(),
|
|
|
|
target: Some("x86_64-pc-windows-msvc".to_string()),
|
|
|
|
})
|
2023-02-10 15:11:11 +00:00
|
|
|
.await
|
2022-03-28 18:38:15 +00:00
|
|
|
.unwrap();
|
|
|
|
assert_eq!(path.file_name().unwrap(), "file.exe");
|
|
|
|
}
|
2022-09-22 15:49:27 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_os_specific_file_path() {
|
|
|
|
fn run_test(path: &str, target: Option<&str>, expected: &str) {
|
|
|
|
assert_eq!(
|
|
|
|
get_os_specific_filepath(
|
|
|
|
PathBuf::from(path),
|
|
|
|
&target.map(|s| s.to_string())
|
|
|
|
),
|
|
|
|
PathBuf::from(expected)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg!(windows) {
|
|
|
|
run_test("C:\\my-exe", None, "C:\\my-exe.exe");
|
|
|
|
run_test("C:\\my-exe.exe", None, "C:\\my-exe.exe");
|
|
|
|
run_test("C:\\my-exe-0.1.2", None, "C:\\my-exe-0.1.2.exe");
|
|
|
|
} else {
|
|
|
|
run_test("my-exe", Some("linux"), "my-exe");
|
|
|
|
run_test("my-exe-0.1.2", Some("linux"), "my-exe-0.1.2");
|
|
|
|
}
|
|
|
|
|
|
|
|
run_test("C:\\my-exe", Some("windows"), "C:\\my-exe.exe");
|
|
|
|
run_test("C:\\my-exe.exe", Some("windows"), "C:\\my-exe.exe");
|
|
|
|
run_test("C:\\my-exe.0.1.2", Some("windows"), "C:\\my-exe.0.1.2.exe");
|
|
|
|
run_test("my-exe-0.1.2", Some("linux"), "my-exe-0.1.2");
|
|
|
|
}
|
2022-03-28 18:38:15 +00:00
|
|
|
}
|