Skip to content

Commit 5ccafaa

Browse files
committed
Refactor and document the DebuggerScripts dist step
1 parent 3487aed commit 5ccafaa

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl Step for Rustc {
458458
return tarball.generate();
459459

460460
fn prepare_image(builder: &Builder<'_>, target_compiler: Compiler, image: &Path) {
461-
let host = target_compiler.host;
461+
let target = target_compiler.host;
462462
let src = builder.sysroot(target_compiler);
463463

464464
// Copy rustc binary
@@ -517,14 +517,14 @@ impl Step for Rustc {
517517
// components like the llvm tools and LLD. LLD is included below and
518518
// tools/LLDB come later, so let's just throw it in the rustc
519519
// component for now.
520-
maybe_install_llvm_runtime(builder, host, image);
520+
maybe_install_llvm_runtime(builder, target, image);
521521

522-
let dst_dir = image.join("lib/rustlib").join(host).join("bin");
522+
let dst_dir = image.join("lib/rustlib").join(target).join("bin");
523523
t!(fs::create_dir_all(&dst_dir));
524524

525525
// Copy over lld if it's there
526526
if builder.config.lld_enabled {
527-
let src_dir = builder.sysroot_target_bindir(target_compiler, host);
527+
let src_dir = builder.sysroot_target_bindir(target_compiler, target);
528528
let rust_lld = exe("rust-lld", target_compiler.host);
529529
builder.copy_link(
530530
&src_dir.join(&rust_lld),
@@ -547,7 +547,7 @@ impl Step for Rustc {
547547
if builder.config.llvm_enabled(target_compiler.host)
548548
&& builder.config.llvm_tools_enabled
549549
{
550-
let src_dir = builder.sysroot_target_bindir(target_compiler, host);
550+
let src_dir = builder.sysroot_target_bindir(target_compiler, target);
551551
let llvm_objcopy = exe("llvm-objcopy", target_compiler.host);
552552
let rust_objcopy = exe("rust-objcopy", target_compiler.host);
553553
builder.copy_link(
@@ -558,7 +558,7 @@ impl Step for Rustc {
558558
}
559559

560560
if builder.tool_enabled("wasm-component-ld") {
561-
let src_dir = builder.sysroot_target_bindir(target_compiler, host);
561+
let src_dir = builder.sysroot_target_bindir(target_compiler, target);
562562
let ld = exe("wasm-component-ld", target_compiler.host);
563563
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld), FileType::Executable);
564564
}
@@ -580,7 +580,7 @@ impl Step for Rustc {
580580
}
581581

582582
// Debugger scripts
583-
builder.ensure(DebuggerScripts { sysroot: image.to_owned(), host });
583+
builder.ensure(DebuggerScripts { sysroot: image.to_owned(), target });
584584

585585
// HTML copyright files
586586
let file_list = builder.ensure(super::run::GenerateCopyright);
@@ -610,10 +610,12 @@ impl Step for Rustc {
610610
}
611611
}
612612

613+
/// Copies debugger scripts for `target` into the given compiler `sysroot`.
613614
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
614615
pub struct DebuggerScripts {
616+
/// Sysroot of a compiler into which will the debugger scripts be copied to.
615617
pub sysroot: PathBuf,
616-
pub host: TargetSelection,
618+
pub target: TargetSelection,
617619
}
618620

619621
impl Step for DebuggerScripts {
@@ -623,16 +625,15 @@ impl Step for DebuggerScripts {
623625
run.never()
624626
}
625627

626-
/// Copies debugger scripts for `target` into the `sysroot` specified.
627628
fn run(self, builder: &Builder<'_>) {
628-
let host = self.host;
629+
let target = self.target;
629630
let sysroot = self.sysroot;
630631
let dst = sysroot.join("lib/rustlib/etc");
631632
t!(fs::create_dir_all(&dst));
632633
let cp_debugger_script = |file: &str| {
633634
builder.install(&builder.src.join("src/etc/").join(file), &dst, FileType::Regular);
634635
};
635-
if host.contains("windows-msvc") {
636+
if target.contains("windows-msvc") {
636637
// windbg debugger scripts
637638
builder.install(
638639
&builder.src.join("src/etc/rust-windbg.cmd"),

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17191719
if suite == "debuginfo" {
17201720
builder.ensure(dist::DebuggerScripts {
17211721
sysroot: builder.sysroot(compiler).to_path_buf(),
1722-
host: target,
1722+
target,
17231723
});
17241724
}
17251725
if suite == "run-make" {

0 commit comments

Comments
 (0)