Rollup merge of #95504 - jyn514:library-alias, r=Mark-Simulacrum

Add `x {check,build,doc} {compiler,library}` aliases.

While working on https://github.com/rust-lang/rust/pull/95503, I realized that it will interfere with existing command lines:
Currently people run `x build library/std` expecting it to "add all library crates to the sysroot",
but after that change, it will *only* build `libstd` and its dependencies (and add them to the sysroot), not libtest or libproc_macro.

That will work for local testing in most cases, but could be confusing. Even if not, though, I think `x build library` is more clear about what actually happens than the current `x build library/std`.

The intended end goal is something like:
- For check/build/doc, we have library + compiler aliases, which correspond to basically "most possible" for that piece. This is the intended path of entry (rather than library/test or similar as today) for when you just want the thing to work -- for example, getting a compiler that is "crates.io-compatible" would be roughly `x.py build library`). #95504
- Specific crate invocations build up to that crate, which means that if you don't care about tests you probably want x.py build library/proc_macro or library/std for faster build times. #95503

Note that this is already implemented today for the `doc` command and seems to work pretty well in practice.

I plan to change the dev-guide and various instructions in the README to `build library` once this is merged.

`@rustbot` label +A-rustbuild
This commit is contained in:
Matthias Krüger 2022-04-24 18:00:25 +02:00 committed by GitHub
commit 472404039e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -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<'_>) {
@ -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<'_>) {

View File

@ -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<'_>) {
@ -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<'_>) {

View File

@ -416,7 +416,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<'_>) {
@ -477,11 +477,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
}
})