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