Skip to content

Commit 5135547

Browse files
committed
rustdoc: Add a --target flag
Closes #13893
1 parent 44019c7 commit 5135547

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/librustdoc/core.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ pub struct CrateAnalysis {
8080
pub type Externs = HashMap<String, Vec<String>>;
8181

8282
/// Parses, resolves, and typechecks the given crate
83-
fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>, externs: Externs)
83+
fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>,
84+
externs: Externs, triple: Option<String>)
8485
-> (DocContext, CrateAnalysis) {
8586
use syntax::codemap::dummy_spanned;
8687
use rustc::driver::driver::{FileInput,
@@ -99,6 +100,7 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>, ext
99100
crate_types: vec!(driver::config::CrateTypeRlib),
100101
lint_opts: vec!((warning_lint, lint::Allow)),
101102
externs: externs,
103+
target_triple: triple.unwrap_or(driver::driver::host_triple().to_string()),
102104
..rustc::driver::config::basic_options().clone()
103105
};
104106

@@ -151,9 +153,10 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>, ext
151153
})
152154
}
153155

154-
pub fn run_core(libs: HashSet<Path>, cfgs: Vec<String>, externs: Externs, path: &Path)
156+
pub fn run_core(libs: HashSet<Path>, cfgs: Vec<String>, externs: Externs,
157+
path: &Path, triple: Option<String>)
155158
-> (clean::Crate, CrateAnalysis) {
156-
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs, externs);
159+
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs, externs, triple);
157160
let ctxt = box(GC) ctxt;
158161
super::ctxtkey.replace(Some(ctxt));
159162

src/librustdoc/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pub fn opts() -> Vec<getopts::OptGroup> {
117117
optflag("", "test", "run code examples as tests"),
118118
optmulti("", "test-args", "arguments to pass to the test runner",
119119
"ARGS"),
120+
optopt("", "target", "target triple to document", "TRIPLE"),
120121
optmulti("", "markdown-css", "CSS files to include via <link> in a rendered Markdown file",
121122
"FILES"),
122123
optmulti("", "html-in-header",
@@ -321,6 +322,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
321322
.map(|s| Path::new(s.as_slice()))
322323
.collect();
323324
let cfgs = matches.opt_strs("cfg");
325+
let triple = matches.opt_str("target");
324326

325327
let cr = Path::new(cratefile);
326328
info!("starting to run rustc");
@@ -329,7 +331,8 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
329331
core::run_core(libs.move_iter().collect(),
330332
cfgs,
331333
externs,
332-
&cr)
334+
&cr,
335+
triple)
333336
}).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap();
334337
info!("finished with rustc");
335338
analysiskey.replace(Some(analysis));

0 commit comments

Comments
 (0)