make the filename computation take a cratenum
This commit is contained in:
parent
f89041bbe3
commit
c7840cfe14
2 changed files with 10 additions and 8 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
use rbml::opaque::Encoder;
|
||||
use rustc::dep_graph::DepNode;
|
||||
use rustc::middle::cstore::LOCAL_CRATE;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_serialize::{Encodable as RustcEncodable};
|
||||
use std::hash::{Hasher, SipHasher};
|
||||
|
@ -25,7 +26,7 @@ pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
|||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
|
||||
save_in(tcx, dep_graph_path(tcx), encode_dep_graph);
|
||||
save_in(tcx, metadata_hash_path(tcx), encode_metadata_hashes);
|
||||
save_in(tcx, metadata_hash_path(tcx, LOCAL_CRATE), encode_metadata_hashes);
|
||||
}
|
||||
|
||||
fn save_in<'a,'tcx,F>(tcx: TyCtxt<'a, 'tcx, 'tcx>, opt_path_buf: Option<PathBuf>, encode: F)
|
||||
|
|
|
@ -16,17 +16,18 @@ use rustc::ty::TyCtxt;
|
|||
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::{PathBuf, Path};
|
||||
use std::path::{Path, PathBuf};
|
||||
use syntax::ast;
|
||||
|
||||
pub fn dep_graph_path(tcx: TyCtxt) -> Option<PathBuf> {
|
||||
path(tcx, "local")
|
||||
path(tcx, LOCAL_CRATE, "local")
|
||||
}
|
||||
|
||||
pub fn metadata_hash_path(tcx: TyCtxt) -> Option<PathBuf> {
|
||||
path(tcx, "metadata")
|
||||
pub fn metadata_hash_path(tcx: TyCtxt, cnum: ast::CrateNum) -> Option<PathBuf> {
|
||||
path(tcx, cnum, "metadata")
|
||||
}
|
||||
|
||||
fn path(tcx: TyCtxt, suffix: &str) -> Option<PathBuf> {
|
||||
fn path(tcx: TyCtxt, cnum: ast::CrateNum, suffix: &str) -> Option<PathBuf> {
|
||||
// For now, just save/load dep-graph from
|
||||
// directory/dep_graph.rbml
|
||||
tcx.sess.opts.incremental.as_ref().and_then(|incr_dir| {
|
||||
|
@ -40,8 +41,8 @@ fn path(tcx: TyCtxt, suffix: &str) -> Option<PathBuf> {
|
|||
}
|
||||
}
|
||||
|
||||
let crate_name = tcx.crate_name(LOCAL_CRATE);
|
||||
let crate_disambiguator = tcx.crate_disambiguator(LOCAL_CRATE);
|
||||
let crate_name = tcx.crate_name(cnum);
|
||||
let crate_disambiguator = tcx.crate_disambiguator(cnum);
|
||||
let file_name = format!("{}-{}.{}.bin",
|
||||
crate_name,
|
||||
crate_disambiguator,
|
||||
|
|
Loading…
Add table
Reference in a new issue