diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2014-01-06 14:00:46 +0200 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2014-01-06 14:00:46 +0200 |
| commit | 3119d18e55fd393641cd744545f350807c4ee7b8 (patch) | |
| tree | 5b7313e2a6dae8ac968c6c2bd642586bd4e19da5 /src/librustpkg | |
| parent | 4e622becdc5fb4e07f95550c3a59fd909b97e5bb (diff) | |
Disowned the Visitor.
Diffstat (limited to 'src/librustpkg')
| -rw-r--r-- | src/librustpkg/lib.rs | 12 | ||||
| -rw-r--r-- | src/librustpkg/util.rs | 10 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/librustpkg/lib.rs b/src/librustpkg/lib.rs index 7051c7de058..1f6de700940 100644 --- a/src/librustpkg/lib.rs +++ b/src/librustpkg/lib.rs @@ -86,8 +86,8 @@ struct PkgScript<'a> { sess: session::Session, /// The config for compiling the custom build script cfg: ast::CrateConfig, - /// The crate for the custom build script - crate: Option<ast::Crate>, + /// The crate and ast_map for the custom build script + crate_and_map: Option<(ast::Crate, syntax::ast_map::map)>, /// Directory in which to store build output build_dir: Path } @@ -117,7 +117,7 @@ impl<'a> PkgScript<'a> { @diagnostic::Emitter); let cfg = driver::build_configuration(sess); let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input); - let crate = driver::phase_2_configure_and_expand(sess, cfg.clone(), crate); + let crate_and_map = driver::phase_2_configure_and_expand(sess, cfg.clone(), crate); let work_dir = build_pkg_id_in_workspace(id, workspace); debug!("Returning package script with id {}", id.to_str()); @@ -127,7 +127,7 @@ impl<'a> PkgScript<'a> { input: script, sess: sess, cfg: cfg, - crate: Some(crate), + crate_and_map: Some(crate_and_map), build_dir: work_dir } } @@ -137,7 +137,8 @@ impl<'a> PkgScript<'a> { debug!("Working directory = {}", self.build_dir.display()); // Collect together any user-defined commands in the package script - let crate = util::ready_crate(sess, self.crate.take_unwrap()); + let (crate, ast_map) = self.crate_and_map.take_unwrap(); + let crate = util::ready_crate(sess, crate); debug!("Building output filenames with script name {}", driver::source_name(&driver::file_input(self.input.clone()))); let exe = self.build_dir.join("pkg" + util::exe_suffix()); @@ -147,6 +148,7 @@ impl<'a> PkgScript<'a> { &self.build_dir, sess, crate, + ast_map, Main); // Discover the output // FIXME (#9639): This needs to handle non-utf8 paths diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 7e43fde7b32..bda84cc8baa 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -18,7 +18,7 @@ use std::io::fs; use extra::workcache; use rustc::driver::{driver, session}; use extra::getopts::groups::getopts; -use syntax::ast_util::*; +use syntax; use syntax::codemap::{DUMMY_SP, Spanned}; use syntax::ext::base::ExtCtxt; use syntax::{ast, attr, codemap, diagnostic, fold, visit}; @@ -283,8 +283,8 @@ pub fn compile_input(context: &BuildContext, // Infer dependencies that rustpkg needs to build, by scanning for // `extern mod` directives. let cfg = driver::build_configuration(sess); - let mut crate = driver::phase_1_parse_input(sess, cfg.clone(), &input); - crate = driver::phase_2_configure_and_expand(sess, cfg.clone(), crate); + let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input); + let (mut crate, ast_map) = driver::phase_2_configure_and_expand(sess, cfg.clone(), crate); debug!("About to call find_and_install_dependencies..."); @@ -323,6 +323,7 @@ pub fn compile_input(context: &BuildContext, &out_dir, sess, crate, + ast_map, what); // Discover the output let discovered_output = if what == Lib { @@ -359,6 +360,7 @@ pub fn compile_crate_from_input(input: &Path, // Returns None if one of the flags that suppresses compilation output was // given crate: ast::Crate, + ast_map: syntax::ast_map::map, what: OutputType) -> Option<Path> { debug!("Calling build_output_filenames with {}, building library? {:?}", out_dir.display(), sess.building_library); @@ -394,7 +396,7 @@ pub fn compile_crate_from_input(input: &Path, debug!("an additional library: {}", lib.display()); } } - let analysis = driver::phase_3_run_analysis_passes(sess, &crate); + let analysis = driver::phase_3_run_analysis_passes(sess, &crate, ast_map); if driver::stop_after_phase_3(sess) { return None; } let translation = driver::phase_4_translate_to_llvm(sess, crate, &analysis, |
