Allow building single crates for the compiler and standard library · rust-lang/rust@d0011b0 (original) (raw)

`@@ -57,6 +57,24 @@ fn check_cli(paths: [&str; N]) {

`

57

57

`);

`

58

58

`}

`

59

59

``

``

60

`+

macro_rules! std {

`

``

61

`+

($host:ident => target:ident,stage=target:ident, stage = target:ident,stage=stage:literal) => {

`

``

62

`+

compile::Std::new(

`

``

63

`+

Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },

`

``

64

`+

TargetSelection::from_user(stringify!($target)),

`

``

65

`+

)

`

``

66

`+

};

`

``

67

`+

}

`

``

68

+

``

69

`+

macro_rules! rustc {

`

``

70

`+

($host:ident => target:ident,stage=target:ident, stage = target:ident,stage=stage:literal) => {

`

``

71

`+

compile::Rustc::new(

`

``

72

`+

Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },

`

``

73

`+

TargetSelection::from_user(stringify!($target)),

`

``

74

`+

)

`

``

75

`+

};

`

``

76

`+

}

`

``

77

+

60

78

`#[test]

`

61

79

`fn test_valid() {

`

62

80

`// make sure multi suite paths are accepted

`

`@@ -117,6 +135,17 @@ fn test_exclude_kind() {

`

117

135

`assert!(run_build(&[path], config).contains::tool::CargoTest());

`

118

136

`}

`

119

137

``

``

138

`` +

/// Ensure that if someone passes both a single crate and library, all library crates get built.

``

``

139

`+

#[test]

`

``

140

`+

fn alias_and_path_for_library() {

`

``

141

`+

let mut cache =

`

``

142

`+

run_build(&["library".into(), "core".into()], configure("build", &["A"], &["A"]));

`

``

143

`+

assert_eq!(

`

``

144

`+

first(cache.all::compile::Std()),

`

``

145

`+

&[std!(A => A, stage = 0), std!(A => A, stage = 1)]

`

``

146

`+

);

`

``

147

`+

}

`

``

148

+

120

149

`mod defaults {

`

121

150

`use super::{configure, first, run_build};

`

122

151

`use crate::builder::*;

`

`@@ -130,10 +159,7 @@ mod defaults {

`

130

159

`let a = TargetSelection::from_user("A");

`

131

160

`assert_eq!(

`

132

161

` first(cache.all::compile::Std()),

`

133

``

`-

&[

`

134

``

`-

compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },

`

135

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },

`

136

``

`-

]

`

``

162

`+

&[std!(A => A, stage = 0), std!(A => A, stage = 1),]

`

137

163

`);

`

138

164

`assert!(!cache.all::compile::Assemble().is_empty());

`

139

165

`// Make sure rustdoc is only built once.

`

`@@ -143,10 +169,7 @@ mod defaults {

`

143

169

`// - this is the compiler it's linked to, not built with.

`

144

170

`&[tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }],

`

145

171

`);

`

146

``

`-

assert_eq!(

`

147

``

`-

first(cache.all::compile::Rustc()),

`

148

``

`-

&[compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },]

`

149

``

`-

);

`

``

172

`+

assert_eq!(first(cache.all::compile::Rustc()), &[rustc!(A => A, stage = 0)],);

`

150

173

`}

`

151

174

``

152

175

`#[test]

`

`@@ -155,10 +178,7 @@ mod defaults {

`

155

178

`let mut cache = run_build(&[], config);

`

156

179

``

157

180

`let a = TargetSelection::from_user("A");

`

158

``

`-

assert_eq!(

`

159

``

`-

first(cache.all::compile::Std()),

`

160

``

`-

&[compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },]

`

161

``

`-

);

`

``

181

`+

assert_eq!(first(cache.all::compile::Std()), &[std!(A => A, stage = 0)]);

`

162

182

`assert!(!cache.all::compile::Assemble().is_empty());

`

163

183

`assert_eq!(

`

164

184

` first(cache.all::tool::Rustdoc()),

`

`@@ -185,10 +205,10 @@ mod defaults {

`

185

205

`assert_eq!(

`

186

206

` first(cache.all::compile::Std()),

`

187

207

`&[

`

188

``

`-

compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },

`

189

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },

`

190

``

`-

compile::Std { compiler: Compiler { host: a, stage: 0 }, target: b },

`

191

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },

`

``

208

`+

std!(A => A, stage = 0),

`

``

209

`+

std!(A => A, stage = 1),

`

``

210

`+

std!(A => B, stage = 0),

`

``

211

`+

std!(A => B, stage = 1),

`

192

212

`]

`

193

213

`);

`

194

214

`assert_eq!(

`

`@@ -208,10 +228,7 @@ mod defaults {

`

208

228

`);

`

209

229

`assert_eq!(

`

210

230

` first(cache.all::compile::Rustc()),

`

211

``

`-

&[

`

212

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },

`

213

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: b },

`

214

``

`-

]

`

``

231

`+

&[rustc!(A => A, stage = 0), rustc!(A => B, stage = 0),]

`

215

232

`);

`

216

233

`}

`

217

234

``

`@@ -334,19 +351,18 @@ mod dist {

`

334

351

`assert_eq!(

`

335

352

` first(cache.all::compile::Std()),

`

336

353

`&[

`

337

``

`-

compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },

`

338

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },

`

339

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },

`

340

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },

`

341

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },

