Fix x86-64 check

This commit is contained in:
William Venner 2021-12-04 19:22:52 +00:00
parent efeb394826
commit f853b67688
1 changed files with 23 additions and 14 deletions

View File

@ -49,14 +49,22 @@ pub fn is_x86_64() -> bool {
static ref IS_X86_64: bool = {
use std::path::PathBuf;
// Check LuaJIT version
unsafe {
let (lib, _) = lua::LuaShared::find_lua_shared();
if lib.get::<()>(b"luaJIT_version_2_0_4\0").is_ok() {
false
} else if lib.get::<()>(b"luaJIT_version_2_1_0_beta3\0").is_ok() {
true
} else {
#[cfg(target_os = "windows")] {
PathBuf::from("srcds_win64.exe").is_file()
}
#[cfg(target_os = "linux")] {
// Check executable name
match std::env::current_exe().expect("Failed to get executable path").file_name().expect("Failed to get executable file name").to_string_lossy().as_ref() {
#[cfg(target_os = "windows")]
"srcds.exe" => false,
#[cfg(target_os = "linux")]
"srcds_linux" => false,
#[cfg(target_os = "linux")]
"srcds" => true,
_ => {
// Check bin folder
#[cfg(target_os = "linux")] {
PathBuf::from("bin/linux64").is_dir()
@ -66,6 +74,7 @@ pub fn is_x86_64() -> bool {
}
}
}
}
};
}
*IS_X86_64