Skip to content

Commit dfd52ba

Browse files
committed
Auto merge of #59772 - andrehjr:add-rustc-guide-to-toolstate, r=mark-i-m
Add rustc guide to toolstate Closes #59597
2 parents 254f201 + b5cd962 commit dfd52ba

File tree

14 files changed

+450
-29
lines changed

14 files changed

+450
-29
lines changed

Cargo.lock

+360-27
Large diffs are not rendered by default.

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ impl<'a> Builder<'a> {
405405
test::TheBook,
406406
test::UnstableBook,
407407
test::RustcBook,
408+
test::RustcGuide,
408409
test::EmbeddedBook,
409410
test::EditionGuide,
410411
test::Rustfmt,

src/bootstrap/test.rs

+25
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,31 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
15301530
}
15311531
}
15321532

1533+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1534+
pub struct RustcGuide;
1535+
1536+
impl Step for RustcGuide {
1537+
type Output = ();
1538+
const DEFAULT: bool = false;
1539+
const ONLY_HOSTS: bool = true;
1540+
1541+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1542+
run.path("src/doc/rustc-guide")
1543+
}
1544+
1545+
fn make_run(run: RunConfig<'_>) {
1546+
run.builder.ensure(RustcGuide);
1547+
}
1548+
1549+
fn run(self, builder: &Builder<'_>) {
1550+
let src = builder.src.join("src/doc/rustc-guide");
1551+
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1552+
builder.run(rustbook_cmd
1553+
.arg("linkcheck")
1554+
.arg(&src));
1555+
}
1556+
}
1557+
15331558
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
15341559
pub struct CrateLibrustc {
15351560
compiler: Compiler,

src/ci/docker/test-various/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14+
libssl-dev \
15+
pkg-config \
1416
xz-utils \
1517
wget \
1618
patch

src/ci/docker/x86_64-gnu-debug/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1717
cmake \
1818
sudo \
1919
gdb \
20+
libssl-dev \
21+
pkg-config \
2022
xz-utils \
2123
lld \
2224
clang

src/ci/docker/x86_64-gnu-full-bootstrap/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14+
libssl-dev \
15+
pkg-config \
1416
xz-utils
1517

1618
COPY scripts/sccache.sh /scripts/

src/ci/docker/x86_64-gnu-llvm-6.0/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313
gdb \
1414
llvm-6.0-tools \
1515
libedit-dev \
16+
libssl-dev \
17+
pkg-config \
1618
zlib1g-dev \
1719
xz-utils
1820

src/ci/docker/x86_64-gnu-nopt/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14+
libssl-dev \
15+
pkg-config \
1416
xz-utils
1517

1618
COPY scripts/sccache.sh /scripts/

src/ci/docker/x86_64-gnu-tools/checktools.sh

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ status_check() {
8888
# these tools are not required for beta to successfully branch
8989
check_dispatch $1 nightly miri src/tools/miri
9090
check_dispatch $1 nightly embedded-book src/doc/embedded-book
91+
check_dispatch $1 nightly rustc-guide src/doc/rustc-guide
9192
}
9293

9394
# If this PR is intended to update one of these tools, do not let the build pass

src/ci/docker/x86_64-gnu/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14+
libssl-dev \
15+
pkg-config \
1416
xz-utils
1517

1618
COPY scripts/sccache.sh /scripts/

src/tools/publish_toolstate.py

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
'@ryankurte @thejpster @therealprof'
2929
),
3030
'edition-guide': '@ehuss @Centril @steveklabnik',
31+
'rustc-guide': '@mark-i-m'
3132
}
3233

3334
REPOS = {
@@ -41,6 +42,7 @@
4142
'rust-by-example': 'https://github.com/rust-lang/rust-by-example',
4243
'embedded-book': 'https://github.com/rust-embedded/book',
4344
'edition-guide': 'https://github.com/rust-lang-nursery/edition-guide',
45+
'rustc-guide': 'https://github.com/rust-lang/rustc-guide',
4446
}
4547

4648

src/tools/rustbook/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2018"
77

88
[dependencies]
99
clap = "2.25.0"
10+
failure = "0.1"
1011

1112
[dependencies.mdbook]
1213
version = "0.3.0"
@@ -18,3 +19,6 @@ package = "mdbook"
1819
version = "0.1.7"
1920
default-features = false
2021
features = ["search"]
22+
23+
[target.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.dependencies]
24+
mdbook-linkcheck = "0.3.0"

src/tools/rustbook/src/main.rs

+44-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ use mdbook_1::{MDBook as MDBook1};
1111
use mdbook_1::errors::{Result as Result1};
1212

1313
use mdbook::MDBook;
14-
use mdbook::errors::Result;
14+
use mdbook::errors::{Result as Result3};
15+
16+
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
17+
use mdbook::renderer::RenderContext;
18+
19+
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
20+
use mdbook_linkcheck::{self, errors::BrokenLinks};
21+
use failure::Error;
1522

1623
fn main() {
1724
let d_message = "-d, --dest-dir=[dest-dir]
@@ -31,6 +38,9 @@ fn main() {
3138
.arg_from_usage(d_message)
3239
.arg_from_usage(dir_message)
3340
.arg_from_usage(vers_message))
41+
.subcommand(SubCommand::with_name("linkcheck")
42+
.about("Run linkcheck with mdBook 3")
43+
.arg_from_usage(dir_message))
3444
.get_matches();
3545

3646
// Check which subcomamnd the user ran...
@@ -64,10 +74,42 @@ fn main() {
6474
}
6575
};
6676
},
77+
("linkcheck", Some(sub_matches)) => {
78+
if let Err(err) = linkcheck(sub_matches) {
79+
eprintln!("Error: {}", err);
80+
81+
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
82+
{
83+
if let Ok(broken_links) = err.downcast::<BrokenLinks>() {
84+
for cause in broken_links.links().iter() {
85+
eprintln!("\tCaused By: {}", cause);
86+
}
87+
}
88+
}
89+
90+
::std::process::exit(101);
91+
}
92+
},
6793
(_, _) => unreachable!(),
6894
};
6995
}
7096

97+
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
98+
pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> {
99+
let book_dir = get_book_dir(args);
100+
let book = MDBook::load(&book_dir).unwrap();
101+
let cfg = book.config;
102+
let render_ctx = RenderContext::new(&book_dir, book.book, cfg, &book_dir);
103+
104+
mdbook_linkcheck::check_links(&render_ctx)
105+
}
106+
107+
#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))]
108+
pub fn linkcheck(_args: &ArgMatches<'_>) -> Result<(), Error> {
109+
println!("mdbook-linkcheck only works on x86_64 linux targets.");
110+
Ok(())
111+
}
112+
71113
// Build command implementation
72114
pub fn build_1(args: &ArgMatches<'_>) -> Result1<()> {
73115
let book_dir = get_book_dir(args);
@@ -86,7 +128,7 @@ pub fn build_1(args: &ArgMatches<'_>) -> Result1<()> {
86128
}
87129

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

src/tools/tidy/src/deps.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const LICENSES: &[&str] = &[
1414
"Apache-2.0/MIT",
1515
"Apache-2.0 / MIT",
1616
"MIT OR Apache-2.0",
17+
"Apache-2.0 OR MIT",
1718
"MIT",
1819
"Unlicense/MIT",
1920
"Unlicense OR MIT",

0 commit comments

Comments
 (0)