mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-12 14:07:42 +00:00
We can finally tell the users that they can uninstall `wl-copy` and `wl-paste` on their systems. Stash now somewhat supports being invoked under the names `stash-copy` and `stash-paste` to fully reimplement the functionality of `wl-copy` and `wl-paste` respectively. A build wrapper has been added generate symlinks for `stash-copy`, `stash-paste`, `wl-copy`, and `wl-paste`. `wl-copy` and `wl-paste` links are provided only for backwards compatibility, but they will not go away anytime soon. Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a6964463b35427cb720fbab68b252944cc90c
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
use std::{env, fs, path::Path};
|
|
|
|
/// List of multicall symlinks to create (name, target)
|
|
const MULTICALL_LINKS: &[&str] =
|
|
&["stash-copy", "stash-paste", "wl-copy", "wl-paste"];
|
|
|
|
fn main() {
|
|
// Only run on Unix-like systems
|
|
#[cfg(not(unix))]
|
|
{
|
|
println!(
|
|
"cargo:warning=Multicall symlinks are only supported on Unix-like \
|
|
systems."
|
|
);
|
|
return;
|
|
}
|
|
|
|
// OUT_DIR is something like .../target/debug/build/<pkg>/out
|
|
// We want .../target/debug or .../target/release
|
|
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
|
|
let bin_dir = Path::new(&out_dir)
|
|
.ancestors()
|
|
.nth(3)
|
|
.expect("Failed to find binary dir");
|
|
|
|
// Path to the main stash binary
|
|
let stash_bin = bin_dir.join("stash");
|
|
|
|
// Create symlinks for each multicall binary
|
|
for link in MULTICALL_LINKS {
|
|
let link_path = bin_dir.join(link);
|
|
// Remove existing symlink or file if present
|
|
let _ = fs::remove_file(&link_path);
|
|
#[cfg(unix)]
|
|
{
|
|
use std::os::unix::fs::symlink;
|
|
match symlink(&stash_bin, &link_path) {
|
|
Ok(()) => {
|
|
println!(
|
|
"cargo:warning=Created symlink: {} -> {}",
|
|
link_path.display(),
|
|
stash_bin.display()
|
|
);
|
|
},
|
|
Err(e) => {
|
|
println!(
|
|
"cargo:warning=Failed to create symlink {} -> {}: {}",
|
|
link_path.display(),
|
|
stash_bin.display(),
|
|
e
|
|
);
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|