mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
parent
44019c79e0
commit
51355478f4
@ -80,7 +80,8 @@ pub struct CrateAnalysis {
|
||||
pub type Externs = HashMap<String, Vec<String>>;
|
||||
|
||||
/// Parses, resolves, and typechecks the given crate
|
||||
fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>, externs: Externs)
|
||||
fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>,
|
||||
externs: Externs, triple: Option<String>)
|
||||
-> (DocContext, CrateAnalysis) {
|
||||
use syntax::codemap::dummy_spanned;
|
||||
use rustc::driver::driver::{FileInput,
|
||||
@ -99,6 +100,7 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>, ext
|
||||
crate_types: vec!(driver::config::CrateTypeRlib),
|
||||
lint_opts: vec!((warning_lint, lint::Allow)),
|
||||
externs: externs,
|
||||
target_triple: triple.unwrap_or(driver::driver::host_triple().to_string()),
|
||||
..rustc::driver::config::basic_options().clone()
|
||||
};
|
||||
|
||||
@ -151,9 +153,10 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>, ext
|
||||
})
|
||||
}
|
||||
|
||||
pub fn run_core(libs: HashSet<Path>, cfgs: Vec<String>, externs: Externs, path: &Path)
|
||||
pub fn run_core(libs: HashSet<Path>, cfgs: Vec<String>, externs: Externs,
|
||||
path: &Path, triple: Option<String>)
|
||||
-> (clean::Crate, CrateAnalysis) {
|
||||
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs, externs);
|
||||
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs, externs, triple);
|
||||
let ctxt = box(GC) ctxt;
|
||||
super::ctxtkey.replace(Some(ctxt));
|
||||
|
||||
|
@ -117,6 +117,7 @@ pub fn opts() -> Vec<getopts::OptGroup> {
|
||||
optflag("", "test", "run code examples as tests"),
|
||||
optmulti("", "test-args", "arguments to pass to the test runner",
|
||||
"ARGS"),
|
||||
optopt("", "target", "target triple to document", "TRIPLE"),
|
||||
optmulti("", "markdown-css", "CSS files to include via <link> in a rendered Markdown file",
|
||||
"FILES"),
|
||||
optmulti("", "html-in-header",
|
||||
@ -321,6 +322,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
||||
.map(|s| Path::new(s.as_slice()))
|
||||
.collect();
|
||||
let cfgs = matches.opt_strs("cfg");
|
||||
let triple = matches.opt_str("target");
|
||||
|
||||
let cr = Path::new(cratefile);
|
||||
info!("starting to run rustc");
|
||||
@ -329,7 +331,8 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
||||
core::run_core(libs.move_iter().collect(),
|
||||
cfgs,
|
||||
externs,
|
||||
&cr)
|
||||
&cr,
|
||||
triple)
|
||||
}).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap();
|
||||
info!("finished with rustc");
|
||||
analysiskey.replace(Some(analysis));
|
||||
|
Loading…
Reference in New Issue
Block a user