Put all temporary build artifacts in build/

This commit is contained in:
bjorn3 2022-11-28 17:37:30 +00:00
parent 5e97a3951d
commit e75dfef4d4
8 changed files with 41 additions and 48 deletions

View file

@ -9,7 +9,7 @@ use super::SysrootKind;
pub(crate) static ABI_CAFE_REPO: GitRepo =
GitRepo::github("Gankra", "abi-cafe", "4c6dc8c9c687e2b3a760ff2176ce236872b37212", "abi-cafe");
static ABI_CAFE: CargoProject = CargoProject::git(&ABI_CAFE_REPO, ".");
static ABI_CAFE: CargoProject = CargoProject::git(&ABI_CAFE_REPO, ".", "abi_cafe");
pub(crate) fn run(
channel: &str,

View file

@ -4,7 +4,7 @@ use std::path::PathBuf;
use super::rustc_info::get_file_name;
use super::utils::{is_ci, CargoProject, Compiler};
static CG_CLIF: CargoProject = CargoProject::local(".");
static CG_CLIF: CargoProject = CargoProject::local(".", "cg_clif");
pub(crate) fn build_backend(
channel: &str,
@ -43,8 +43,7 @@ pub(crate) fn build_backend(
super::utils::spawn_and_wait(cmd);
CG_CLIF
.source_dir()
.join("target")
.target_dir()
.join(host_triple)
.join(channel)
.join(get_file_name("rustc_codegen_cranelift", "dylib"))

View file

@ -1,5 +1,5 @@
use std::fs;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::process::{self, Command};
use super::rustc_info::{get_file_name, get_rustc_version, get_wrapper_file_name};
@ -40,7 +40,7 @@ pub(crate) fn build_sysroot(
let mut build_cargo_wrapper_cmd = Command::new("rustc");
build_cargo_wrapper_cmd
.arg(PathBuf::from("scripts").join(format!("{wrapper}.rs")))
.arg(Path::new("scripts").join(format!("{wrapper}.rs")))
.arg("-o")
.arg(dist_dir.join(wrapper_name))
.arg("-g");
@ -149,7 +149,7 @@ pub(crate) fn build_sysroot(
}
}
static STANDARD_LIBRARY: CargoProject = CargoProject::local("build_sysroot");
static STANDARD_LIBRARY: CargoProject = CargoProject::local("build_sysroot", "build_sysroot");
fn build_clif_sysroot_for_triple(
channel: &str,
@ -176,7 +176,7 @@ fn build_clif_sysroot_for_triple(
}
}
let build_dir = Path::new("build_sysroot").join("target").join(triple).join(channel);
let build_dir = STANDARD_LIBRARY.target_dir().join(triple).join(channel);
if !super::config::get_bool("keep_sysroot") {
// Cleanup the deps dir, but keep build scripts and the incremental cache for faster
@ -207,10 +207,7 @@ fn build_clif_sysroot_for_triple(
spawn_and_wait(build_cmd);
// Copy all relevant files to the sysroot
for entry in
fs::read_dir(Path::new("build_sysroot/target").join(triple).join(channel).join("deps"))
.unwrap()
{
for entry in fs::read_dir(build_dir.join("deps")).unwrap() {
let entry = entry.unwrap();
if let Some(ext) = entry.path().extension() {
if ext == "rmeta" || ext == "d" || ext == "dSYM" || ext == "clif" {

View file

@ -49,13 +49,14 @@ pub fn main() {
env::set_var("CG_CLIF_DISPLAY_CG_TIME", "1");
env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
std::fs::create_dir_all("build").unwrap();
{
// Make sure we always explicitly specify the target dir
let target = "build/target_dir_should_be_set_explicitly";
env::set_var("CARGO_TARGET_DIR", target);
std::fs::create_dir_all("build").unwrap();
let _ = std::fs::remove_file(target);
let file = std::fs::File::create(target).unwrap();
std::fs::File::create(target).unwrap();
}
if is_ci() {

View file

@ -35,9 +35,7 @@ pub(crate) fn prepare() {
.join(&host_compiler.triple)
.join("debug")
.join(get_file_name("main", "bin")),
super::tests::SIMPLE_RAYTRACER_REPO
.source_dir()
.join(get_file_name("raytracer_cg_llvm", "bin")),
Path::new("build").join(get_file_name("raytracer_cg_llvm", "bin")),
)
.unwrap();
}

View file

@ -223,12 +223,12 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
pub(crate) static RAND_REPO: GitRepo =
GitRepo::github("rust-random", "rand", "0f933f9c7176e53b2a3c7952ded484e1783f0bf1", "rand");
static RAND: CargoProject = CargoProject::git(&RAND_REPO, ".");
static RAND: CargoProject = CargoProject::git(&RAND_REPO, ".", "rand");
pub(crate) static REGEX_REPO: GitRepo =
GitRepo::github("rust-lang", "regex", "341f207c1071f7290e3f228c710817c280c8dca1", "regex");
static REGEX: CargoProject = CargoProject::git(&REGEX_REPO, ".");
static REGEX: CargoProject = CargoProject::git(&REGEX_REPO, ".", "regex");
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
"rust-lang",
@ -237,7 +237,7 @@ pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
"portable-simd",
);
static PORTABLE_SIMD: CargoProject = CargoProject::git(&PORTABLE_SIMD_REPO, ".");
static PORTABLE_SIMD: CargoProject = CargoProject::git(&PORTABLE_SIMD_REPO, ".", "portable_simd");
pub(crate) static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
"ebobby",
@ -246,10 +246,11 @@ pub(crate) static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
"<none>",
);
pub(crate) static SIMPLE_RAYTRACER: CargoProject = CargoProject::git(&SIMPLE_RAYTRACER_REPO, ".");
pub(crate) static SIMPLE_RAYTRACER: CargoProject =
CargoProject::git(&SIMPLE_RAYTRACER_REPO, ".", "simple_raytracer");
static LIBCORE_TESTS: CargoProject =
CargoProject::local("build_sysroot/sysroot_src/library/core/tests");
CargoProject::local("build_sysroot/sysroot_src/library/core/tests", "core_tests");
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
TestCase::new("test.rust-random/rand", &|runner| {
@ -276,7 +277,6 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
.unwrap()
.join("dist")
.join(get_wrapper_file_name("cargo-clif", "bin"));
let source_dir = SIMPLE_RAYTRACER.source_dir();
let manifest_path = SIMPLE_RAYTRACER.manifest_path();
let target_dir = SIMPLE_RAYTRACER.target_dir();
@ -303,17 +303,15 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
spawn_and_wait(bench_compile);
eprintln!("[BENCH RUN] ebobby/simple-raytracer");
fs::copy(target_dir.join("debug").join("main"), source_dir.join("raytracer_cg_clif"))
.unwrap();
fs::copy(
target_dir.join("debug").join("main"),
Path::new("build").join("raytracer_cg_clif"),
)
.unwrap();
let mut bench_run = hyperfine_command(
0,
run_runs,
None,
&source_dir.join("raytracer_cg_llvm").display().to_string(),
&source_dir.join("raytracer_cg_clif").display().to_string(),
);
bench_run.current_dir(SIMPLE_RAYTRACER.source_dir());
let mut bench_run =
hyperfine_command(0, run_runs, None, "./raytracer_cg_llvm", "./raytracer_cg_clif");
bench_run.current_dir(Path::new("build"));
spawn_and_wait(bench_run);
} else {
spawn_and_wait(SIMPLE_RAYTRACER.clean(&runner.target_compiler.cargo));
@ -449,7 +447,7 @@ pub(crate) fn run_tests(
&target_triple,
);
let _ = fs::remove_dir_all(Path::new("target").join("out"));
let _ = fs::remove_dir_all(Path::new("build").join("example"));
runner.run_testsuite(NO_SYSROOT_SUITE);
} else {
eprintln!("[SKIP] no_sysroot tests");
@ -495,8 +493,8 @@ impl TestRunner {
let root_dir = env::current_dir().unwrap();
let mut out_dir = root_dir.clone();
out_dir.push("target");
out_dir.push("out");
out_dir.push("build");
out_dir.push("example");
let is_native = host_triple == target_triple;
let jit_supported =

View file

@ -51,15 +51,20 @@ enum CargoProjectSource {
pub(crate) struct CargoProject {
source: CargoProjectSource,
path: &'static str,
target: &'static str,
}
impl CargoProject {
pub(crate) const fn local(path: &'static str) -> CargoProject {
CargoProject { source: CargoProjectSource::Local, path }
pub(crate) const fn local(path: &'static str, target: &'static str) -> CargoProject {
CargoProject { source: CargoProjectSource::Local, path, target }
}
pub(crate) const fn git(git_repo: &'static GitRepo, path: &'static str) -> CargoProject {
CargoProject { source: CargoProjectSource::GitRepo(git_repo), path }
pub(crate) const fn git(
git_repo: &'static GitRepo,
path: &'static str,
target: &'static str,
) -> CargoProject {
CargoProject { source: CargoProjectSource::GitRepo(git_repo), path, target }
}
pub(crate) fn source_dir(&self) -> PathBuf {
@ -75,12 +80,7 @@ impl CargoProject {
}
pub(crate) fn target_dir(&self) -> PathBuf {
match self.source {
CargoProjectSource::Local => std::env::current_dir().unwrap(),
CargoProjectSource::GitRepo(git_repo) => git_repo.source_dir(),
}
.join(self.path)
.join("target")
std::env::current_dir().unwrap().join("build").join(self.target)
}
fn base_cmd(&self, command: &str, cargo: &Path) -> Command {

View file

@ -2,9 +2,9 @@
set -e
rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version}
rm -rf target/ dist/ perf.data{,.old} y.bin
rm -rf target/ build/ dist/ perf.data{,.old} y.bin
rm -rf download/
# Kept for now in case someone updates their checkout of cg_clif before running clean_all.sh
# FIXME remove at some point in the future
rm -rf rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/ abi-cafe/ build/
rm -rf rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/ abi-cafe/