`

``

354

`+

std!(A => A, stage = 0),

`

``

355

`+

std!(A => A, stage = 1),

`

``

356

`+

std!(A => A, stage = 2),

`

``

357

`+

std!(A => B, stage = 1),

`

``

358

`+

std!(A => B, stage = 2),

`

342

359

`],

`

343

360

`);

`

344

361

`assert_eq!(first(cache.all::dist::Src()), &[dist::Src]);

`

345

362

`}

`

346

363

``

347

364

`#[test]

`

348

365

`fn dist_only_cross_host() {

`

349

``

`-

let a = TargetSelection::from_user("A");

`

350

366

`let b = TargetSelection::from_user("B");

`

351

367

`let mut config = configure(&["A", "B"], &["A", "B"]);

`

352

368

` config.docs = false;

`

`@@ -360,10 +376,7 @@ mod dist {

`

360

376

`);

`

361

377

`assert_eq!(

`

362

378

` first(cache.all::compile::Rustc()),

`

363

``

`-

&[

`

364

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },

`

365

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b },

`

366

``

`-

]

`

``

379

`+

&[rustc!(A => A, stage = 0), rustc!(A => B, stage = 1),]

`

367

380

`);

`

368

381

`}

`

369

382

``

`@@ -450,11 +463,11 @@ mod dist {

`

450

463

`assert_eq!(

`

451

464

` first(cache.all::compile::Std()),

`

452

465

`&[

`

453

``

`-

compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },

`

454

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },

`

455

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },

`

456

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },

`

457

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },

`

``

466

`+

std!(A => A, stage = 0),

`

``

467

`+

std!(A => A, stage = 1),

`

``

468

`+

std!(A => A, stage = 2),

`

``

469

`+

std!(A => B, stage = 1),

`

``

470

`+

std!(A => B, stage = 2),

`

458

471

`]

`

459

472

`);

`

460

473

`assert_eq!(

`

`@@ -474,33 +487,29 @@ mod dist {

`

474

487

`let mut builder = Builder::new(&build);

`

475

488

` builder.run_step_descriptions(

`

476

489

`&Builder::get_step_descriptions(Kind::Build),

`

477

``

`-

&["compiler/rustc".into(), "library/std".into()],

`

``

490

`+

&["compiler/rustc".into(), "library".into()],

`

478

491

`);

`

479

492

``

480

``

`-

let a = TargetSelection::from_user("A");

`

481

``

`-

let b = TargetSelection::from_user("B");

`

482

``

`-

let c = TargetSelection::from_user("C");

`

483

``

-

484

493

`assert_eq!(

`

485

494

` first(builder.cache.all::compile::Std()),

`

486

495

`&[

`

487

``

`-

compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },

`

488

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },

`

489

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },

`

490

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },

`

491

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },

`

492

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },

`

``

496

`+

std!(A => A, stage = 0),

`

``

497

`+

std!(A => A, stage = 1),

`

``

498

`+

std!(A => A, stage = 2),

`

``

499

`+

std!(A => B, stage = 1),

`

``

500

`+

std!(A => B, stage = 2),

`

``

501

`+

std!(A => C, stage = 2),

`

493

502

`]

`

494

503

`);

`

495

``

`-

assert!(!builder.cache.all::compile::Assemble().is_empty());

`

``

504

`+

assert_eq!(builder.cache.all::compile::Assemble().len(), 5);

`

496

505

`assert_eq!(

`

497

506

` first(builder.cache.all::compile::Rustc()),

`

498

507

`&[

`

499

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },

`

500

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a },

`

501

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: a },

`

502

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b },

`

503

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: b },

`

``

508

`+

rustc!(A => A, stage = 0),

`

``

509

`+

rustc!(A => A, stage = 1),

`

``

510

`+

rustc!(A => A, stage = 2),

`

``

511

`+

rustc!(A => B, stage = 1),

`

``

512

`+

rustc!(A => B, stage = 2),

`

504

513

`]

`

505

514

`);

`

506

515

`}

`

`@@ -513,15 +522,10 @@ mod dist {

`

513

522

` builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);

`

514

523

``

515

524

`let a = TargetSelection::from_user("A");

`

516

``

`-

let c = TargetSelection::from_user("C");

`

517

525

``

518

526

`assert_eq!(

`

519

527

` first(builder.cache.all::compile::Std()),

`

520

``

`-

&[

`

521

``

`-

compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },

`

522

``

`-

compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },

`

523

``

`-

compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },

`

524

``

`-

]

`

``

528

`+

&[std!(A => A, stage = 0), std!(A => A, stage = 1), std!(A => C, stage = 2),]

`

525

529

`);

`

526

530

`assert_eq!(

`

527

531

` first(builder.cache.all::compile::Assemble()),

`

`@@ -533,10 +537,7 @@ mod dist {

`

533

537

`);

`

534

538

`assert_eq!(

`

535

539

` first(builder.cache.all::compile::Rustc()),

`

536

``

`-

&[

`

537

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },

`

538

``

`-

compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a },

`

539

``

`-

]

`

``

540

`+

&[rustc!(A => A, stage = 0), rustc!(A => A, stage = 1),]

`

540

541

`);

`

541

542

`}

`

542

543

``