Make executable extension platform, rather than environment dependent

This commit is contained in:
Jakub Beránek 2023-09-12 18:07:31 +02:00
parent 074fb2c6b7
commit 95500f4941
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
5 changed files with 20 additions and 20 deletions

View File

@ -57,10 +57,6 @@ fn supports_shared_llvm(&self) -> bool {
true
}
fn executable_extension(&self) -> &'static str {
""
}
fn skipped_tests(&self) -> &'static [&'static str] {
&[
// Fails because of linker errors, as of June 2023.

View File

@ -31,21 +31,21 @@ fn cargo_stage_0(&self) -> Utf8PathBuf {
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 @@ fn rustc_perf_dir(&self) -> Utf8PathBuf {
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"
}

View File

@ -84,10 +84,6 @@ fn supports_shared_llvm(&self) -> bool {
false
}
fn executable_extension(&self) -> &'static str {
".exe"
}
fn skipped_tests(&self) -> &'static [&'static str] {
&[
// Fails as of June 2023.

View File

@ -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!(

View File

@ -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()])