Skip to content

Commit fe0eca0

Browse files
Change tools to take a compiler instead of a stage.
1 parent f4240a4 commit fe0eca0

File tree

3 files changed

+40
-37
lines changed

3 files changed

+40
-37
lines changed

src/bootstrap/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl Step for Cargo {
194194
let build = builder.build;
195195
let compiler = builder.compiler(self.stage, self.host);
196196

197-
builder.ensure(tool::Cargo { stage: self.stage, target: self.host });
197+
builder.ensure(tool::Cargo { compiler, target: self.host });
198198
let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
199199
cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
200200
if !build.fail_fast {
@@ -240,7 +240,7 @@ impl Step for Rls {
240240
let host = self.host;
241241
let compiler = builder.compiler(stage, host);
242242

243-
builder.ensure(tool::Rls { stage: self.stage, target: self.host });
243+
builder.ensure(tool::Rls { compiler, target: self.host });
244244
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
245245
cargo.arg("--manifest-path").arg(build.src.join("src/tools/rls/Cargo.toml"));
246246

@@ -1165,7 +1165,7 @@ impl Step for RemoteCopyLibs {
11651165
println!("REMOTE copy libs to emulator ({})", target);
11661166
t!(fs::create_dir_all(build.out.join("tmp")));
11671167

1168-
let server = builder.ensure(tool::RemoteTestServer { stage: compiler.stage, target });
1168+
let server = builder.ensure(tool::RemoteTestServer { compiler, target });
11691169

11701170
// Spawn the emulator and wait for it to come online
11711171
let tool = builder.tool_exe(Tool::RemoteTestClient);

src/bootstrap/dist.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,10 @@ impl Step for Cargo {
963963
// Prepare the image directory
964964
t!(fs::create_dir_all(image.join("share/zsh/site-functions")));
965965
t!(fs::create_dir_all(image.join("etc/bash_completion.d")));
966-
let cargo = builder.ensure(tool::Cargo { stage, target });
966+
let cargo = builder.ensure(tool::Cargo {
967+
compiler: builder.compiler(stage, build.build),
968+
target
969+
});
967970
install(&cargo, &image.join("bin"), 0o755);
968971
for man in t!(etc.join("man").read_dir()) {
969972
let man = t!(man);
@@ -1046,7 +1049,10 @@ impl Step for Rls {
10461049
t!(fs::create_dir_all(&image));
10471050

10481051
// Prepare the image directory
1049-
let rls = builder.ensure(tool::Rls { stage, target });
1052+
let rls = builder.ensure(tool::Rls {
1053+
compiler: builder.compiler(stage, build.build),
1054+
target
1055+
});
10501056
install(&rls, &image.join("bin"), 0o755);
10511057
let doc = image.join("share/doc/rls");
10521058
install(&src.join("README.md"), &doc, 0o644);

src/bootstrap/tool.rs

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ use channel::GitInfo;
2222
use cache::Interned;
2323

2424
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
25-
pub struct CleanTools {
26-
pub stage: u32,
27-
pub target: Interned<String>,
28-
pub mode: Mode,
25+
struct CleanTools {
26+
compiler: Compiler,
27+
target: Interned<String>,
28+
mode: Mode,
2929
}
3030

3131
impl Step for CleanTools {
@@ -41,12 +41,10 @@ impl Step for CleanTools {
4141
/// `stage` into the normal cargo output directory.
4242
fn run(self, builder: &Builder) {
4343
let build = builder.build;
44-
let stage = self.stage;
44+
let compiler = self.compiler;
4545
let target = self.target;
4646
let mode = self.mode;
4747

48-
let compiler = builder.compiler(stage, build.build);
49-
5048
let stamp = match mode {
5149
Mode::Libstd => libstd_stamp(build, compiler, target),
5250
Mode::Libtest => libtest_stamp(build, compiler, target),
@@ -59,11 +57,11 @@ impl Step for CleanTools {
5957
}
6058

6159
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
62-
pub struct ToolBuild {
63-
pub stage: u32,
64-
pub target: Interned<String>,
65-
pub tool: &'static str,
66-
pub mode: Mode,
60+
struct ToolBuild {
61+
compiler: Compiler,
62+
target: Interned<String>,
63+
tool: &'static str,
64+
mode: Mode,
6765
}
6866

6967
impl Step for ToolBuild {
@@ -79,21 +77,20 @@ impl Step for ToolBuild {
7977
/// `stage` into the normal cargo output directory.
8078
fn run(self, builder: &Builder) -> PathBuf {
8179
let build = builder.build;
82-
let stage = self.stage;
80+
let compiler = self.compiler;
8381
let target = self.target;
8482
let tool = self.tool;
8583

86-
let compiler = builder.compiler(stage, build.build);
87-
builder.ensure(CleanTools { stage, target, mode: self.mode });
84+
builder.ensure(CleanTools { compiler, target, mode: self.mode });
8885
match self.mode {
8986
Mode::Libstd => builder.ensure(compile::Std { compiler, target }),
9087
Mode::Libtest => builder.ensure(compile::Test { compiler, target }),
9188
Mode::Librustc => builder.ensure(compile::Rustc { compiler, target }),
9289
Mode::Tool => panic!("unexpected Mode::Tool for tool build")
9390
}
9491

95-
let _folder = build.fold_output(|| format!("stage{}-{}", stage, tool));
96-
println!("Building stage{} tool {} ({})", stage, tool, target);
92+
let _folder = build.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
93+
println!("Building stage{} tool {} ({})", compiler.stage, tool, target);
9794

9895
let mut cargo = builder.cargo(compiler, Mode::Tool, target, "build");
9996
let dir = build.src.join("src/tools").join(tool);
@@ -141,7 +138,7 @@ macro_rules! tool {
141138
match tool {
142139
$(Tool::$name =>
143140
self.ensure($name {
144-
stage: 0,
141+
compiler: self.compiler(0, self.build.build),
145142
target: self.build.build,
146143
}),
147144
)+
@@ -152,7 +149,7 @@ macro_rules! tool {
152149
$(
153150
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
154151
pub struct $name {
155-
pub stage: u32,
152+
pub compiler: Compiler,
156153
pub target: Interned<String>,
157154
}
158155

@@ -165,14 +162,14 @@ macro_rules! tool {
165162

166163
fn make_run(run: RunConfig) {
167164
run.builder.ensure($name {
168-
stage: run.builder.top_stage,
165+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
169166
target: run.target,
170167
});
171168
}
172169

173170
fn run(self, builder: &Builder) -> PathBuf {
174171
builder.ensure(ToolBuild {
175-
stage: self.stage,
172+
compiler: self.compiler,
176173
target: self.target,
177174
tool: $tool_name,
178175
mode: $mode,
@@ -198,7 +195,7 @@ tool!(
198195

199196
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
200197
pub struct RemoteTestServer {
201-
pub stage: u32,
198+
pub compiler: Compiler,
202199
pub target: Interned<String>,
203200
}
204201

@@ -211,14 +208,14 @@ impl Step for RemoteTestServer {
211208

212209
fn make_run(run: RunConfig) {
213210
run.builder.ensure(RemoteTestServer {
214-
stage: run.builder.top_stage,
211+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
215212
target: run.target,
216213
});
217214
}
218215

219216
fn run(self, builder: &Builder) -> PathBuf {
220217
builder.ensure(ToolBuild {
221-
stage: self.stage,
218+
compiler: self.compiler,
222219
target: self.target,
223220
tool: "remote-test-server",
224221
mode: Mode::Libstd,
@@ -228,7 +225,7 @@ impl Step for RemoteTestServer {
228225

229226
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
230227
pub struct Cargo {
231-
pub stage: u32,
228+
pub compiler: Compiler,
232229
pub target: Interned<String>,
233230
}
234231

@@ -244,7 +241,7 @@ impl Step for Cargo {
244241

245242
fn make_run(run: RunConfig) {
246243
run.builder.ensure(Cargo {
247-
stage: run.builder.top_stage,
244+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
248245
target: run.target,
249246
});
250247
}
@@ -256,11 +253,11 @@ impl Step for Cargo {
256253
// Cargo depends on procedural macros, which requires a full host
257254
// compiler to be available, so we need to depend on that.
258255
builder.ensure(compile::Rustc {
259-
compiler: builder.compiler(self.stage, builder.build.build),
256+
compiler: self.compiler,
260257
target: builder.build.build,
261258
});
262259
builder.ensure(ToolBuild {
263-
stage: self.stage,
260+
compiler: self.compiler,
264261
target: self.target,
265262
tool: "cargo",
266263
mode: Mode::Librustc,
@@ -270,7 +267,7 @@ impl Step for Cargo {
270267

271268
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
272269
pub struct Rls {
273-
pub stage: u32,
270+
pub compiler: Compiler,
274271
pub target: Interned<String>,
275272
}
276273

@@ -286,7 +283,7 @@ impl Step for Rls {
286283

287284
fn make_run(run: RunConfig) {
288285
run.builder.ensure(Rls {
289-
stage: run.builder.top_stage,
286+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
290287
target: run.target,
291288
});
292289
}
@@ -298,11 +295,11 @@ impl Step for Rls {
298295
// RLS depends on procedural macros, which requires a full host
299296
// compiler to be available, so we need to depend on that.
300297
builder.ensure(compile::Rustc {
301-
compiler: builder.compiler(self.stage, builder.build.build),
298+
compiler: self.compiler,
302299
target: builder.build.build,
303300
});
304301
builder.ensure(ToolBuild {
305-
stage: self.stage,
302+
compiler: self.compiler,
306303
target: self.target,
307304
tool: "rls",
308305
mode: Mode::Librustc,

0 commit comments

Comments
 (0)