diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2023-09-12 18:07:31 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2023-09-12 18:07:31 +0200 |
| commit | 95500f494118b74c965a94acce3e92a803ee8e91 (patch) | |
| tree | 7a23c86ad23c60ec50e09c55f6c968b770038c13 | |
| parent | 074fb2c6b7c4c7fb1de7d303a37632c02dd10cef (diff) | |
| download | rust-95500f494118b74c965a94acce3e92a803ee8e91.tar.gz rust-95500f494118b74c965a94acce3e92a803ee8e91.zip | |
Make executable extension platform, rather than environment dependent
| -rw-r--r-- | src/tools/opt-dist/src/environment/linux.rs | 4 | ||||
| -rw-r--r-- | src/tools/opt-dist/src/environment/mod.rs | 20 | ||||
| -rw-r--r-- | src/tools/opt-dist/src/environment/windows.rs | 4 | ||||
| -rw-r--r-- | src/tools/opt-dist/src/tests.rs | 8 | ||||
| -rw-r--r-- | src/tools/opt-dist/src/training.rs | 4 |
5 files changed, 20 insertions, 20 deletions
diff --git a/src/tools/opt-dist/src/environment/linux.rs b/src/tools/opt-dist/src/environment/linux.rs index bd8dd037ae5..61f05137298 100644 --- a/src/tools/opt-dist/src/environment/linux.rs +++ b/src/tools/opt-dist/src/environment/linux.rs @@ -57,10 +57,6 @@ impl Environment for LinuxEnvironment { true } - fn executable_extension(&self) -> &'static str { - "" - } - fn skipped_tests(&self) -> &'static [&'static str] { &[ // Fails because of linker errors, as of June 2023. diff --git a/src/tools/opt-dist/src/environment/mod.rs b/src/tools/opt-dist/src/environment/mod.rs index 9f7f31d4791..271b41316ab 100644 --- a/src/tools/opt-dist/src/environment/mod.rs +++ b/src/tools/opt-dist/src/environment/mod.rs @@ -31,21 +31,21 @@ pub trait Environment { self.build_artifacts() .join("stage0") .join("bin") - .join(format!("cargo{}", self.executable_extension())) + .join(format!("cargo{}", executable_extension())) } fn rustc_stage_0(&self) -> Utf8PathBuf { self.build_artifacts() .join("stage0") .join("bin") - .join(format!("rustc{}", self.executable_extension())) + .join(format!("rustc{}", executable_extension())) } fn rustc_stage_2(&self) -> Utf8PathBuf { self.build_artifacts() .join("stage2") .join("bin") - .join(format!("rustc{}", self.executable_extension())) + .join(format!("rustc{}", executable_extension())) } /// Path to the built rustc-perf benchmark suite. @@ -60,9 +60,6 @@ pub trait Environment { fn supports_shared_llvm(&self) -> bool; - /// What is the extension of binary executables in this environment? - fn executable_extension(&self) -> &'static str; - /// List of test paths that should be skipped when testing the optimized artifacts. fn skipped_tests(&self) -> &'static [&'static str]; } @@ -73,3 +70,14 @@ pub fn create_environment(target_triple: String) -> Box<dyn Environment> { #[cfg(target_family = "windows")] return Box::new(windows::WindowsEnvironment::new(target_triple)); } + +/// What is the extension of binary executables on this platform? +#[cfg(target_family = "unix")] +pub fn executable_extension() -> &'static str { + "" +} + +#[cfg(target_family = "windows")] +pub fn executable_extension() -> &'static str { + ".exe" +} diff --git a/src/tools/opt-dist/src/environment/windows.rs b/src/tools/opt-dist/src/environment/windows.rs index 90ddc01e893..f705461ac81 100644 --- a/src/tools/opt-dist/src/environment/windows.rs +++ b/src/tools/opt-dist/src/environment/windows.rs @@ -84,10 +84,6 @@ impl Environment for WindowsEnvironment { false } - fn executable_extension(&self) -> &'static str { - ".exe" - } - fn skipped_tests(&self) -> &'static [&'static str] { &[ // Fails as of June 2023. diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index 3dd1a3223f5..e6b8df9c862 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -1,4 +1,4 @@ -use crate::environment::Environment; +use crate::environment::{executable_extension, Environment}; use crate::exec::cmd; use crate::utils::io::{copy_directory, find_file_in_dir, unpack_archive}; use anyhow::Context; @@ -45,9 +45,9 @@ pub fn run_tests(env: &dyn Environment) -> anyhow::Result<()> { &rustc_dir.join("lib").join("rustlib").join("src"), )?; - let rustc_path = rustc_dir.join("bin").join(format!("rustc{}", env.executable_extension())); + let rustc_path = rustc_dir.join("bin").join(format!("rustc{}", executable_extension())); assert!(rustc_path.is_file()); - let cargo_path = cargo_dir.join("bin").join(format!("cargo{}", env.executable_extension())); + let cargo_path = cargo_dir.join("bin").join(format!("cargo{}", executable_extension())); assert!(cargo_path.is_file()); // Specify path to a LLVM config so that LLVM is not rebuilt. @@ -56,7 +56,7 @@ pub fn run_tests(env: &dyn Environment) -> anyhow::Result<()> { .build_artifacts() .join("llvm") .join("bin") - .join(format!("llvm-config{}", env.executable_extension())); + .join(format!("llvm-config{}", executable_extension())); assert!(llvm_config.is_file()); let config_content = format!( diff --git a/src/tools/opt-dist/src/training.rs b/src/tools/opt-dist/src/training.rs index 59c73fbd695..950dd1127a9 100644 --- a/src/tools/opt-dist/src/training.rs +++ b/src/tools/opt-dist/src/training.rs @@ -1,4 +1,4 @@ -use crate::environment::Environment; +use crate::environment::{executable_extension, Environment}; use crate::exec::{cmd, CmdBuilder}; use crate::utils::io::{count_files, delete_directory}; use crate::utils::with_log_group; @@ -86,7 +86,7 @@ fn merge_llvm_profiles( .build_artifacts() .join("llvm") .join("build") - .join(format!("bin/llvm-profdata{}", env.executable_extension())), + .join(format!("bin/llvm-profdata{}", executable_extension())), }; cmd(&[llvm_profdata.as_str(), "merge", "-o", merged_path.as_str(), profile_dir.as_str()]) |
