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

Add rustc guide to toolstate #59772

Merged
merged 10 commits into from
Jul 6, 2019
387 changes: 360 additions & 27 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ impl<'a> Builder<'a> {
test::TheBook,
test::UnstableBook,
test::RustcBook,
test::RustcGuide,
test::EmbeddedBook,
test::EditionGuide,
test::Rustfmt,
Expand Down
25 changes: 25 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,31 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct RustcGuide;

impl Step for RustcGuide {
type Output = ();
const DEFAULT: bool = false;
const ONLY_HOSTS: bool = true;

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

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustcGuide);
}

fn run(self, builder: &Builder<'_>) {
let src = builder.src.join("src/doc/rustc-guide");
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
builder.run(rustbook_cmd
.arg("linkcheck")
.arg(&src));
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct CrateLibrustc {
compiler: Compiler,
Expand Down
2 changes: 2 additions & 0 deletions src/ci/docker/test-various/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils \
wget \
patch
Expand Down
2 changes: 2 additions & 0 deletions src/ci/docker/x86_64-gnu-debug/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils \
lld \
clang
Expand Down
2 changes: 2 additions & 0 deletions src/ci/docker/x86_64-gnu-full-bootstrap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils

COPY scripts/sccache.sh /scripts/
Expand Down
2 changes: 2 additions & 0 deletions src/ci/docker/x86_64-gnu-llvm-6.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
llvm-6.0-tools \
libedit-dev \
libssl-dev \
pkg-config \
zlib1g-dev \
xz-utils

Expand Down
2 changes: 2 additions & 0 deletions src/ci/docker/x86_64-gnu-nopt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils

COPY scripts/sccache.sh /scripts/
Expand Down
1 change: 1 addition & 0 deletions src/ci/docker/x86_64-gnu-tools/checktools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ status_check() {
# these tools are not required for beta to successfully branch
check_dispatch $1 nightly miri src/tools/miri
check_dispatch $1 nightly embedded-book src/doc/embedded-book
check_dispatch $1 nightly rustc-guide src/doc/rustc-guide
}

# If this PR is intended to update one of these tools, do not let the build pass
Expand Down
2 changes: 2 additions & 0 deletions src/ci/docker/x86_64-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils

COPY scripts/sccache.sh /scripts/
Expand Down
2 changes: 2 additions & 0 deletions src/tools/publish_toolstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
'@ryankurte @thejpster @therealprof'
),
'edition-guide': '@ehuss @Centril @steveklabnik',
'rustc-guide': '@mark-i-m'
}

REPOS = {
Expand All @@ -41,6 +42,7 @@
'rust-by-example': 'https://github.com/rust-lang/rust-by-example',
'embedded-book': 'https://github.com/rust-embedded/book',
'edition-guide': 'https://github.com/rust-lang-nursery/edition-guide',
'rustc-guide': 'https://github.com/rust-lang/rustc-guide',
}


Expand Down
4 changes: 4 additions & 0 deletions src/tools/rustbook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"

[dependencies]
clap = "2.25.0"
failure = "0.1"

[dependencies.mdbook]
version = "0.3.0"
Expand All @@ -18,3 +19,6 @@ package = "mdbook"
version = "0.1.7"
default-features = false
features = ["search"]

[target.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.dependencies]
mdbook-linkcheck = "0.3.0"
46 changes: 44 additions & 2 deletions src/tools/rustbook/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ use mdbook_1::{MDBook as MDBook1};
use mdbook_1::errors::{Result as Result1};

use mdbook::MDBook;
use mdbook::errors::Result;
use mdbook::errors::{Result as Result3};

#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
use mdbook::renderer::RenderContext;

#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
use mdbook_linkcheck::{self, errors::BrokenLinks};
use failure::Error;

fn main() {
let d_message = "-d, --dest-dir=[dest-dir]
Expand All @@ -31,6 +38,9 @@ fn main() {
.arg_from_usage(d_message)
.arg_from_usage(dir_message)
.arg_from_usage(vers_message))
.subcommand(SubCommand::with_name("linkcheck")
.about("Run linkcheck with mdBook 3")
.arg_from_usage(dir_message))
.get_matches();

// Check which subcomamnd the user ran...
Expand Down Expand Up @@ -64,10 +74,42 @@ fn main() {
}
};
},
("linkcheck", Some(sub_matches)) => {
if let Err(err) = linkcheck(sub_matches) {
eprintln!("Error: {}", err);

#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
{
if let Ok(broken_links) = err.downcast::<BrokenLinks>() {
for cause in broken_links.links().iter() {
eprintln!("\tCaused By: {}", cause);
}
}
}

::std::process::exit(101);
}
},
(_, _) => unreachable!(),
};
}

#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> {
let book_dir = get_book_dir(args);
let book = MDBook::load(&book_dir).unwrap();
let cfg = book.config;
let render_ctx = RenderContext::new(&book_dir, book.book, cfg, &book_dir);

mdbook_linkcheck::check_links(&render_ctx)
}

#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))]
pub fn linkcheck(_args: &ArgMatches<'_>) -> Result<(), Error> {
println!("mdbook-linkcheck only works on x86_64 linux targets.");
Ok(())
}

// Build command implementation
pub fn build_1(args: &ArgMatches<'_>) -> Result1<()> {
let book_dir = get_book_dir(args);
Expand All @@ -86,7 +128,7 @@ pub fn build_1(args: &ArgMatches<'_>) -> Result1<()> {
}

// Build command implementation
pub fn build(args: &ArgMatches<'_>) -> Result<()> {
pub fn build(args: &ArgMatches<'_>) -> Result3<()> {
let book_dir = get_book_dir(args);
let mut book = MDBook::load(&book_dir)?;

Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const LICENSES: &[&str] = &[
"Apache-2.0/MIT",
"Apache-2.0 / MIT",
"MIT OR Apache-2.0",
"Apache-2.0 OR MIT",
"MIT",
"Unlicense/MIT",
"Unlicense OR MIT",
Expand Down