mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-12 22:17:41 +00:00
meta: allow disabling symlinks in build script via env vars
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I07f5d565d26ca527d413edf69857539e6a6a6964
This commit is contained in:
parent
d367728b39
commit
2e3c73957a
1 changed files with 19 additions and 0 deletions
19
build.rs
19
build.rs
|
|
@ -4,6 +4,9 @@ use std::{env, fs, path::Path};
|
||||||
const MULTICALL_LINKS: &[&str] =
|
const MULTICALL_LINKS: &[&str] =
|
||||||
&["stash-copy", "stash-paste", "wl-copy", "wl-paste"];
|
&["stash-copy", "stash-paste", "wl-copy", "wl-paste"];
|
||||||
|
|
||||||
|
/// Wayland-specific symlinks that can be disabled separately
|
||||||
|
const WAYLAND_LINKS: &[&str] = &["wl-copy", "wl-paste"];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// OUT_DIR is something like .../target/debug/build/<pkg>/out
|
// OUT_DIR is something like .../target/debug/build/<pkg>/out
|
||||||
// We want .../target/debug or .../target/release
|
// We want .../target/debug or .../target/release
|
||||||
|
|
@ -16,8 +19,24 @@ fn main() {
|
||||||
// Path to the main stash binary
|
// Path to the main stash binary
|
||||||
let stash_bin = bin_dir.join("stash");
|
let stash_bin = bin_dir.join("stash");
|
||||||
|
|
||||||
|
// Check for environment variables to disable symlinking
|
||||||
|
let disable_all_symlinks = env::var("STASH_NO_SYMLINKS").is_ok();
|
||||||
|
let disable_wayland_symlinks = env::var("STASH_NO_WL_SYMLINKS").is_ok();
|
||||||
|
|
||||||
// Create symlinks for each multicall binary
|
// Create symlinks for each multicall binary
|
||||||
for link in MULTICALL_LINKS {
|
for link in MULTICALL_LINKS {
|
||||||
|
if disable_all_symlinks {
|
||||||
|
println!("cargo:warning=Skipping symlink {link} (all symlinks disabled)");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if disable_wayland_symlinks && WAYLAND_LINKS.contains(link) {
|
||||||
|
println!(
|
||||||
|
"cargo:warning=Skipping symlink {link} (wayland symlinks disabled)"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let link_path = bin_dir.join(link);
|
let link_path = bin_dir.join(link);
|
||||||
// Remove existing symlink or file if present
|
// Remove existing symlink or file if present
|
||||||
let _ = fs::remove_file(&link_path);
|
let _ = fs::remove_file(&link_path);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue