Skip to content

Commit 8e0ab0f

Browse files
committed
bootstrap: use the correct paths during ./x.py install
1 parent 1fab574 commit 8e0ab0f

File tree

3 files changed

+45
-81
lines changed

3 files changed

+45
-81
lines changed

src/bootstrap/dist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1317,10 +1317,10 @@ impl Step for Extended {
13171317
}
13181318

13191319
let tarball = Tarball::new(builder, "rust", &target.triple);
1320-
let work = tarball.work_dir();
1321-
tarball.combine(&tarballs);
1320+
let generated = tarball.combine(&tarballs);
13221321

13231322
let tmp = tmpdir(builder).join("combined-tarball");
1323+
let work = generated.work_dir();
13241324

13251325
let mut license = String::new();
13261326
license += &builder.read(&builder.src.join("COPYRIGHT"));

src/bootstrap/install.rs

+31-75
Original file line numberDiff line numberDiff line change
@@ -10,60 +10,19 @@ use std::process::Command;
1010

1111
use build_helper::t;
1212

13-
use crate::dist::{self, pkgname, sanitize_sh, tmpdir};
13+
use crate::dist::{self, sanitize_sh};
14+
use crate::tarball::GeneratedTarball;
1415
use crate::Compiler;
1516

1617
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
1718
use crate::config::{Config, TargetSelection};
1819

19-
pub fn install_docs(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
20-
install_sh(builder, "docs", "rust-docs", stage, Some(host));
21-
}
22-
23-
pub fn install_std(builder: &Builder<'_>, stage: u32, target: TargetSelection) {
24-
install_sh(builder, "std", "rust-std", stage, Some(target));
25-
}
26-
27-
pub fn install_cargo(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
28-
install_sh(builder, "cargo", "cargo", stage, Some(host));
29-
}
30-
31-
pub fn install_rls(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
32-
install_sh(builder, "rls", "rls", stage, Some(host));
33-
}
34-
35-
pub fn install_rust_analyzer(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
36-
install_sh(builder, "rust-analyzer", "rust-analyzer", stage, Some(host));
37-
}
38-
39-
pub fn install_clippy(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
40-
install_sh(builder, "clippy", "clippy", stage, Some(host));
41-
}
42-
pub fn install_miri(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
43-
install_sh(builder, "miri", "miri", stage, Some(host));
44-
}
45-
46-
pub fn install_rustfmt(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
47-
install_sh(builder, "rustfmt", "rustfmt", stage, Some(host));
48-
}
49-
50-
pub fn install_analysis(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
51-
install_sh(builder, "analysis", "rust-analysis", stage, Some(host));
52-
}
53-
54-
pub fn install_src(builder: &Builder<'_>, stage: u32) {
55-
install_sh(builder, "src", "rust-src", stage, None);
56-
}
57-
pub fn install_rustc(builder: &Builder<'_>, stage: u32, host: TargetSelection) {
58-
install_sh(builder, "rustc", "rustc", stage, Some(host));
59-
}
60-
6120
fn install_sh(
6221
builder: &Builder<'_>,
6322
package: &str,
64-
name: &str,
6523
stage: u32,
6624
host: Option<TargetSelection>,
25+
tarball: &GeneratedTarball,
6726
) {
6827
builder.info(&format!("Install {} stage{} ({:?})", package, stage, host));
6928

@@ -108,15 +67,10 @@ fn install_sh(
10867
let empty_dir = builder.out.join("tmp/empty_dir");
10968

11069
t!(fs::create_dir_all(&empty_dir));
111-
let package_name = if let Some(host) = host {
112-
format!("{}-{}", pkgname(builder, name), host.triple)
113-
} else {
114-
pkgname(builder, name)
115-
};
11670

11771
let mut cmd = Command::new("sh");
11872
cmd.current_dir(&empty_dir)
119-
.arg(sanitize_sh(&tmpdir(builder).join(&package_name).join("install.sh")))
73+
.arg(sanitize_sh(&tarball.decompressed_output().join("install.sh")))
12074
.arg(format!("--prefix={}", sanitize_sh(&prefix)))
12175
.arg(format!("--sysconfdir={}", sanitize_sh(&sysconfdir)))
12276
.arg(format!("--datadir={}", sanitize_sh(&datadir)))
@@ -191,75 +145,77 @@ macro_rules! install {
191145

192146
install!((self, builder, _config),
193147
Docs, "src/doc", _config.docs, only_hosts: false, {
194-
builder.ensure(dist::Docs { host: self.target });
195-
install_docs(builder, self.compiler.stage, self.target);
148+
let tarball = builder.ensure(dist::Docs { host: self.target }).expect("missing docs");
149+
install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
196150
};
197151
Std, "library/std", true, only_hosts: false, {
198152
for target in &builder.targets {
199-
builder.ensure(dist::Std {
153+
let tarball = builder.ensure(dist::Std {
200154
compiler: self.compiler,
201155
target: *target
202-
});
203-
install_std(builder, self.compiler.stage, *target);
156+
}).expect("missing std");
157+
install_sh(builder, "std", self.compiler.stage, Some(*target), &tarball);
204158
}
205159
};
206160
Cargo, "cargo", Self::should_build(_config), only_hosts: true, {
207-
builder.ensure(dist::Cargo { compiler: self.compiler, target: self.target });
208-
install_cargo(builder, self.compiler.stage, self.target);
161+
let tarball = builder.ensure(dist::Cargo { compiler: self.compiler, target: self.target });
162+
install_sh(builder, "cargo", self.compiler.stage, Some(self.target), &tarball);
209163
};
210164
Rls, "rls", Self::should_build(_config), only_hosts: true, {
211-
if builder.ensure(dist::Rls { compiler: self.compiler, target: self.target }).is_some() {
212-
install_rls(builder, self.compiler.stage, self.target);
165+
if let Some(tarball) = builder.ensure(dist::Rls { compiler: self.compiler, target: self.target }) {
166+
install_sh(builder, "rls", self.compiler.stage, Some(self.target), &tarball);
213167
} else {
214168
builder.info(
215169
&format!("skipping Install RLS stage{} ({})", self.compiler.stage, self.target),
216170
);
217171
}
218172
};
219173
RustAnalyzer, "rust-analyzer", Self::should_build(_config), only_hosts: true, {
220-
builder.ensure(dist::RustAnalyzer { compiler: self.compiler, target: self.target });
221-
install_rust_analyzer(builder, self.compiler.stage, self.target);
174+
let tarball = builder
175+
.ensure(dist::RustAnalyzer { compiler: self.compiler, target: self.target })
176+
.expect("missing rust-analyzer");
177+
install_sh(builder, "rust-analyzer", self.compiler.stage, Some(self.target), &tarball);
222178
};
223179
Clippy, "clippy", Self::should_build(_config), only_hosts: true, {
224-
builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target });
225-
install_clippy(builder, self.compiler.stage, self.target);
180+
let tarball = builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target });
181+
install_sh(builder, "clippy", self.compiler.stage, Some(self.target), &tarball);
226182
};
227183
Miri, "miri", Self::should_build(_config), only_hosts: true, {
228-
if builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }).is_some() {
229-
install_miri(builder, self.compiler.stage, self.target);
184+
if let Some(tarball) = builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }) {
185+
install_sh(builder, "miri", self.compiler.stage, Some(self.target), &tarball);
230186
} else {
231187
builder.info(
232188
&format!("skipping Install miri stage{} ({})", self.compiler.stage, self.target),
233189
);
234190
}
235191
};
236192
Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, {
237-
if builder.ensure(dist::Rustfmt {
193+
if let Some(tarball) = builder.ensure(dist::Rustfmt {
238194
compiler: self.compiler,
239195
target: self.target
240-
}).is_some() {
241-
install_rustfmt(builder, self.compiler.stage, self.target);
196+
}) {
197+
install_sh(builder, "rustfmt", self.compiler.stage, Some(self.target), &tarball);
242198
} else {
243199
builder.info(
244200
&format!("skipping Install Rustfmt stage{} ({})", self.compiler.stage, self.target),
245201
);
246202
}
247203
};
248204
Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
249-
builder.ensure(dist::Analysis {
205+
let tarball = builder.ensure(dist::Analysis {
250206
// Find the actual compiler (handling the full bootstrap option) which
251207
// produced the save-analysis data because that data isn't copied
252208
// through the sysroot uplifting.
253209
compiler: builder.compiler_for(builder.top_stage, builder.config.build, self.target),
254210
target: self.target
255-
});
256-
install_analysis(builder, self.compiler.stage, self.target);
211+
}).expect("missing analysis");
212+
install_sh(builder, "analysis", self.compiler.stage, Some(self.target), &tarball);
257213
};
258214
Rustc, "src/librustc", true, only_hosts: true, {
259-
builder.ensure(dist::Rustc {
215+
let tarball = builder.ensure(dist::Rustc {
260216
compiler: builder.compiler(builder.top_stage, self.target),
261217
});
262-
install_rustc(builder, self.compiler.stage, self.target);
218+
install_sh(builder, "rustc", self.compiler.stage, Some(self.target), &tarball);
263219
};
264220
);
265221

@@ -284,7 +240,7 @@ impl Step for Src {
284240
}
285241

286242
fn run(self, builder: &Builder<'_>) {
287-
builder.ensure(dist::Src);
288-
install_src(builder, self.stage);
243+
let tarball = builder.ensure(dist::Src);
244+
install_sh(builder, "src", self.stage, None, &tarball);
289245
}
290246
}

