about summary refs log tree commit diff
path: root/src/bootstrap/lib.rs
diff options
context:
space:
mode:
authorJoshua Nelson <jnelson@cloudflare.com>2022-03-21 08:59:34 -0500
committerJoshua Nelson <jnelson@cloudflare.com>2022-04-24 19:40:13 -0500
commit93c1a941bb49369ddf7237253a034d98f2c4382a (patch)
tree5a27498c4e0b1b0e7e3ef5f1ed310d0dd1bd846f /src/bootstrap/lib.rs
parentde1bc0008be096cf7ed67b93402250d3b3e480d0 (diff)
downloadrust-93c1a941bb49369ddf7237253a034d98f2c4382a.tar.gz
rust-93c1a941bb49369ddf7237253a034d98f2c4382a.zip
Move download-ci-llvm to rustbuild
This attempts to keep the logic as close to the original python as possible.
`probably_large` has been removed, since it was always `True`, and UTF-8 paths are no longer supported when patching files for NixOS.
I can readd UTF-8 support if desired.

Note that this required making `llvm_link_shared` computed on-demand,
since we don't know whether it will be static or dynamic until we download LLVM from CI.
Diffstat (limited to 'src/bootstrap/lib.rs')
-rw-r--r--src/bootstrap/lib.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 59102ad9f50..11be33ed4f0 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1391,6 +1391,23 @@ impl Build {
         paths
     }
 
+    pub fn rename(&self, src: &Path, dst: &Path) {
+        if self.config.dry_run {
+            return;
+        }
+        self.verbose_than(1, &format!("Move {:?} to {:?}", src, dst));
+        if src == dst {
+            return;
+        }
+        if let Err(e) = fs::rename(src, dst) {
+            if e.raw_os_error() == Some(libc::EXDEV) {
+                self.copy(src, dst);
+                return;
+            }
+            panic!("failed to rename `{}` to `{}`: {}", src.display(), dst.display(), e);
+        }
+    }
+
     /// Copies a file from `src` to `dst`
     pub fn copy(&self, src: &Path, dst: &Path) {
         if self.config.dry_run {