diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-06-12 20:03:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 20:03:18 -0700 |
| commit | 1a6b1a14f9825879f7a9606ccbb5982cdcc46d1e (patch) | |
| tree | cb5a8a9f2476dc6bfa0e4558809b59233b583b84 /src | |
| parent | 8cf5101d77cd9eeb12751c563d8098aba2c604d0 (diff) | |
| parent | 2ac5faa509e9511665986a5ac25ed7c4e427aac2 (diff) | |
| download | rust-1a6b1a14f9825879f7a9606ccbb5982cdcc46d1e.tar.gz rust-1a6b1a14f9825879f7a9606ccbb5982cdcc46d1e.zip | |
Rollup merge of #125674 - Oneirical:another-day-another-test, r=jieyouxu
Rewrite `symlinked-extern`, `symlinked-rlib` and `symlinked-libraries` `run-make` tests in `rmake.rs` format Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). try-job: x86_64-msvc
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/run-make-support/src/lib.rs | 28 | ||||
| -rw-r--r-- | src/tools/tidy/src/allowed_run_make_makefiles.txt | 3 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index b920f9a07db..9ec20bf8fd4 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -93,6 +93,34 @@ pub fn source_root() -> PathBuf { env_var("SOURCE_ROOT").into() } +/// 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 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. pub fn static_lib_name(name: &str) -> String { // See tools.mk (irrelevant lines omitted): diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 87185eef952..a4d19eee980 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -227,9 +227,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-extern/Makefile -run-make/symlinked-libraries/Makefile -run-make/symlinked-rlib/Makefile run-make/sysroot-crates-are-unstable/Makefile run-make/target-cpu-native/Makefile run-make/target-specs/Makefile |
