rust: Cache bootstrap downloads to $(DL_DIR)/rustc
[feed/packages.git] / lang / rust / patches / 0002-rustc-bootstrap-cache.patch
1 --- a/src/bootstrap/bootstrap.py
2 +++ b/src/bootstrap/bootstrap.py
3 @@ -543,7 +543,7 @@ class RustBuild(object):
4 shutil.rmtree(bin_root)
5
6 key = self.stage0_compiler.date
7 - cache_dst = os.path.join(self.build_dir, "cache")
8 + cache_dst = os.getenv('OPENWRT_RUSTC_BOOTSTRAP_CACHE', os.path.join(self.build_dir, "cache"))
9 rustc_cache = os.path.join(cache_dst, key)
10 if not os.path.exists(rustc_cache):
11 os.makedirs(rustc_cache)
12 --- a/src/bootstrap/download.rs
13 +++ b/src/bootstrap/download.rs
14 @@ -507,7 +507,10 @@ impl Config {
15 key: &str,
16 destination: &str,
17 ) {
18 - let cache_dst = self.out.join("cache");
19 + let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
20 + Some(v) => PathBuf::from(v),
21 + None => self.out.join("cache"),
22 + };
23 let cache_dir = cache_dst.join(key);
24 if !cache_dir.exists() {
25 t!(fs::create_dir_all(&cache_dir));
26 @@ -627,7 +630,10 @@ download-rustc = false
27 let llvm_assertions = self.llvm_assertions;
28
29 let cache_prefix = format!("llvm-{}-{}", llvm_sha, llvm_assertions);
30 - let cache_dst = self.out.join("cache");
31 + let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
32 + Some(v) => PathBuf::from(v),
33 + None => self.out.join("cache"),
34 + };
35 let rustc_cache = cache_dst.join(cache_prefix);
36 if !rustc_cache.exists() {
37 t!(fs::create_dir_all(&rustc_cache));