about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-05-28 13:57:09 -0400
committerOneirical <manchot@videotron.ca>2024-06-12 09:44:21 -0400
commit2ac5faa509e9511665986a5ac25ed7c4e427aac2 (patch)
tree6dd9293eb42544d65c277d9ba419b68e7d701be1 /src
parent59acd234575b0283a6e00ec2e9d8be5f1b2f782d (diff)
downloadrust-2ac5faa509e9511665986a5ac25ed7c4e427aac2.tar.gz
rust-2ac5faa509e9511665986a5ac25ed7c4e427aac2.zip
port symlinked-libraries to rmake
Diffstat (limited to 'src')
-rw-r--r--src/tools/run-make-support/src/lib.rs41
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
2 files changed, 25 insertions, 17 deletions
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index d93a950d3e1..9ec20bf8fd4 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -94,14 +94,31 @@ pub fn source_root() -> PathBuf {
 }
 
 /// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
+#[cfg(target_family = "windows")]
 pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
-    if is_windows() {
-        use std::os::windows::fs;
-        fs::symlink_file(original, link).unwrap();
-    } else {
-        use std::os::unix::fs;
-        fs::symlink(original, link).unwrap();
+    if link.as_ref().exists() {
+        std::fs::remove_dir(link.as_ref()).unwrap();
+    }
+    use std::os::windows::fs;
+    fs::symlink_file(original.as_ref(), link.as_ref()).expect(&format!(
+        "failed to create symlink {:?} for {:?}",
+        link.as_ref().display(),
+        original.as_ref().display(),
+    ));
+}
+
+/// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
+#[cfg(target_family = "unix")]
+pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
+    if link.as_ref().exists() {
+        std::fs::remove_dir(link.as_ref()).unwrap();
     }
+    use std::os::unix::fs;
+    fs::symlink(original.as_ref(), link.as_ref()).expect(&format!(
+        "failed to create symlink {:?} for {:?}",
+        link.as_ref().display(),
+        original.as_ref().display(),
+    ));
 }
 
 /// Construct the static library name based on the platform.
@@ -125,11 +142,7 @@ pub fn static_lib_name(name: &str) -> String {
     // ```
     assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace");
 
-    if is_msvc() {
-        format!("{name}.lib")
-    } else {
-        format!("lib{name}.a")
-    }
+    if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
 }
 
 /// Construct the dynamic library name based on the platform.
@@ -176,11 +189,7 @@ pub fn rust_lib_name(name: &str) -> String {
 
 /// Construct the binary name based on platform.
 pub fn bin_name(name: &str) -> String {
-    if is_windows() {
-        format!("{name}.exe")
-    } else {
-        name.to_string()
-    }
+    if is_windows() { format!("{name}.exe") } else { name.to_string() }
 }
 
 /// Return the current working directory.
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index dc1310afde9..33918473197 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -228,7 +228,6 @@ run-make/std-core-cycle/Makefile
 run-make/symbol-mangling-hashed/Makefile
 run-make/symbol-visibility/Makefile
 run-make/symbols-include-type-name/Makefile
-run-make/symlinked-libraries/Makefile
 run-make/sysroot-crates-are-unstable/Makefile
 run-make/target-cpu-native/Makefile
 run-make/target-specs/Makefile