Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix x doc compiler/rustc #95502

Merged
merged 4 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 16 additions & 37 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<_>>();

Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,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>>,
Expand Down Expand Up @@ -491,6 +493,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()),
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
36 changes: 6 additions & 30 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<'_>) {
Expand Down Expand Up @@ -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
Expand Down