Rename target_dir to dist_dir in a couple of places

This commit is contained in:
bjorn3 2022-11-28 15:02:08 +00:00
parent 052d5ccf5d
commit 9c21990283
4 changed files with 29 additions and 29 deletions

View File

@ -14,7 +14,7 @@
pub(crate) fn run( pub(crate) fn run(
channel: &str, channel: &str,
sysroot_kind: SysrootKind, sysroot_kind: SysrootKind,
target_dir: &Path, dist_dir: &Path,
cg_clif_dylib: &Path, cg_clif_dylib: &Path,
host_triple: &str, host_triple: &str,
target_triple: &str, target_triple: &str,
@ -33,7 +33,7 @@ pub(crate) fn run(
build_sysroot::build_sysroot( build_sysroot::build_sysroot(
channel, channel,
sysroot_kind, sysroot_kind,
target_dir, dist_dir,
cg_clif_dylib, cg_clif_dylib,
host_triple, host_triple,
target_triple, target_triple,

View File

@ -9,21 +9,21 @@
pub(crate) fn build_sysroot( pub(crate) fn build_sysroot(
channel: &str, channel: &str,
sysroot_kind: SysrootKind, sysroot_kind: SysrootKind,
target_dir: &Path, dist_dir: &Path,
cg_clif_dylib_src: &Path, cg_clif_dylib_src: &Path,
host_triple: &str, host_triple: &str,
target_triple: &str, target_triple: &str,
) { ) {
eprintln!("[BUILD] sysroot {:?}", sysroot_kind); eprintln!("[BUILD] sysroot {:?}", sysroot_kind);
if target_dir.exists() { if dist_dir.exists() {
fs::remove_dir_all(target_dir).unwrap(); fs::remove_dir_all(dist_dir).unwrap();
} }
fs::create_dir_all(target_dir.join("bin")).unwrap(); fs::create_dir_all(dist_dir.join("bin")).unwrap();
fs::create_dir_all(target_dir.join("lib")).unwrap(); fs::create_dir_all(dist_dir.join("lib")).unwrap();
// Copy the backend // Copy the backend
let cg_clif_dylib_path = target_dir let cg_clif_dylib_path = dist_dir
.join(if cfg!(windows) { .join(if cfg!(windows) {
// Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the // Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
// binaries. // binaries.
@ -42,14 +42,14 @@ pub(crate) fn build_sysroot(
build_cargo_wrapper_cmd build_cargo_wrapper_cmd
.arg(PathBuf::from("scripts").join(format!("{wrapper}.rs"))) .arg(PathBuf::from("scripts").join(format!("{wrapper}.rs")))
.arg("-o") .arg("-o")
.arg(target_dir.join(wrapper_name)) .arg(dist_dir.join(wrapper_name))
.arg("-g"); .arg("-g");
spawn_and_wait(build_cargo_wrapper_cmd); spawn_and_wait(build_cargo_wrapper_cmd);
} }
let default_sysroot = super::rustc_info::get_default_sysroot(); let default_sysroot = super::rustc_info::get_default_sysroot();
let rustlib = target_dir.join("lib").join("rustlib"); let rustlib = dist_dir.join("lib").join("rustlib");
let host_rustlib_lib = rustlib.join(host_triple).join("lib"); let host_rustlib_lib = rustlib.join(host_triple).join("lib");
let target_rustlib_lib = rustlib.join(target_triple).join("lib"); let target_rustlib_lib = rustlib.join(target_triple).join("lib");
fs::create_dir_all(&host_rustlib_lib).unwrap(); fs::create_dir_all(&host_rustlib_lib).unwrap();
@ -114,7 +114,7 @@ pub(crate) fn build_sysroot(
SysrootKind::Clif => { SysrootKind::Clif => {
build_clif_sysroot_for_triple( build_clif_sysroot_for_triple(
channel, channel,
target_dir, dist_dir,
host_triple, host_triple,
&cg_clif_dylib_path, &cg_clif_dylib_path,
None, None,
@ -129,7 +129,7 @@ pub(crate) fn build_sysroot(
}; };
build_clif_sysroot_for_triple( build_clif_sysroot_for_triple(
channel, channel,
target_dir, dist_dir,
target_triple, target_triple,
&cg_clif_dylib_path, &cg_clif_dylib_path,
linker, linker,
@ -142,7 +142,7 @@ pub(crate) fn build_sysroot(
let file = file.unwrap().path(); let file = file.unwrap().path();
let filename = file.file_name().unwrap().to_str().unwrap(); let filename = file.file_name().unwrap().to_str().unwrap();
if filename.contains("std-") && !filename.contains(".rlib") { if filename.contains("std-") && !filename.contains(".rlib") {
try_hard_link(&file, target_dir.join("lib").join(file.file_name().unwrap())); try_hard_link(&file, dist_dir.join("lib").join(file.file_name().unwrap()));
} }
} }
} }
@ -153,7 +153,7 @@ pub(crate) fn build_sysroot(
fn build_clif_sysroot_for_triple( fn build_clif_sysroot_for_triple(
channel: &str, channel: &str,
target_dir: &Path, dist_dir: &Path,
triple: &str, triple: &str,
cg_clif_dylib_path: &Path, cg_clif_dylib_path: &Path,
linker: Option<&str>, linker: Option<&str>,
@ -189,7 +189,7 @@ fn build_clif_sysroot_for_triple(
// Build sysroot // Build sysroot
let mut rustflags = "-Zforce-unstable-if-unmarked -Cpanic=abort".to_string(); let mut rustflags = "-Zforce-unstable-if-unmarked -Cpanic=abort".to_string();
rustflags.push_str(&format!(" -Zcodegen-backend={}", cg_clif_dylib_path.to_str().unwrap())); rustflags.push_str(&format!(" -Zcodegen-backend={}", cg_clif_dylib_path.to_str().unwrap()));
rustflags.push_str(&format!(" --sysroot={}", target_dir.to_str().unwrap())); rustflags.push_str(&format!(" --sysroot={}", dist_dir.to_str().unwrap()));
if channel == "release" { if channel == "release" {
rustflags.push_str(" -Zmir-opt-level=3"); rustflags.push_str(" -Zmir-opt-level=3");
} }
@ -221,7 +221,7 @@ fn build_clif_sysroot_for_triple(
}; };
try_hard_link( try_hard_link(
entry.path(), entry.path(),
target_dir.join("lib").join("rustlib").join(triple).join("lib").join(entry.file_name()), dist_dir.join("lib").join("rustlib").join(triple).join("lib").join(entry.file_name()),
); );
} }
} }

View File

@ -17,10 +17,10 @@ fn usage() {
eprintln!("Usage:"); eprintln!("Usage:");
eprintln!(" ./y.rs prepare"); eprintln!(" ./y.rs prepare");
eprintln!( eprintln!(
" ./y.rs build [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]" " ./y.rs build [--debug] [--sysroot none|clif|llvm] [--dist-dir DIR] [--no-unstable-features]"
); );
eprintln!( eprintln!(
" ./y.rs test [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]" " ./y.rs test [--debug] [--sysroot none|clif|llvm] [--dist-dir DIR] [--no-unstable-features]"
); );
} }
@ -75,15 +75,15 @@ pub fn main() {
} }
}; };
let mut target_dir = PathBuf::from("dist"); let mut dist_dir = PathBuf::from("dist");
let mut channel = "release"; let mut channel = "release";
let mut sysroot_kind = SysrootKind::Clif; let mut sysroot_kind = SysrootKind::Clif;
let mut use_unstable_features = true; let mut use_unstable_features = true;
while let Some(arg) = args.next().as_deref() { while let Some(arg) = args.next().as_deref() {
match arg { match arg {
"--target-dir" => { "--dist-dir" => {
target_dir = PathBuf::from(args.next().unwrap_or_else(|| { dist_dir = PathBuf::from(args.next().unwrap_or_else(|| {
arg_error!("--target-dir requires argument"); arg_error!("--dist-dir requires argument");
})) }))
} }
"--debug" => channel = "debug", "--debug" => channel = "debug",
@ -101,7 +101,7 @@ pub fn main() {
arg => arg_error!("Unexpected argument {}", arg), arg => arg_error!("Unexpected argument {}", arg),
} }
} }
target_dir = std::env::current_dir().unwrap().join(target_dir); dist_dir = std::env::current_dir().unwrap().join(dist_dir);
let host_triple = if let Ok(host_triple) = std::env::var("HOST_TRIPLE") { let host_triple = if let Ok(host_triple) = std::env::var("HOST_TRIPLE") {
host_triple host_triple
@ -128,7 +128,7 @@ pub fn main() {
tests::run_tests( tests::run_tests(
channel, channel,
sysroot_kind, sysroot_kind,
&target_dir, &dist_dir,
&cg_clif_dylib, &cg_clif_dylib,
&host_triple, &host_triple,
&target_triple, &target_triple,
@ -137,7 +137,7 @@ pub fn main() {
abi_cafe::run( abi_cafe::run(
channel, channel,
sysroot_kind, sysroot_kind,
&target_dir, &dist_dir,
&cg_clif_dylib, &cg_clif_dylib,
&host_triple, &host_triple,
&target_triple, &target_triple,
@ -147,7 +147,7 @@ pub fn main() {
build_sysroot::build_sysroot( build_sysroot::build_sysroot(
channel, channel,
sysroot_kind, sysroot_kind,
&target_dir, &dist_dir,
&cg_clif_dylib, &cg_clif_dylib,
&host_triple, &host_triple,
&target_triple, &target_triple,

View File

@ -432,7 +432,7 @@ const fn new(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
pub(crate) fn run_tests( pub(crate) fn run_tests(
channel: &str, channel: &str,
sysroot_kind: SysrootKind, sysroot_kind: SysrootKind,
target_dir: &Path, dist_dir: &Path,
cg_clif_dylib: &Path, cg_clif_dylib: &Path,
host_triple: &str, host_triple: &str,
target_triple: &str, target_triple: &str,
@ -443,7 +443,7 @@ pub(crate) fn run_tests(
build_sysroot::build_sysroot( build_sysroot::build_sysroot(
channel, channel,
SysrootKind::None, SysrootKind::None,
&target_dir, &dist_dir,
cg_clif_dylib, cg_clif_dylib,
&host_triple, &host_triple,
&target_triple, &target_triple,
@ -462,7 +462,7 @@ pub(crate) fn run_tests(
build_sysroot::build_sysroot( build_sysroot::build_sysroot(
channel, channel,
sysroot_kind, sysroot_kind,
&target_dir, &dist_dir,
cg_clif_dylib, cg_clif_dylib,
&host_triple, &host_triple,
&target_triple, &target_triple,