Skip to content

Commit

Permalink
Add x {check,build,doc} {compiler/library} aliases.
Browse files Browse the repository at this point in the history
While working on rust-lang#95503,
I realized that this will interfere with existing command lines:
Currently people run `x build library/std` expecting it to be added to the sysroot,
but after that change, it will *only* build `libstd` without making it available
for the toolchain.

It's debatable whether that's a breaking change that will be accepted; if so, this PR is absolutely
necessary to make sure there's a command for "build the standard library and add it to the sysroot".
Even if not, though, I think `x build library` is more clear about what actually happens than the
current `x build library/std`.

For consistency, also add support for `compiler` and all other command variants.  Note that `doc
compiler` was already supported, so in a sense this is just fixing an existing inconsistency.

I plan to change the dev-guide and various instructions in the README to `build library` once this is merged.
  • Loading branch information
jyn514 committed Mar 30, 2022
1 parent 11909e3 commit 9f38ce0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Step for Std {
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.all_krates("test")
run.all_krates("test").path("library")
}

fn make_run(run: RunConfig<'_>) {
Expand Down Expand Up @@ -162,7 +162,7 @@ impl Step for Rustc {
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.all_krates("rustc-main")
run.all_krates("rustc-main").path("compiler")
}

fn make_run(run: RunConfig<'_>) {
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Step for Std {
// When downloading stage1, the standard library has already been copied to the sysroot, so
// there's no need to rebuild it.
let download_rustc = run.builder.config.download_rustc;
run.all_krates("test").default_condition(!download_rustc)
run.all_krates("test").path("library").default_condition(!download_rustc)
}

fn make_run(run: RunConfig<'_>) {
Expand Down Expand Up @@ -1047,7 +1047,7 @@ impl Step for Assemble {
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("compiler/rustc")
run.path("compiler/rustc").path("compiler")
}

fn make_run(run: RunConfig<'_>) {
Expand Down
7 changes: 5 additions & 2 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl Step for Std {

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
run.all_krates("test").default_condition(builder.config.docs)
run.all_krates("test").path("library").default_condition(builder.config.docs)
}

fn make_run(run: RunConfig<'_>) {
Expand Down Expand Up @@ -479,11 +479,14 @@ impl Step for Std {
.iter()
.map(components_simplified)
.filter_map(|path| {
if path.get(0) == Some(&"library") {
if path.len() >= 2 && path.get(0) == Some(&"library") {
// single crate
Some(path[1].to_owned())
} else if !path.is_empty() {
// ??
Some(path[0].to_owned())
} else {
// all library crates
None
}
})
Expand Down

0 comments on commit 9f38ce0

Please sign in to comment.