rustbuild: Add the error-index-generator
This adds a step and a rule for building the error index as part of rustbuild.
This commit is contained in:
parent
e9cb96a56a
commit
3e6fed3a7a
@ -126,7 +126,7 @@ TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
|
|||||||
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
|
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
|
||||||
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
|
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
|
||||||
TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
|
TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
|
||||||
TOOL_SOURCE_error_index_generator := $(S)src/error_index_generator/main.rs
|
TOOL_SOURCE_error_index_generator := $(S)src/tools/error_index_generator/main.rs
|
||||||
|
|
||||||
ONLY_RLIB_core := 1
|
ONLY_RLIB_core := 1
|
||||||
ONLY_RLIB_libc := 1
|
ONLY_RLIB_libc := 1
|
||||||
|
@ -139,3 +139,16 @@ pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
|
|||||||
build.run(&mut cargo);
|
build.run(&mut cargo);
|
||||||
cp_r(&out_dir, out)
|
cp_r(&out_dir, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn error_index(build: &Build, stage: u32, host: &str, out: &Path) {
|
||||||
|
println!("Documenting stage{} error index ({})", stage, host);
|
||||||
|
let compiler = Compiler::new(stage, host);
|
||||||
|
let mut index = Command::new(build.tool(&compiler, "error_index_generator"));
|
||||||
|
index.arg("html");
|
||||||
|
index.arg(out.join("error-index.html"));
|
||||||
|
|
||||||
|
// FIXME: shouldn't have to pass this env var
|
||||||
|
index.env("CFG_BUILD", &build.config.build);
|
||||||
|
|
||||||
|
build.run(&mut index);
|
||||||
|
}
|
||||||
|
@ -178,6 +178,10 @@ impl Build {
|
|||||||
ToolRustbook { stage } => {
|
ToolRustbook { stage } => {
|
||||||
compile::tool(self, stage, target.target, "rustbook");
|
compile::tool(self, stage, target.target, "rustbook");
|
||||||
}
|
}
|
||||||
|
ToolErrorIndex { stage } => {
|
||||||
|
compile::tool(self, stage, target.target,
|
||||||
|
"error_index_generator");
|
||||||
|
}
|
||||||
DocBook { stage } => {
|
DocBook { stage } => {
|
||||||
doc::rustbook(self, stage, target.target, "book", &doc_out);
|
doc::rustbook(self, stage, target.target, "book", &doc_out);
|
||||||
}
|
}
|
||||||
@ -198,6 +202,9 @@ impl Build {
|
|||||||
DocRustc { stage } => {
|
DocRustc { stage } => {
|
||||||
doc::rustc(self, stage, target.target, &doc_out);
|
doc::rustc(self, stage, target.target, &doc_out);
|
||||||
}
|
}
|
||||||
|
DocErrorIndex { stage } => {
|
||||||
|
doc::error_index(self, stage, target.target, &doc_out);
|
||||||
|
}
|
||||||
|
|
||||||
CheckLinkcheck { stage } => {
|
CheckLinkcheck { stage } => {
|
||||||
check::linkcheck(self, stage, target.target);
|
check::linkcheck(self, stage, target.target);
|
||||||
|
@ -48,6 +48,7 @@ macro_rules! targets {
|
|||||||
// Various tools that we can build as part of the build.
|
// Various tools that we can build as part of the build.
|
||||||
(tool_linkchecker, ToolLinkchecker { stage: u32 }),
|
(tool_linkchecker, ToolLinkchecker { stage: u32 }),
|
||||||
(tool_rustbook, ToolRustbook { stage: u32 }),
|
(tool_rustbook, ToolRustbook { stage: u32 }),
|
||||||
|
(tool_error_index, ToolErrorIndex { stage: u32 }),
|
||||||
|
|
||||||
// Steps for long-running native builds. Ideally these wouldn't
|
// Steps for long-running native builds. Ideally these wouldn't
|
||||||
// actually exist and would be part of build scripts, but for now
|
// actually exist and would be part of build scripts, but for now
|
||||||
@ -68,6 +69,7 @@ macro_rules! targets {
|
|||||||
(doc_standalone, DocStandalone { stage: u32 }),
|
(doc_standalone, DocStandalone { stage: u32 }),
|
||||||
(doc_std, DocStd { stage: u32 }),
|
(doc_std, DocStd { stage: u32 }),
|
||||||
(doc_rustc, DocRustc { stage: u32 }),
|
(doc_rustc, DocRustc { stage: u32 }),
|
||||||
|
(doc_error_index, DocErrorIndex { stage: u32 }),
|
||||||
|
|
||||||
// Steps for running tests. The 'check' target is just a pseudo
|
// Steps for running tests. The 'check' target is just a pseudo
|
||||||
// target to depend on a bunch of others.
|
// target to depend on a bunch of others.
|
||||||
@ -265,6 +267,9 @@ impl<'a> Step<'a> {
|
|||||||
Source::DocStyle { stage } => {
|
Source::DocStyle { stage } => {
|
||||||
vec![self.tool_rustbook(stage)]
|
vec![self.tool_rustbook(stage)]
|
||||||
}
|
}
|
||||||
|
Source::DocErrorIndex { stage } => {
|
||||||
|
vec![self.tool_error_index(stage)]
|
||||||
|
}
|
||||||
Source::DocStandalone { stage } => {
|
Source::DocStandalone { stage } => {
|
||||||
vec![self.rustc(stage)]
|
vec![self.rustc(stage)]
|
||||||
}
|
}
|
||||||
@ -274,7 +279,8 @@ impl<'a> Step<'a> {
|
|||||||
Source::Doc { stage } => {
|
Source::Doc { stage } => {
|
||||||
vec![self.doc_book(stage), self.doc_nomicon(stage),
|
vec![self.doc_book(stage), self.doc_nomicon(stage),
|
||||||
self.doc_style(stage), self.doc_standalone(stage),
|
self.doc_style(stage), self.doc_standalone(stage),
|
||||||
self.doc_std(stage)]
|
self.doc_std(stage),
|
||||||
|
self.doc_error_index(stage)]
|
||||||
}
|
}
|
||||||
Source::Check { stage, compiler: _ } => {
|
Source::Check { stage, compiler: _ } => {
|
||||||
vec![self.check_linkcheck(stage)]
|
vec![self.check_linkcheck(stage)]
|
||||||
@ -286,6 +292,7 @@ impl<'a> Step<'a> {
|
|||||||
Source::ToolLinkchecker { stage } => {
|
Source::ToolLinkchecker { stage } => {
|
||||||
vec![self.libstd(stage, self.compiler(stage))]
|
vec![self.libstd(stage, self.compiler(stage))]
|
||||||
}
|
}
|
||||||
|
Source::ToolErrorIndex { stage } |
|
||||||
Source::ToolRustbook { stage } => {
|
Source::ToolRustbook { stage } => {
|
||||||
vec![self.librustc(stage, self.compiler(stage))]
|
vec![self.librustc(stage, self.compiler(stage))]
|
||||||
}
|
}
|
||||||
|
4
src/tools/error_index_generator/Cargo.lock
generated
Normal file
4
src/tools/error_index_generator/Cargo.lock
generated
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[root]
|
||||||
|
name = "error_index_generator"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
8
src/tools/error_index_generator/Cargo.toml
Normal file
8
src/tools/error_index_generator/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
authors = ["The Rust Project Developers"]
|
||||||
|
name = "error_index_generator"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "error_index_generator"
|
||||||
|
path = "main.rs"
|
@ -15,11 +15,12 @@ extern crate rustdoc;
|
|||||||
extern crate serialize as rustc_serialize;
|
extern crate serialize as rustc_serialize;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::env;
|
||||||
|
use std::error::Error;
|
||||||
use std::fs::{read_dir, File};
|
use std::fs::{read_dir, File};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::env;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::error::Error;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use syntax::diagnostics::metadata::{get_metadata_dir, ErrorMetadataMap, ErrorMetadata};
|
use syntax::diagnostics::metadata::{get_metadata_dir, ErrorMetadataMap, ErrorMetadata};
|
||||||
|
|
||||||
@ -173,31 +174,35 @@ fn render_error_page<T: Formatter>(err_map: &ErrorMetadataMap, output_path: &Pat
|
|||||||
formatter.footer(&mut output_file)
|
formatter.footer(&mut output_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_with_result(format: OutputFormat) -> Result<(), Box<Error>> {
|
fn main_with_result(format: OutputFormat, dst: &Path) -> Result<(), Box<Error>> {
|
||||||
let build_arch = try!(env::var("CFG_BUILD"));
|
let build_arch = try!(env::var("CFG_BUILD"));
|
||||||
let metadata_dir = get_metadata_dir(&build_arch);
|
let metadata_dir = get_metadata_dir(&build_arch);
|
||||||
let err_map = try!(load_all_errors(&metadata_dir));
|
let err_map = try!(load_all_errors(&metadata_dir));
|
||||||
match format {
|
match format {
|
||||||
OutputFormat::Unknown(s) => panic!("Unknown output format: {}", s),
|
OutputFormat::Unknown(s) => panic!("Unknown output format: {}", s),
|
||||||
OutputFormat::HTML(h) => try!(render_error_page(&err_map,
|
OutputFormat::HTML(h) => try!(render_error_page(&err_map, dst, h)),
|
||||||
Path::new("doc/error-index.html"),
|
OutputFormat::Markdown(m) => try!(render_error_page(&err_map, dst, m)),
|
||||||
h)),
|
|
||||||
OutputFormat::Markdown(m) => try!(render_error_page(&err_map,
|
|
||||||
Path::new("doc/error-index.md"),
|
|
||||||
m)),
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_args() -> OutputFormat {
|
fn parse_args() -> (OutputFormat, PathBuf) {
|
||||||
for arg in env::args().skip(1) {
|
let mut args = env::args().skip(1);
|
||||||
return OutputFormat::from(&arg);
|
let format = args.next().map(|a| OutputFormat::from(&a))
|
||||||
}
|
.unwrap_or(OutputFormat::from("html"));
|
||||||
OutputFormat::from("html")
|
let dst = args.next().map(PathBuf::from).unwrap_or_else(|| {
|
||||||
|
match format {
|
||||||
|
OutputFormat::HTML(..) => PathBuf::from("doc/error-index.html"),
|
||||||
|
OutputFormat::Markdown(..) => PathBuf::from("doc/error-index.md"),
|
||||||
|
OutputFormat::Unknown(..) => PathBuf::from("<nul>"),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
(format, dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(e) = main_with_result(parse_args()) {
|
let (format, dst) = parse_args();
|
||||||
|
if let Err(e) = main_with_result(format, &dst) {
|
||||||
panic!("{}", e.description());
|
panic!("{}", e.description());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user