diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0090fb0..ef8b859 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,13 +16,11 @@ jobs: fail-fast: false matrix: variants: - # - {os: ubuntu-22.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64} - - {os: ubuntu-24.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64} - # - {os: ubuntu-24.04-arm, config: release, compiler: linux_gcc_arm64, aqt_os: linux_arm64, aqt_compiler: linux_gcc_arm64} - # - {os: windows-2022, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64} - - {os: windows-2025, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64} - - {os: macos-14, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64} - # - {os: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64} + - {os: ubuntu-24.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64} + - {os: ubuntu-24.04-arm, config: release, compiler: gcc_arm64, aqt_os: linux_arm64, aqt_compiler: gcc_arm64} + - {os: windows-2025, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64} + # - {os: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64} + # - {os: macos-14, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64} runs-on: ${{ matrix.variants.os }} steps: - uses: actions/checkout@v5 diff --git a/build.rs b/build.rs index facd36d..ef07124 100644 --- a/build.rs +++ b/build.rs @@ -26,7 +26,13 @@ fn get_qt_libs_path() -> String { return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/macos/lib"); #[cfg(target_os = "linux")] - return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_64/lib"); + { + #[cfg(target_arch = "aarch64")] + return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_arm64/lib"); + + #[cfg(target_arch = "x86_64")] + return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_64/lib"); + } } fn qt_download() { @@ -51,9 +57,15 @@ fn qt_download() { .args(["-m", "aqt", "install-qt", "-O", LIBDIE_BUILD_DIR]); #[cfg(target_os = "linux")] - cmd.args(["linux", "desktop", QT_VERSION]); + { + #[cfg(target_arch = "x86_64")] + cmd.args(["linux", "desktop", QT_VERSION]); + + #[cfg(target_arch = "aarch64")] + cmd.args(["linux_arm64", "desktop", QT_VERSION, "linux_gcc_arm64"]); + } #[cfg(target_os = "macos")] - cmd.args(["mac", "desktop", QT_VERSION, "clang_64"]); + cmd.args(["mac", "desktop", QT_VERSION]); #[cfg(target_os = "windows")] cmd.args(["windows", "desktop", QT_VERSION, "win64_msvc2022_64"]); diff --git a/libdie++/cmake/FindDieLibrary.cmake b/libdie++/cmake/FindDieLibrary.cmake index ba92698..de88095 100644 --- a/libdie++/cmake/FindDieLibrary.cmake +++ b/libdie++/cmake/FindDieLibrary.cmake @@ -6,7 +6,11 @@ set(QT_BUILD_VERSION "6.10.0") if(WIN32) set(QT_BUILD_COMPILER "msvc2022_64") elseif(LINUX) - set(QT_BUILD_COMPILER "gcc_64") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64") + set(QT_BUILD_COMPILER "gcc_arm64") + else() + set(QT_BUILD_COMPILER "gcc_64") + endif() elseif(APPLE) set(QT_BUILD_COMPILER "macos") else() diff --git a/src/lib.rs b/src/lib.rs index e6fbefb..b20ee53 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,12 +46,12 @@ bitflags! { #[link(name = "die", kind = "static")] unsafe extern "C" { // Definitions from die.h - fn DIE_FreeMemoryA(str: *const i8); - fn DIE_ScanFileA(fname: *const i8, flags: u32, db: *const i8) -> *const i8; - fn DIE_ScanFileExA(fname: *const i8, flags: u32) -> *mut i8; - fn DIE_ScanMemoryA(mem: *const u8, len: u32, flags: u32, db: *const i8) -> *mut i8; - fn DIE_ScanMemoryExA(mem: *const u8, len: u32, flags: u32) -> *mut i8; - fn DIE_LoadDatabaseA(fname: *const i8) -> i32; + fn DIE_FreeMemoryA(str: *const u8); + fn DIE_ScanFileA(fname: *const u8, flags: u32, db: *const u8) -> *const u8; + fn DIE_ScanFileExA(fname: *const u8, flags: u32) -> *const u8; + fn DIE_ScanMemoryA(mem: *const u8, len: u32, flags: u32, db: *const u8) -> *const u8; + fn DIE_ScanMemoryExA(mem: *const u8, len: u32, flags: u32) -> *const u8; + fn DIE_LoadDatabaseA(fname: *const u8) -> i32; } /// Scans a file at the specified path using the provided scan flags. @@ -89,8 +89,10 @@ pub fn scan_file(fpath: &Path, flags: ScanFlags) -> Result { let fpath = CString::new(fpath.to_str().ok_or(Error::ConversionFailure)?)?; unsafe { - let res = DIE_ScanFileExA(fpath.as_ptr(), flags.bits()); - let out = CStr::from_ptr(res).to_str()?.to_string(); + let res = DIE_ScanFileExA(fpath.as_bytes_with_nul().as_ptr(), flags.bits()); + let out = CStr::from_ptr(res as *const std::os::raw::c_char) + .to_str()? + .to_string(); DIE_FreeMemoryA(res); Ok(out) } @@ -133,9 +135,15 @@ pub fn scan_file_with_db(fpath: &Path, flags: ScanFlags, db_path: &Path) -> Resu let db_path = CString::new(db_path.to_str().ok_or(Error::ConversionFailure)?)?; unsafe { - let cstr = CStr::from_ptr(fpath.as_ptr() as *const i8); - let res = DIE_ScanFileA(cstr.as_ptr(), flags.bits(), db_path.as_ptr()); - let str = CStr::from_ptr(res).to_str()?.to_string(); + let cstr = CStr::from_ptr(fpath.as_ptr()); + let res = DIE_ScanFileA( + cstr.to_bytes_with_nul().as_ptr(), + flags.bits(), + db_path.to_bytes_with_nul().as_ptr(), + ); + let str = CStr::from_ptr(res as *const std::os::raw::c_char) + .to_str()? + .to_string(); DIE_FreeMemoryA(res); Ok(str) } @@ -178,7 +186,9 @@ pub fn scan_memory(mem: &[u8], flags: ScanFlags) -> Result { unsafe { let res = DIE_ScanMemoryExA(ptr, sz as u32, flags.bits()); - let str = CStr::from_ptr(res).to_str()?.to_string(); + let str = CStr::from_ptr(res as *const std::os::raw::c_char) + .to_str()? + .to_string(); DIE_FreeMemoryA(res); Ok(str) } @@ -224,8 +234,15 @@ pub fn scan_memory_with_db(mem: &[u8], flags: ScanFlags, db_path: &Path) -> Resu } unsafe { - let res = DIE_ScanMemoryA(ptr, sz as u32, flags.bits(), db_path.as_ptr()); - let str = CStr::from_ptr(res).to_str()?.to_string(); + let res = DIE_ScanMemoryA( + ptr, + sz as u32, + flags.bits(), + db_path.as_bytes_with_nul().as_ptr(), + ); + let str = CStr::from_ptr(res as *const std::os::raw::c_char) + .to_str()? + .to_string(); DIE_FreeMemoryA(res); Ok(str) } @@ -263,7 +280,7 @@ pub fn scan_memory_with_db(mem: &[u8], flags: ScanFlags, db_path: &Path) -> Resu pub fn load_database(fpath: &Path) -> Result<()> { let fpath = CString::new(fpath.to_str().ok_or(Error::ConversionFailure)?)?; - let res = unsafe { DIE_LoadDatabaseA(fpath.as_ptr()) }; + let res = unsafe { DIE_LoadDatabaseA(fpath.as_bytes_with_nul().as_ptr()) }; match res { 0 => Ok(()), err => Err(Error::Ffi { error_code: err }),