提交 6fbe2a0c 编写于 作者: C Corey Richardson

rustdoc: pass through --cfg to rustc

Closes #10623
上级 b3ff24ad
......@@ -215,10 +215,12 @@ RUSTDOC = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD))
# $(1) - The crate name (std/extra)
# $(2) - The crate file
# $(3) - The relevant host build triple (to depend on libstd)
#
# Passes --cfg stage2 to rustdoc because it uses the stage2 librustc.
define libdoc
doc/$(1)/index.html: $$(RUSTDOC) $$(TLIB2_T_$(3)_H_$(3))/$(CFG_STDLIB_$(3))
@$$(call E, rustdoc: $$@)
$(Q)$(RUSTDOC) $(2)
$(Q)$(RUSTDOC) --cfg stage2 $(2)
DOCS += doc/$(1)/index.html
endef
......
......@@ -37,7 +37,7 @@ pub struct CrateAnalysis {
/// Parses, resolves, and typechecks the given crate
fn get_ast_and_resolve(cpath: &Path,
libs: HashSet<Path>) -> (DocContext, CrateAnalysis) {
libs: HashSet<Path>, cfgs: ~[~str]) -> (DocContext, CrateAnalysis) {
use syntax::codemap::dummy_spanned;
use rustc::driver::driver::{file_input, build_configuration,
phase_1_parse_input,
......@@ -66,7 +66,9 @@ fn get_ast_and_resolve(cpath: &Path,
span_diagnostic_handler);
let mut cfg = build_configuration(sess);
cfg.push(@dummy_spanned(ast::MetaWord(@"stage2")));
for cfg_ in cfgs.move_iter() {
cfg.push(@dummy_spanned(ast::MetaWord(cfg_.to_managed())));
}
let mut crate = phase_1_parse_input(sess, cfg.clone(), &input);
crate = phase_2_configure_and_expand(sess, cfg, crate);
......@@ -79,8 +81,8 @@ fn get_ast_and_resolve(cpath: &Path,
CrateAnalysis { exported_items: exported_items });
}
pub fn run_core (libs: HashSet<Path>, path: &Path) -> (clean::Crate, CrateAnalysis) {
let (ctxt, analysis) = get_ast_and_resolve(path, libs);
pub fn run_core (libs: HashSet<Path>, cfgs: ~[~str], path: &Path) -> (clean::Crate, CrateAnalysis) {
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs);
let ctxt = @ctxt;
debug!("defmap:");
for (k, v) in ctxt.tycx.def_map.iter() {
......
......@@ -96,6 +96,7 @@ pub fn opts() -> ~[groups::OptGroup] {
optopt("o", "output", "where to place the output", "PATH"),
optmulti("L", "library-path", "directory to add to crate search path",
"DIR"),
optmulti("", "cfg", "pass a --cfg to rustc", ""),
optmulti("", "plugin-path", "directory to load plugins from", "DIR"),
optmulti("", "passes", "space separated list of passes to also run, a \
value of `list` will print available passes",
......@@ -194,11 +195,12 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
// First, parse the crate and extract all relevant information.
let libs = Cell::new(matches.opt_strs("L").map(|s| Path::new(s.as_slice())));
let cfgs = Cell::new(matches.opt_strs("cfg"));
let cr = Cell::new(Path::new(cratefile));
info!("starting to run rustc");
let (crate, analysis) = do std::task::try {
let cr = cr.take();
core::run_core(libs.take().move_iter().collect(), &cr)
core::run_core(libs.take().move_iter().collect(), cfgs.take(), &cr)
}.unwrap();
info!("finished with rustc");
local_data::set(analysiskey, analysis);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册