fix: use build-time AHFAIL_INSTALL_DIR on macOS, not hardcoded /usr/local/lib
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
Apple Silicon Homebrew uses /opt/homebrew as prefix, so hardcoding /usr/local/lib/ahfail/ahfail-display as DEFAULT_PATH breaks there. build.rs now falls back to /usr/local/lib on macOS and /usr/lib on Linux when AHFAIL_LIBDIR is not set; macOS uses the same concat!(env!(...)) approach as Linux. install-macos.sh passes -Dlibdir so the baked-in path matches INSTALL_DIR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
fn main() {
|
||||
println!("cargo:rustc-link-lib=pam");
|
||||
|
||||
// Emit AHFAIL_INSTALL_DIR so DEFAULT_PATH in lib.rs is correct on multiarch
|
||||
// systems (e.g. Debian/Ubuntu where libdir is /usr/lib/x86_64-linux-gnu).
|
||||
// Meson passes AHFAIL_LIBDIR=<libdir> when building; fall back to /usr/lib otherwise.
|
||||
let libdir = std::env::var("AHFAIL_LIBDIR").unwrap_or_else(|_| "/usr/lib".to_string());
|
||||
// Emit AHFAIL_INSTALL_DIR so DEFAULT_PATH in lib.rs is correct on multiarch Linux
|
||||
// (e.g. /usr/lib/x86_64-linux-gnu) and on Apple Silicon macOS (/opt/homebrew/lib).
|
||||
// Meson passes AHFAIL_LIBDIR=<libdir> when building; fall back per platform otherwise.
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
let fallback = if target_os == "macos" { "/usr/local/lib" } else { "/usr/lib" };
|
||||
let libdir = std::env::var("AHFAIL_LIBDIR").unwrap_or_else(|_| fallback.to_string());
|
||||
println!("cargo:rustc-env=AHFAIL_INSTALL_DIR={}/ahfail", libdir);
|
||||
}
|
||||
|
||||
@@ -20,12 +20,9 @@ pub const PAM_DATA_REPLACE: c_int = 0x00000002;
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
pub const PAM_DATA_REPLACE: c_int = 0x20000000u32 as i32;
|
||||
|
||||
// Default install path for ahfail-display.
|
||||
// On Linux: built from AHFAIL_INSTALL_DIR emitted by build.rs, which reads AHFAIL_LIBDIR
|
||||
// passed by Meson — correct on multiarch systems (e.g. /usr/lib/x86_64-linux-gnu/ahfail).
|
||||
#[cfg(target_os = "macos")]
|
||||
const DEFAULT_PATH: &str = "/usr/local/lib/ahfail/ahfail-display";
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
// Default install path for ahfail-display — baked in at build time via AHFAIL_INSTALL_DIR,
|
||||
// which build.rs derives from AHFAIL_LIBDIR (passed by Meson or the install script).
|
||||
// This is correct on multiarch Linux and on both Intel and Apple Silicon macOS.
|
||||
const DEFAULT_PATH: &str = concat!(env!("AHFAIL_INSTALL_DIR"), "/ahfail-display");
|
||||
|
||||
pub fn default_display_path() -> &'static str { DEFAULT_PATH }
|
||||
|
||||
@@ -34,10 +34,11 @@ PROJECT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
step "Building ahfail..."
|
||||
MESON_FLAGS=("--buildtype=release" "-Dlibdir=${INSTALL_DIR%/ahfail}")
|
||||
if [[ -d builddir ]]; then
|
||||
meson setup builddir --wipe
|
||||
meson setup builddir "${MESON_FLAGS[@]}" --wipe
|
||||
else
|
||||
meson setup builddir
|
||||
meson setup builddir "${MESON_FLAGS[@]}"
|
||||
fi
|
||||
meson compile -C builddir
|
||||
|
||||
|
||||
Reference in New Issue
Block a user