Skip to content

Commit 488da69

Browse files
committed
bootstrap.py: Create cache before download
This make `_download_component_helper` "pure".
1 parent e6e956d commit 488da69

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/bootstrap/bootstrap.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,24 @@ def download_toolchain(self):
429429
self.program_out_of_date(self.rustc_stamp(), key)):
430430
if os.path.exists(bin_root):
431431
shutil.rmtree(bin_root)
432+
433+
key = self.stage0_compiler.date
434+
cache_dst = os.path.join(self.build_dir, "cache")
435+
rustc_cache = os.path.join(cache_dst, key)
436+
if not os.path.exists(rustc_cache):
437+
os.makedirs(rustc_cache)
438+
432439
tarball_suffix = '.tar.gz' if lzma is None else '.tar.xz'
433440
filename = "rust-std-{}-{}{}".format(
434441
rustc_channel, self.build, tarball_suffix)
435442
pattern = "rust-std-{}".format(self.build)
436-
self._download_component_helper(filename, pattern, tarball_suffix)
443+
self._download_component_helper(filename, pattern, tarball_suffix, rustc_cache)
437444
filename = "rustc-{}-{}{}".format(rustc_channel, self.build,
438445
tarball_suffix)
439-
self._download_component_helper(filename, "rustc", tarball_suffix)
446+
self._download_component_helper(filename, "rustc", tarball_suffix, rustc_cache)
440447
filename = "cargo-{}-{}{}".format(rustc_channel, self.build,
441448
tarball_suffix)
442-
self._download_component_helper(filename, "cargo", tarball_suffix)
449+
self._download_component_helper(filename, "cargo", tarball_suffix, rustc_cache)
443450
if self.should_fix_bins_and_dylibs():
444451
self.fix_bin_or_dylib("{}/bin/cargo".format(bin_root))
445452

@@ -455,13 +462,9 @@ def download_toolchain(self):
455462
rust_stamp.write(key)
456463

457464
def _download_component_helper(
458-
self, filename, pattern, tarball_suffix,
465+
self, filename, pattern, tarball_suffix, rustc_cache,
459466
):
460467
key = self.stage0_compiler.date
461-
cache_dst = os.path.join(self.build_dir, "cache")
462-
rustc_cache = os.path.join(cache_dst, key)
463-
if not os.path.exists(rustc_cache):
464-
os.makedirs(rustc_cache)
465468

466469
tarball = os.path.join(rustc_cache, filename)
467470
if not os.path.exists(tarball):

0 commit comments

Comments
 (0)