src/bootstrap/tarball.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,6 @@ impl<'a> Tarball<'a> {
196196
self.builder.cp_r(src.as_ref(), &dest);
197197
}
198198

199-
pub(crate) fn work_dir(&self) -> PathBuf {
200-
self.temp_dir.clone()
201-
}
202-
203199
pub(crate) fn generate(self) -> GeneratedTarball {
204200
let mut component_name = self.component.clone();
205201
if self.is_preview {
@@ -309,17 +305,29 @@ impl<'a> Tarball<'a> {
309305

310306
GeneratedTarball {
311307
path: crate::dist::distdir(self.builder).join(format!("{}.tar.{}", package_name, ext)),
308+
decompressed_output: self.temp_dir.join(package_name),
309+
work: self.temp_dir,
312310
}
313311
}
314312
}
315313

316314
#[derive(Debug, Clone)]
317315
pub struct GeneratedTarball {
318316
path: PathBuf,
317+
decompressed_output: PathBuf,
318+
work: PathBuf,
319319
}
320320

321321
impl GeneratedTarball {
322322
pub(crate) fn tarball(&self) -> &Path {
323323
&self.path
324324
}
325+
326+
pub(crate) fn decompressed_output(&self) -> &Path {
327+
&self.decompressed_output
328+
}
329+
330+
pub(crate) fn work_dir(&self) -> &Path {
331+
&self.work
332+
}
325333
}

0 commit comments

Comments
 (0)