]> git.proxmox.com Git - rustc.git/blob - src/librustc_incremental/persist/util.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / librustc_incremental / persist / util.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use rustc::ty;
12 use std::fs;
13 use std::path::PathBuf;
14
15 pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
16 // For now, just save/load dep-graph from
17 // directory/dep_graph.rbml
18 tcx.sess.opts.incremental.as_ref().and_then(|incr_dir| {
19 match fs::create_dir_all(&incr_dir){
20 Ok(()) => {}
21 Err(err) => {
22 tcx.sess.err(
23 &format!("could not create the directory `{}`: {}",
24 incr_dir.display(), err));
25 return None;
26 }
27 }
28
29 Some(incr_dir.join("dep_graph.rbml"))
30 })
31 }
32