about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2013-11-24 23:31:21 -0500
committerCorey Richardson <corey@octayn.net>2013-11-24 23:33:44 -0500
commit6fbe2a0c8b62487d64c32fa57bbed8138251f8c5 (patch)
tree51d00b54bac0b21cb2df82190f62e9184da0cd7e
parentb3ff24adaa8c7f9c48c525f284526c23ffd33fcb (diff)
downloadrust-6fbe2a0c8b62487d64c32fa57bbed8138251f8c5.tar.gz
rust-6fbe2a0c8b62487d64c32fa57bbed8138251f8c5.zip
rustdoc: pass through --cfg to rustc
Closes #10623
-rw-r--r--mk/docs.mk4
-rw-r--r--src/librustdoc/core.rs10
-rw-r--r--src/librustdoc/lib.rs4
3 files changed, 12 insertions, 6 deletions
diff --git a/mk/docs.mk b/mk/docs.mk
index a7ffe928940..412981add6c 100644
--- a/mk/docs.mk
+++ b/mk/docs.mk
@@ -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
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index c802d41bcee..79aba0f1320 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -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() {
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 12a79aa545e..1ed1b79a628 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -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);