Auto merge of #95502 - jyn514:doc-rustc, r=Mark-Simulacrum
Fix `x doc compiler/rustc` This also has a few cleanups to `doc.rs`. The last two commits I don't care about, but the first commit I'd like to keep - it will be very useful for https://github.com/rust-lang/rust/issues/44293. Fixes https://github.com/rust-lang/rust/issues/95447.
This commit is contained in:
commit
341883d051
@ -7,7 +7,6 @@
|
||||
//! Everything here is basically just a shim around calling either `rustbook` or
|
||||
//! `rustdoc`.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
@ -554,13 +553,9 @@ impl Step for Rustc {
|
||||
let paths = builder
|
||||
.paths
|
||||
.iter()
|
||||
.map(components_simplified)
|
||||
.filter_map(|path| {
|
||||
if path.get(0) == Some(&"compiler") {
|
||||
path.get(1).map(|p| p.to_owned())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.filter(|path| {
|
||||
let components = components_simplified(path);
|
||||
components.len() >= 2 && components[0] == "compiler"
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@ -608,38 +603,22 @@ impl Step for Rustc {
|
||||
cargo.rustdocflag("--extern-html-root-url");
|
||||
cargo.rustdocflag("ena=https://docs.rs/ena/latest/");
|
||||
|
||||
let mut compiler_crates = HashSet::new();
|
||||
|
||||
if paths.is_empty() {
|
||||
// Find dependencies for top level crates.
|
||||
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
|
||||
compiler_crates.extend(
|
||||
builder
|
||||
.in_tree_crates(root_crate, Some(target))
|
||||
.into_iter()
|
||||
.map(|krate| krate.name),
|
||||
);
|
||||
}
|
||||
let root_crates = if paths.is_empty() {
|
||||
vec![
|
||||
INTERNER.intern_str("rustc_driver"),
|
||||
INTERNER.intern_str("rustc_codegen_llvm"),
|
||||
INTERNER.intern_str("rustc_codegen_ssa"),
|
||||
]
|
||||
} else {
|
||||
for root_crate in paths {
|
||||
if !builder.src.join("compiler").join(&root_crate).exists() {
|
||||
builder.info(&format!(
|
||||
"\tskipping - compiler/{} (unknown compiler crate)",
|
||||
root_crate
|
||||
));
|
||||
} else {
|
||||
compiler_crates.extend(
|
||||
builder
|
||||
.in_tree_crates(root_crate, Some(target))
|
||||
.into_iter()
|
||||
.map(|krate| krate.name),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
paths.into_iter().map(|p| builder.crate_paths[p]).collect()
|
||||
};
|
||||
// Find dependencies for top level crates.
|
||||
let compiler_crates = root_crates.iter().flat_map(|krate| {
|
||||
builder.in_tree_crates(krate, Some(target)).into_iter().map(|krate| krate.name)
|
||||
});
|
||||
|
||||
let mut to_open = None;
|
||||
for krate in &compiler_crates {
|
||||
for krate in compiler_crates {
|
||||
// Create all crate output directories first to make sure rustdoc uses
|
||||
// relative links.
|
||||
// FIXME: Cargo should probably do this itself.
|
||||
|
@ -302,7 +302,9 @@ pub struct Build {
|
||||
ar: HashMap<TargetSelection, PathBuf>,
|
||||
ranlib: HashMap<TargetSelection, PathBuf>,
|
||||
// Miscellaneous
|
||||
// allow bidirectional lookups: both name -> path and path -> name
|
||||
crates: HashMap<Interned<String>, Crate>,
|
||||
crate_paths: HashMap<PathBuf, Interned<String>>,
|
||||
is_sudo: bool,
|
||||
ci_env: CiEnv,
|
||||
delayed_failures: RefCell<Vec<String>>,
|
||||
@ -492,6 +494,7 @@ impl Build {
|
||||
ar: HashMap::new(),
|
||||
ranlib: HashMap::new(),
|
||||
crates: HashMap::new(),
|
||||
crate_paths: HashMap::new(),
|
||||
is_sudo,
|
||||
ci_env: CiEnv::current(),
|
||||
delayed_failures: RefCell::new(Vec::new()),
|
||||
|
@ -49,7 +49,11 @@ pub fn build(build: &mut Build) {
|
||||
.filter(|dep| dep.source.is_none())
|
||||
.map(|dep| INTERNER.intern_string(dep.name))
|
||||
.collect();
|
||||
build.crates.insert(name, Crate { name, deps, path });
|
||||
let krate = Crate { name, deps, path };
|
||||
let relative_path = krate.local_path(build);
|
||||
build.crates.insert(name, krate);
|
||||
let existing_path = build.crate_paths.insert(relative_path, name);
|
||||
assert!(existing_path.is_none(), "multiple crates with the same path");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use crate::native;
|
||||
use crate::tool::{self, SourceType, Tool};
|
||||
use crate::toolstate::ToolState;
|
||||
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t};
|
||||
use crate::Crate as CargoCrate;
|
||||
use crate::{envify, CLang, DocTests, GitRepo, Mode};
|
||||
|
||||
const ADB_TEST_DIR: &str = "/data/tmp/work";
|
||||
@ -1901,19 +1900,10 @@ impl Step for CrateLibrustc {
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
let builder = run.builder;
|
||||
let compiler = builder.compiler(builder.top_stage, run.build_triple());
|
||||
let krate = builder.crate_paths[&run.path];
|
||||
let test_kind = builder.kind.into();
|
||||
|
||||
for krate in builder.in_tree_crates("rustc-main", Some(run.target)) {
|
||||
if krate.path.ends_with(&run.path) {
|
||||
let test_kind = builder.kind.into();
|
||||
|
||||
builder.ensure(CrateLibrustc {
|
||||
compiler,
|
||||
target: run.target,
|
||||
test_kind,
|
||||
krate: krate.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
builder.ensure(CrateLibrustc { compiler, target: run.target, test_kind, krate });
|
||||
}
|
||||
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
@ -1947,24 +1937,10 @@ impl Step for Crate {
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
let builder = run.builder;
|
||||
let compiler = builder.compiler(builder.top_stage, run.build_triple());
|
||||
let test_kind = builder.kind.into();
|
||||
let krate = builder.crate_paths[&run.path];
|
||||
|
||||
let make = |mode: Mode, krate: &CargoCrate| {
|
||||
let test_kind = builder.kind.into();
|
||||
|
||||
builder.ensure(Crate {
|
||||
compiler,
|
||||
target: run.target,
|
||||
mode,
|
||||
test_kind,
|
||||
krate: krate.name,
|
||||
});
|
||||
};
|
||||
|
||||
for krate in builder.in_tree_crates("test", Some(run.target)) {
|
||||
if krate.path.ends_with(&run.path) {
|
||||
make(Mode::Std, krate);
|
||||
}
|
||||
}
|
||||
builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, test_kind, krate });
|
||||
}
|
||||
|
||||
/// Runs all unit tests plus documentation tests for a given crate defined
|
||||
|
Loading…
x
Reference in New Issue
Block a user