From a8a76ba19a11f1f8e610be8ed3630f922a64f10a Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Wed, 5 Nov 2025 17:28:26 -0800 Subject: [PATCH 01/15] update to qt 6.10.0 , update msvc 2019 -> 2022 unified build process for publication --- .github/workflows/build.yml | 4 +- Cargo.lock | 10 +- Cargo.toml | 6 +- README.md | 14 +-- build.rs | 189 ++++++++++++++++++++-------- libdie++/cmake/FindDieLibrary.cmake | 4 +- 6 files changed, 155 insertions(+), 72 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 35eb985..b09b5a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: env: CARGO_TERM_COLOR: always - QT_BUILD_VERSION: 6.2.2 + QT_BUILD_VERSION: 6.10.0 jobs: @@ -19,7 +19,7 @@ jobs: variants: - {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-2019, config: release, compiler: msvc2019_64, aqt_os: windows, aqt_compiler: win64_msvc2019_64} + - {os: windows-2019, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64} - {os: macos-13, 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} - {os: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64} diff --git a/Cargo.lock b/Cargo.lock index 188c353..06c1ab3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,18 +114,18 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "derive_more" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "die" -version = "0.1.0" +version = "0.2.0" dependencies = [ "bitflags", "clap", diff --git a/Cargo.toml b/Cargo.toml index 70cec87..1914c50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "die" -version = "0.1.0" -edition = "2021" +version = "0.2.0" +edition = "2024" authors = ["Christophe Alladoum"] description = "Native Rust bindings for @horsicq's Detect-It-Easy" homepage = "https://github.com/elastic/die-rust" @@ -21,7 +21,7 @@ name = "scan_file" [dependencies] bitflags = "2.6.0" -derive_more = { version = "1.0.0", features = ["from", "display"] } +derive_more = { version = "2.0.1", features = ["from", "display"] } [dev-dependencies] clap = { version = "4.5.23", features = ["derive"] } diff --git a/README.md b/README.md index f52cfd0..61eea81 100644 --- a/README.md +++ b/README.md @@ -40,31 +40,31 @@ The build requires Qt6 libraries. On Linux/macOS they can usually be obtained fr ### Linux ```bash -export QT_BUILD_VERSION=6.2.2 +export QT_BUILD_VERSION=6.10.0 git clone https://github.com/elastic/die-rust.git && cd die-rust python -m pip install aqtinstall python -m aqt install-qt -O ./libdie++/build/ linux desktop ${QT_BUILD_VERSION} gcc_64 -export QT6_LIB_PATH=./libdie++/build/6.2.2/gcc_64/lib +export QT6_LIB_PATH=./libdie++/build/6.10.0/gcc_64/lib ``` ### macOS ```bash -export QT_BUILD_VERSION=6.2.2 +export QT_BUILD_VERSION=6.10.0 git clone https://github.com/calladoum-elastic/die-rust.git && cd die-rust python -m pip install aqtinstall python -m aqt install-qt -O ./libdie++/build/ mac desktop ${QT_BUILD_VERSION} clang_64 -export QT6_LIB_PATH=./libdie++/build/6.2.2/clang_64/lib # macos +export QT6_LIB_PATH=./libdie++/build/6.10.0/clang_64/lib # macos ``` ### Windows ```pwsh -$env:QT_BUILD_VERSION="6.2.2" +$env:QT_BUILD_VERSION="6.10.0" git clone https://github.com/calladoum-elastic/die-rust.git && cd die-rust python -m pip install aqtinstall -python -m aqt install-qt -O ./libdie++/build/ windows desktop $env:QT_BUILD_VERSION win64_msvc2019_64 -$env:QT6_LIB_PATH="./libdie++/build/6.2.2/msvc2019_64/lib" +python -m aqt install-qt -O ./libdie++/build/ windows desktop $env:QT_BUILD_VERSION win64_msvc2022_64 +$env:QT6_LIB_PATH="./libdie++/build/6.10.0/msvc2022_64/lib" ``` diff --git a/build.rs b/build.rs index 859304c..1cd6fe9 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,14 @@ +use std::env; + +#[allow(dead_code)] // build.rs // https://doc.rust-lang.org/cargo/reference/build-scripts.html -const BASE_DIR: &'static str = "./libdie++"; -#[allow(dead_code)] -const BUILD_DIR: &'static str = "./libdie++/build"; -const INSTALL_DIR: &'static str = "./libdie++/install"; +const QT_VERSION: &'static str = "6.10.0"; +const BASE_DIR: &'static str = "."; +const LIBDIE_BASE_DIR: &'static str = "./libdie++"; +const LIBDIE_BUILD_DIR: &'static str = "./libdie++/build"; +const LIBDIE_INSTALL_DIR: &'static str = "./libdie++/install"; const LIB_DIE_PATH: &'static str = "./libdie++/build/_deps/dielibrary-build/src"; #[cfg(target_os = "windows")] @@ -15,52 +19,118 @@ const BUILD_TYPE: &'static str = "Debug"; #[cfg(not(debug_assertions))] const BUILD_TYPE: &'static str = "Release"; +fn get_qt_libs_path() -> String { + #[cfg(target_os = "windows")] + return format!("./libdie++/build/{QT_VERSION}/msvc2022_64/lib"); + + #[cfg(target_os = "macos")] + return format!("./libdie++/build/{QT_VERSION}/clang_64/lib"); + + #[cfg(target_os = "linux")] + return format!("./libdie++/build/{QT_VERSION}/gcc_64/lib"); +} + +fn qt_download() { + // Install AQT + { + assert!( + std::process::Command::new("python") + .current_dir(BASE_DIR) + .args(["-m", "pip", "install", "--user", "--upgrade", "aqtinstall"]) + .spawn() + .unwrap() + .wait() + .expect("failed to install AQT") + .success() + ); + } + + // Install QT using AQT + { + let mut cmd = std::process::Command::new("python"); + cmd.current_dir(BASE_DIR) + .args(["-m", "aqt", "install-qt", "-O", LIBDIE_BUILD_DIR]); + + #[cfg(target_os = "linux")] + cmd.args(["linux", "desktop", QT_VERSION, "gcc_64"]); + #[cfg(target_os = "macos")] + cmd.args(["mac", "desktop", QT_VERSION, "clang_64"]); + #[cfg(target_os = "windows")] + cmd.args(["windows", "desktop", QT_VERSION, "win64_msvc2022_64"]); + + assert!( + cmd.spawn() + .unwrap() + .wait() + .expect(format!("failed to install Qt {QT_VERSION} using AQT").as_str()) + .success() + ); + } + + // Add to env var + { + let fpath = get_qt_libs_path(); + + println!("cargo:rustc-env=QT6_LIB_PATH=\"{fpath}\""); + unsafe { + env::set_var("QT6_LIB_PATH", fpath.as_str()); + env::set_var("Qt6_DIR", fpath.as_str()); + } + } +} + fn cmake_build_die() { // CMake configure { - assert!(std::process::Command::new("cmake") - .current_dir(BASE_DIR) - .args(["-S", "."]) - .args(["-B", "build"]) - .spawn() - .unwrap() - .wait() - .expect("failed to configure cmake") - .success()); + assert!( + std::process::Command::new("cmake") + .current_dir(LIBDIE_BASE_DIR) + .args(["-S", "."]) + .args(["-B", "build"]) + .spawn() + .unwrap() + .wait() + .expect("failed to configure cmake") + .success() + ); } // CMake build { let nb_cpu = "4"; - assert!(std::process::Command::new("cmake") - .args(["--build", "build"]) - .args(["-j", nb_cpu]) - .args(["--config", BUILD_TYPE]) - .current_dir(BASE_DIR) - .spawn() - .unwrap() - .wait() - .expect("failed to build with cmake") - .success()); + assert!( + std::process::Command::new("cmake") + .current_dir(LIBDIE_BASE_DIR) + .args(["--build", "build"]) + .args(["-j", nb_cpu]) + .args(["--config", BUILD_TYPE]) + .spawn() + .unwrap() + .wait() + .expect("failed to build with cmake") + .success() + ); } // CMake install { - assert!(std::process::Command::new("cmake") - .args(["--install", "build"]) - .args(["--config", BUILD_TYPE]) - .args(["--prefix", "install"]) - .current_dir(BASE_DIR) - .spawn() - .unwrap() - .wait() - .expect("failed to install with cmake") - .success()); + assert!( + std::process::Command::new("cmake") + .current_dir(LIBDIE_BASE_DIR) + .args(["--install", "build"]) + .args(["--config", BUILD_TYPE]) + .args(["--prefix", "install"]) + .spawn() + .unwrap() + .wait() + .expect("failed to install with cmake") + .success() + ); } } -fn install_common() { +fn setup_common() { // die & die++ println!("cargo:rustc-link-lib=static=die++"); println!("cargo:rustc-link-lib=static=die"); @@ -89,7 +159,7 @@ fn install_common() { } #[cfg(target_os = "linux")] -fn install_linux() { +fn install() { println!("cargo:rustc-link-search=native={}/die", INSTALL_DIR); println!("cargo:rustc-link-search=native={}/die/lib", INSTALL_DIR); println!("cargo:rustc-link-lib=dylib=stdc++"); @@ -108,7 +178,7 @@ fn install_linux() { } #[cfg(target_os = "macos")] -fn install_macos() { +fn install() { println!("cargo:rustc-link-search=native={}/die", INSTALL_DIR); println!("cargo:rustc-link-search=native={}/die/lib", INSTALL_DIR); println!("cargo:rustc-link-lib=dylib=c++"); @@ -132,15 +202,18 @@ fn install_macos() { } #[cfg(target_os = "windows")] -fn install_windows() { - println!("cargo:rustc-link-search=native={}/die/dielib", INSTALL_DIR); +fn install() { + println!( + "cargo:rustc-link-search=native={}/die/dielib", + LIBDIE_INSTALL_DIR + ); println!( "cargo:rustc-link-search=native={}/{}", - BUILD_DIR, BUILD_TYPE + LIBDIE_BUILD_DIR, BUILD_TYPE ); println!( "cargo:rustc-link-search=native={}/_deps/dielibrary-build/src/dielib/{}", - BUILD_DIR, BUILD_TYPE + LIBDIE_BUILD_DIR, BUILD_TYPE ); for _mod in ["bzip2", "lzma", "zlib"].iter() { println!( @@ -168,23 +241,33 @@ fn install_windows() { } } +fn is_qt_missing() -> bool { + std::path::Path::new(get_qt_libs_path().as_str()).exists() == false +} + +fn should_rebuild_libdie() -> bool { + let mut fpath = std::path::PathBuf::from(LIBDIE_INSTALL_DIR); + + #[cfg(target_os = "windows")] + fpath.push("die.lib"); + + fpath.exists() == false +} + fn main() { - cmake_build_die(); + #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))] + unimplemented!(); - install_common(); + if is_qt_missing() { + qt_download(); + } - if cfg!(target_os = "linux") { - #[cfg(target_os = "linux")] - install_linux(); - } else if cfg!(target_os = "macos") { - #[cfg(target_os = "macos")] - install_macos(); - } else if cfg!(target_os = "windows") { - #[cfg(target_os = "windows")] - install_windows(); - } else { - unimplemented!(); + if should_rebuild_libdie() { + cmake_build_die(); } + setup_common(); + install(); + println!("cargo:rerun-if-changed=src/lib.rs"); } diff --git a/libdie++/cmake/FindDieLibrary.cmake b/libdie++/cmake/FindDieLibrary.cmake index 69cb6af..33141d6 100644 --- a/libdie++/cmake/FindDieLibrary.cmake +++ b/libdie++/cmake/FindDieLibrary.cmake @@ -1,10 +1,10 @@ include(FetchContent) set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/..") -set(QT_BUILD_VERSION "6.2.2") +set(QT_BUILD_VERSION "6.10.0") if(WIN32) - set(QT_BUILD_COMPILER "msvc2019_64") + set(QT_BUILD_COMPILER "msvc2022_64") elseif(LINUX) set(QT_BUILD_COMPILER "gcc_64") elseif(APPLE) From 06b3e07d5d2abbb611bb37e133ba548f4a0d4aca Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 07:49:35 -0800 Subject: [PATCH 02/15] update for ci --- .github/workflows/build.yml | 5 +++-- build.rs | 29 +++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b09b5a5..b481c32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,10 +17,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-2019, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64} - - {os: macos-13, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64} + - {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} runs-on: ${{ matrix.variants.os }} diff --git a/build.rs b/build.rs index 1cd6fe9..8f0bed6 100644 --- a/build.rs +++ b/build.rs @@ -160,8 +160,11 @@ fn setup_common() { #[cfg(target_os = "linux")] fn install() { - println!("cargo:rustc-link-search=native={}/die", INSTALL_DIR); - println!("cargo:rustc-link-search=native={}/die/lib", INSTALL_DIR); + println!("cargo:rustc-link-search=native={}/die", LIBDIE_INSTALL_DIR); + println!( + "cargo:rustc-link-search=native={}/die/lib", + LIBDIE_INSTALL_DIR + ); println!("cargo:rustc-link-lib=dylib=stdc++"); println!("cargo:rustc-link-lib=dylib=Qt6Core"); println!("cargo:rustc-link-lib=dylib=Qt6Qml"); @@ -179,8 +182,11 @@ fn install() { #[cfg(target_os = "macos")] fn install() { - println!("cargo:rustc-link-search=native={}/die", INSTALL_DIR); - println!("cargo:rustc-link-search=native={}/die/lib", INSTALL_DIR); + println!("cargo:rustc-link-search=native={}/die", LIBDIE_INSTALL_DIR); + println!( + "cargo:rustc-link-search=native={}/die/lib", + LIBDIE_INSTALL_DIR + ); println!("cargo:rustc-link-lib=dylib=c++"); if let Some(qt_lib_path) = option_env!("QT6_LIB_PATH") { @@ -249,9 +255,20 @@ fn should_rebuild_libdie() -> bool { let mut fpath = std::path::PathBuf::from(LIBDIE_INSTALL_DIR); #[cfg(target_os = "windows")] - fpath.push("die.lib"); + { + fpath.push("die.lib"); + fpath.exists() == false + } - fpath.exists() == false + #[cfg(target_os = "linux")] + { + true + } + + #[cfg(target_os = "macos")] + { + true + } } fn main() { From d1b57dd82a8a5ae43bd234f825a6dbebff14984d Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 08:52:34 -0800 Subject: [PATCH 03/15] fix cargo build --- .github/workflows/build.yml | 5 +++-- build.rs | 41 +++++++++++++++---------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b481c32..56f97ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,8 +25,10 @@ jobs: - {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} runs-on: ${{ matrix.variants.os }} + env: + QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/cache@v4 with: path: | @@ -58,7 +60,6 @@ jobs: echo QT6_LIB_PATH=${QT6_LIB_PATH} >> $GITHUB_ENV - name: Build (Windows) - if: startsWith(matrix.variants.os, 'windows-') run: | python -m pip install aqtinstall --user --upgrade python -m aqt install-qt -O libdie++/build ${{ matrix.variants.aqt_os }} desktop ${{ env.QT_BUILD_VERSION }} ${{ matrix.variants.aqt_compiler }} diff --git a/build.rs b/build.rs index 8f0bed6..227f2fd 100644 --- a/build.rs +++ b/build.rs @@ -1,8 +1,7 @@ -use std::env; - #[allow(dead_code)] // build.rs // https://doc.rust-lang.org/cargo/reference/build-scripts.html +use std::env; const QT_VERSION: &'static str = "6.10.0"; const BASE_DIR: &'static str = "."; @@ -21,13 +20,13 @@ const BUILD_TYPE: &'static str = "Release"; fn get_qt_libs_path() -> String { #[cfg(target_os = "windows")] - return format!("./libdie++/build/{QT_VERSION}/msvc2022_64/lib"); + return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/msvc2022_64/lib"); #[cfg(target_os = "macos")] - return format!("./libdie++/build/{QT_VERSION}/clang_64/lib"); + return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/clang_64/lib"); #[cfg(target_os = "linux")] - return format!("./libdie++/build/{QT_VERSION}/gcc_64/lib"); + return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_64/lib"); } fn qt_download() { @@ -52,7 +51,7 @@ fn qt_download() { .args(["-m", "aqt", "install-qt", "-O", LIBDIE_BUILD_DIR]); #[cfg(target_os = "linux")] - cmd.args(["linux", "desktop", QT_VERSION, "gcc_64"]); + cmd.args(["linux", "desktop", QT_VERSION]); #[cfg(target_os = "macos")] cmd.args(["mac", "desktop", QT_VERSION, "clang_64"]); #[cfg(target_os = "windows")] @@ -84,9 +83,8 @@ fn cmake_build_die() { { assert!( std::process::Command::new("cmake") - .current_dir(LIBDIE_BASE_DIR) - .args(["-S", "."]) - .args(["-B", "build"]) + .args(["-S", LIBDIE_BASE_DIR]) + .args(["-B", LIBDIE_BUILD_DIR]) .spawn() .unwrap() .wait() @@ -101,9 +99,8 @@ fn cmake_build_die() { assert!( std::process::Command::new("cmake") - .current_dir(LIBDIE_BASE_DIR) - .args(["--build", "build"]) - .args(["-j", nb_cpu]) + .args(["--build", LIBDIE_BUILD_DIR]) + .args(["--parallel", nb_cpu]) .args(["--config", BUILD_TYPE]) .spawn() .unwrap() @@ -117,10 +114,9 @@ fn cmake_build_die() { { assert!( std::process::Command::new("cmake") - .current_dir(LIBDIE_BASE_DIR) - .args(["--install", "build"]) + .args(["--install", LIBDIE_BUILD_DIR]) .args(["--config", BUILD_TYPE]) - .args(["--prefix", "install"]) + .args(["--prefix", LIBDIE_INSTALL_DIR]) .spawn() .unwrap() .wait() @@ -255,20 +251,15 @@ fn should_rebuild_libdie() -> bool { let mut fpath = std::path::PathBuf::from(LIBDIE_INSTALL_DIR); #[cfg(target_os = "windows")] - { - fpath.push("die.lib"); - fpath.exists() == false - } + fpath.push("die.lib"); #[cfg(target_os = "linux")] - { - true - } + fpath.push("lib/libdie.a"); #[cfg(target_os = "macos")] - { - true - } + fpath.push("lib/"); + + return fpath.exists() == false; } fn main() { From fcc9574a6f52abad7fc7368f6a1f742de67bc606 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 09:03:05 -0800 Subject: [PATCH 04/15] github actions stuff --- .github/workflows/build.yml | 38 +++++++++---------------------------- build.rs | 2 +- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56f97ef..9b6eb48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,8 +25,6 @@ jobs: - {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} runs-on: ${{ matrix.variants.os }} - env: - QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" steps: - uses: actions/checkout@v5 - uses: actions/cache@v4 @@ -41,48 +39,30 @@ jobs: target/ key: ${{ matrix.variants.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Build (Linux) - if: startsWith(matrix.variants.os, 'ubuntu-') - run: | - python -m pip install aqtinstall --user --upgrade - python -m aqt install-qt -O libdie++/build ${{ matrix.variants.aqt_os }} desktop ${{ env.QT_BUILD_VERSION }} ${{ matrix.variants.aqt_compiler }} - export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - cargo build -vv --tests --examples - echo QT6_LIB_PATH=${QT6_LIB_PATH} >> $GITHUB_ENV - - - name: Build (macOS) - if: startsWith(matrix.variants.os, 'macos-') + - name: Build + env: + QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" run: | - python -m pip install aqtinstall --user --upgrade - python -m aqt install-qt -O libdie++/build ${{ matrix.variants.aqt_os }} desktop ${{ env.QT_BUILD_VERSION }} ${{ matrix.variants.aqt_compiler }} - export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" cargo build -vv --tests --examples - echo QT6_LIB_PATH=${QT6_LIB_PATH} >> $GITHUB_ENV - - name: Build (Windows) - run: | - python -m pip install aqtinstall --user --upgrade - python -m aqt install-qt -O libdie++/build ${{ matrix.variants.aqt_os }} desktop ${{ env.QT_BUILD_VERSION }} ${{ matrix.variants.aqt_compiler }} - $env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - cargo build -vv --tests --examples - - - name: Tests (Linux) + - name: Test Setup (Linux) if: startsWith(matrix.variants.os, 'ubuntu-') run: | export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QT6_LIB_PATH} - cargo test -vv - - name: Tests (macOS) + - name: Test Setup (macOS) if: startsWith(matrix.variants.os, 'macos-') run: | export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QT6_LIB_PATH} - cargo test -vv - - name: Tests (Windows) + - name: Test Setup (Windows) if: startsWith(matrix.variants.os, 'windows-') run: | $env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" cp -v ./libdie++/install/die/*.dll . + + - name: Test + run: | cargo test -vv diff --git a/build.rs b/build.rs index 227f2fd..a7b6dc0 100644 --- a/build.rs +++ b/build.rs @@ -23,7 +23,7 @@ fn get_qt_libs_path() -> String { return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/msvc2022_64/lib"); #[cfg(target_os = "macos")] - return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/clang_64/lib"); + return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/macos/lib"); #[cfg(target_os = "linux")] return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_64/lib"); From 3db2e0022c2fc6e8aaf9e2eb8cd8a822145df3a8 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 09:32:33 -0800 Subject: [PATCH 05/15] [ci] fixed missing env var --- .github/workflows/build.yml | 33 +++++++++++++++------------------ build.rs | 2 +- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b6eb48..6a6261a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,30 +39,27 @@ jobs: target/ key: ${{ matrix.variants.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Build + - name: Build (Windows) + if: startsWith(matrix.variants.os, 'windows-') env: QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" run: | cargo build -vv --tests --examples + cargo test -vv - - name: Test Setup (Linux) - if: startsWith(matrix.variants.os, 'ubuntu-') - run: | - export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QT6_LIB_PATH} - - - name: Test Setup (macOS) - if: startsWith(matrix.variants.os, 'macos-') - run: | - export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QT6_LIB_PATH} - - - name: Test Setup (Windows) - if: startsWith(matrix.variants.os, 'windows-') + - name: Build (Linux) + env: + QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" + LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:${QT6_LIB_PATH}" run: | - $env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - cp -v ./libdie++/install/die/*.dll . + cargo build -vv --tests --examples + cargo test -vv - - name: Test + - name: Build (macOS) + env: + QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" + LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:${QT6_LIB_PATH}" run: | + cargo build -vv --tests --examples cargo test -vv + diff --git a/build.rs b/build.rs index a7b6dc0..139543a 100644 --- a/build.rs +++ b/build.rs @@ -257,7 +257,7 @@ fn should_rebuild_libdie() -> bool { fpath.push("lib/libdie.a"); #[cfg(target_os = "macos")] - fpath.push("lib/"); + fpath.push("lib/libdie.a"); return fpath.exists() == false; } From 7ee12f036ac90de2e070909bb0187f7de06b5f42 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 09:49:11 -0800 Subject: [PATCH 06/15] [ci] more fixing --- .github/workflows/build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a6261a..6a81cf5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,22 +44,22 @@ jobs: env: QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" run: | - cargo build -vv --tests --examples - cargo test -vv + cargo build -vv --tests --examples --release + cargo test -vv --release - name: Build (Linux) env: QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:${QT6_LIB_PATH}" + LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" run: | - cargo build -vv --tests --examples - cargo test -vv + cargo build -vv --tests --examples --release + cargo test -vv --release - name: Build (macOS) env: QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:${QT6_LIB_PATH}" + LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" run: | - cargo build -vv --tests --examples - cargo test -vv + cargo build -vv --tests --examples --release + cargo test -vv --release From 914ac08a68e3d24ce43b914813f751fe9c62779e Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 10:11:57 -0800 Subject: [PATCH 07/15] [ci] more fixing --- .github/workflows/build.yml | 23 ++++++++++++++--------- examples/scan_file.rs | 28 +++++++++++++++++++--------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a81cf5..6ae7bbc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,6 @@ env: CARGO_TERM_COLOR: always QT_BUILD_VERSION: 6.10.0 - jobs: build: strategy: @@ -41,25 +40,31 @@ jobs: - name: Build (Windows) if: startsWith(matrix.variants.os, 'windows-') - env: - QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" run: | + $env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" + $env:DIE_DB_PATH="./db/db" cargo build -vv --tests --examples --release cargo test -vv --release + cd libdie++\install\die + cargo run --example scan_file -- -vv /bin/ls --database-path $env:DIE_DB_PATH - name: Build (Linux) - env: - QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" + if: startsWith(matrix.variants.os, 'ubuntu-') run: | + export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" + export DIE_DB_PATH="`pwd`/libdie++/install/die/db/db" cargo build -vv --tests --examples --release cargo test -vv --release + cargo run --example scan_file -- -vv /bin/ls --database-path ${DIE_DB_PATH} - name: Build (macOS) - env: - QT6_LIB_PATH: "./libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH}:libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" + if: startsWith(matrix.variants.os, 'macos-') run: | + export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" + export DIE_DB_PATH="`pwd`/libdie++/install/die/db/db" cargo build -vv --tests --examples --release cargo test -vv --release + cargo run --example scan_file -- -vv /bin/ls --database-path ${DIE_DB_PATH} diff --git a/examples/scan_file.rs b/examples/scan_file.rs index fd13ad6..2daf3ac 100644 --- a/examples/scan_file.rs +++ b/examples/scan_file.rs @@ -1,11 +1,11 @@ type Error = Box; type Result = std::result::Result; -use std::path::PathBuf; +use std::{env, path::PathBuf}; use clap::{Parser, ValueEnum}; use derive_more::derive::Display; -use log::{debug, error, info, LevelFilter}; +use log::{LevelFilter, debug, error, info, trace}; #[derive(Default, Clone, Debug, Display, ValueEnum)] enum OutputFormat { @@ -42,29 +42,39 @@ fn main() -> Result<()> { }; env_logger::Builder::new().filter(None, log_level).init(); + trace!("env_logger initialized"); debug!("Starting at log level {:?}", &log_level); let mut scan_flags = die::ScanFlags::DEEP_SCAN; if log_level >= LevelFilter::Debug { + trace!("Setting VERBOSE scan flag"); scan_flags |= die::ScanFlags::VERBOSE; } + debug!("Scanning with flags {:?}", scan_flags,); + let res = match args.database { Some(db) => { - debug!( - "Scanning with flags {:?} and database path {}", - scan_flags, + trace!( + "Using database path {} from command line", args.filepath.as_path().to_string_lossy() ); die::scan_file_with_db(args.filepath.as_path(), scan_flags, db.as_path()) } - None => { - debug!("Scanning with flags {:?}", scan_flags); - die::scan_file(args.filepath.as_path(), scan_flags) - } + None => match env::var("DIE_DB_PATH") { + Ok(db_str) => { + let db_path = PathBuf::from(db_str); + trace!("Using database path from environment {:?}", &db_path); + die::scan_file_with_db(args.filepath.as_path(), scan_flags, db_path.as_path()) + } + Err(_) => { + trace!("Scanning without database"); + die::scan_file(args.filepath.as_path(), scan_flags) + } + }, }; match res { From 71f3a8c6ed56f955243774abcd5c34cc06e6791c Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 10:37:30 -0800 Subject: [PATCH 08/15] [ci] more fixing --- .github/workflows/build.yml | 10 +++++----- build.rs | 18 +++++++++--------- src/lib.rs | 10 ++++++++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ae7bbc..2c1c52d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - {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: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64} runs-on: ${{ matrix.variants.os }} steps: - uses: actions/checkout@v5 @@ -54,8 +54,8 @@ jobs: export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" export DIE_DB_PATH="`pwd`/libdie++/install/die/db/db" - cargo build -vv --tests --examples --release - cargo test -vv --release + cargo build -vv --tests --examples + cargo test -vv cargo run --example scan_file -- -vv /bin/ls --database-path ${DIE_DB_PATH} - name: Build (macOS) @@ -64,7 +64,7 @@ jobs: export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib" export DIE_DB_PATH="`pwd`/libdie++/install/die/db/db" - cargo build -vv --tests --examples --release - cargo test -vv --release + cargo build -vv --tests --examples + cargo test -vv cargo run --example scan_file -- -vv /bin/ls --database-path ${DIE_DB_PATH} diff --git a/build.rs b/build.rs index 139543a..84b10f8 100644 --- a/build.rs +++ b/build.rs @@ -143,15 +143,15 @@ fn setup_common() { println!("cargo:rustc-link-search=native={}", qt_lib_path); } - if BUILD_TYPE == "Release" { - println!("cargo:rustc-link-lib=static=Qt6Core"); - println!("cargo:rustc-link-lib=static=Qt6Qml"); - println!("cargo:rustc-link-lib=static=Qt6Network"); - - println!("cargo:rustc-link-lib=dylib=Qt6Core"); - println!("cargo:rustc-link-lib=dylib=Qt6Qml"); - println!("cargo:rustc-link-lib=dylib=Qt6Network"); - } + // if BUILD_TYPE == "Release" { + // println!("cargo:rustc-link-lib=static=Qt6Core"); + // println!("cargo:rustc-link-lib=static=Qt6Qml"); + // println!("cargo:rustc-link-lib=static=Qt6Network"); + + // println!("cargo:rustc-link-lib=dylib=Qt6Core"); + // println!("cargo:rustc-link-lib=dylib=Qt6Qml"); + // println!("cargo:rustc-link-lib=dylib=Qt6Network"); + // } } #[cfg(target_os = "linux")] diff --git a/src/lib.rs b/src/lib.rs index b31e7ca..3867f78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -305,6 +305,7 @@ mod tests { let flags = ScanFlags::DEEP_SCAN; let res = scan_file(fname, flags).unwrap(); + assert_ne!(res.len(), 0); #[cfg(not(target_os = "macos"))] assert!( res.starts_with(expected_type), @@ -319,9 +320,11 @@ mod tests { let fname = default_test_file(); let expected_type = default_test_file_type(); - let flags = ScanFlags::DEEP_SCAN; + let flags = ScanFlags::DEEP_SCAN | ScanFlags::VERBOSE; if let Ok(db_path) = std::env::var("DIE_DB_PATH") { let res = scan_file_with_db(&fname, flags, Path::new(&db_path)).unwrap(); + assert_ne!(res.len(), 0); + #[cfg(not(target_os = "macos"))] assert!( res.starts_with(expected_type), "unexpected result: got {:?}, expected {:?}", @@ -343,6 +346,7 @@ mod tests { let mem = unsafe { Mmap::map(&file).unwrap() }; let res = scan_memory(mem.as_ref(), flags).unwrap(); + assert_ne!(res.len(), 0); #[cfg(not(target_os = "macos"))] assert!( res.starts_with(expected_type), @@ -357,12 +361,14 @@ mod tests { let fname = default_test_file(); let expected_type = default_test_file_type(); - let flags = ScanFlags::DEEP_SCAN; + let flags = ScanFlags::DEEP_SCAN | ScanFlags::VERBOSE; let file = File::open(fname).unwrap(); let mem = unsafe { Mmap::map(&file).unwrap() }; if let Ok(db_path) = std::env::var("DIE_DB_PATH") { let res = scan_memory_with_db(mem.as_ref(), flags, Path::new(&db_path)).unwrap(); + assert_ne!(res.len(), 0); + #[cfg(not(target_os = "macos"))] assert!( res.starts_with(expected_type), "unexpected result: got {:?}, expected {:?}", From 85bdd7cb7b8c0cbe4a553f1e8eaefdf876ff510f Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 10:39:54 -0800 Subject: [PATCH 09/15] [ci] only latest img --- .github/workflows/build.yml | 4 ++-- src/lib.rs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c1c52d..49efa8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,10 +16,10 @@ jobs: fail-fast: false matrix: variants: - - {os: ubuntu-22.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64} + # - {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-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} diff --git a/src/lib.rs b/src/lib.rs index 3867f78..eb3acfd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -305,7 +305,6 @@ mod tests { let flags = ScanFlags::DEEP_SCAN; let res = scan_file(fname, flags).unwrap(); - assert_ne!(res.len(), 0); #[cfg(not(target_os = "macos"))] assert!( res.starts_with(expected_type), @@ -346,7 +345,6 @@ mod tests { let mem = unsafe { Mmap::map(&file).unwrap() }; let res = scan_memory(mem.as_ref(), flags).unwrap(); - assert_ne!(res.len(), 0); #[cfg(not(target_os = "macos"))] assert!( res.starts_with(expected_type), From 8fe986f8f960ad4d66e08c585bd728eb7321da15 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 11:35:37 -0800 Subject: [PATCH 10/15] correctly rebuild if switching debug/rebuild, make sure tests pass on windwos --- .github/workflows/build.yml | 8 +++-- .gitignore | 1 + build.rs | 68 +++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49efa8e..5ff7fb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,10 +42,12 @@ jobs: if: startsWith(matrix.variants.os, 'windows-') run: | $env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - $env:DIE_DB_PATH="./db/db" - cargo build -vv --tests --examples --release - cargo test -vv --release + $env:DIE_DB_PATH="./libdie++/install/db" + cargo build -vv --tests --examples + cp ./libdie++/install/die/*.dll . + cargo test -vv cd libdie++\install\die + $env:DIE_DB_PATH=".\db" cargo run --example scan_file -- -vv /bin/ls --database-path $env:DIE_DB_PATH - name: Build (Linux) diff --git a/.gitignore b/.gitignore index 4e52b77..3aa78e6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ libdie++/build libdie++/install .vscode aqtinstall.log +*.dll diff --git a/build.rs b/build.rs index 84b10f8..facd36d 100644 --- a/build.rs +++ b/build.rs @@ -143,15 +143,14 @@ fn setup_common() { println!("cargo:rustc-link-search=native={}", qt_lib_path); } - // if BUILD_TYPE == "Release" { - // println!("cargo:rustc-link-lib=static=Qt6Core"); - // println!("cargo:rustc-link-lib=static=Qt6Qml"); - // println!("cargo:rustc-link-lib=static=Qt6Network"); - - // println!("cargo:rustc-link-lib=dylib=Qt6Core"); - // println!("cargo:rustc-link-lib=dylib=Qt6Qml"); - // println!("cargo:rustc-link-lib=dylib=Qt6Network"); - // } + if BUILD_TYPE == "Release" { + println!("cargo:rustc-link-lib=static=Qt6Core"); + println!("cargo:rustc-link-lib=static=Qt6Qml"); + println!("cargo:rustc-link-lib=static=Qt6Network"); + println!("cargo:rustc-link-lib=dylib=Qt6Core"); + println!("cargo:rustc-link-lib=dylib=Qt6Qml"); + println!("cargo:rustc-link-lib=dylib=Qt6Network"); + } } #[cfg(target_os = "linux")] @@ -205,10 +204,37 @@ fn install() { #[cfg(target_os = "windows")] fn install() { + match BUILD_TYPE { + "Release" => { + println!("cargo:rustc-link-lib=static=Qt6Core"); + println!("cargo:rustc-link-lib=static=Qt6Qml"); + println!("cargo:rustc-link-lib=static=Qt6Network"); + println!("cargo:rustc-link-lib=dylib=Qt6Core"); + println!("cargo:rustc-link-lib=dylib=Qt6Qml"); + println!("cargo:rustc-link-lib=dylib=Qt6Network"); + } + "Debug" => { + println!("cargo:rustc-link-lib=static=Qt6Cored"); + println!("cargo:rustc-link-lib=static=Qt6Qmld"); + println!("cargo:rustc-link-lib=static=Qt6Networkd"); + println!("cargo:rustc-link-lib=dylib=Qt6Cored"); + println!("cargo:rustc-link-lib=dylib=Qt6Qmld"); + println!("cargo:rustc-link-lib=dylib=Qt6Networkd"); + println!("cargo:rustc-link-search=native={}/ucrt/x64", MSVC_PATH); + println!("cargo:rustc-link-lib=static=ucrtd"); + } + _ => { + unimplemented!() + } + }; + + println!("cargo:rustc-link-search=native={}/die", LIBDIE_INSTALL_DIR); + println!( "cargo:rustc-link-search=native={}/die/dielib", LIBDIE_INSTALL_DIR ); + println!( "cargo:rustc-link-search=native={}/{}", LIBDIE_BUILD_DIR, BUILD_TYPE @@ -229,18 +255,6 @@ fn install() { ); println!("cargo:rustc-link-lib=dylib=Crypt32"); println!("cargo:rustc-link-lib=dylib=Wintrust"); - - if BUILD_TYPE == "Debug" { - println!("cargo:rustc-link-lib=static=Qt6Cored"); - println!("cargo:rustc-link-lib=static=Qt6Qmld"); - println!("cargo:rustc-link-lib=static=Qt6Networkd"); - println!("cargo:rustc-link-lib=dylib=Qt6Cored"); - println!("cargo:rustc-link-lib=dylib=Qt6Qmld"); - println!("cargo:rustc-link-lib=dylib=Qt6Networkd"); - - println!("cargo:rustc-link-search=native={}/ucrt/x64", MSVC_PATH); - println!("cargo:rustc-link-lib=static=ucrtd"); - } } fn is_qt_missing() -> bool { @@ -248,6 +262,18 @@ fn is_qt_missing() -> bool { } fn should_rebuild_libdie() -> bool { + for _mod in ["bzip2", "lzma", "zlib"].iter() { + #[cfg(target_os = "windows")] + let path_str = format!("{}/XArchive/3rdparty/{}/{}", LIB_DIE_PATH, _mod, BUILD_TYPE); + + #[cfg(not(target_os = "windows"))] + let path_str = format!("{}/XArchive/3rdparty/{}", LIB_DIE_PATH, _mod); + + if !std::path::Path::new(path_str.as_str()).exists() { + return true; + } + } + let mut fpath = std::path::PathBuf::from(LIBDIE_INSTALL_DIR); #[cfg(target_os = "windows")] From 6fbe4230adb774740aaa3dd23d0f0bdb5c6e6d45 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 11:37:43 -0800 Subject: [PATCH 11/15] fix windows ci --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ff7fb7..0f359c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,8 +46,6 @@ jobs: cargo build -vv --tests --examples cp ./libdie++/install/die/*.dll . cargo test -vv - cd libdie++\install\die - $env:DIE_DB_PATH=".\db" cargo run --example scan_file -- -vv /bin/ls --database-path $env:DIE_DB_PATH - name: Build (Linux) From df08dfbafba29b934cb3854572105e507142772e Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 11:40:58 -0800 Subject: [PATCH 12/15] fixed bad db path --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f359c6..5c4d3e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,11 +42,11 @@ jobs: if: startsWith(matrix.variants.os, 'windows-') run: | $env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" - $env:DIE_DB_PATH="./libdie++/install/db" + $env:DIE_DB_PATH="./libdie++/install/die/db/db" cargo build -vv --tests --examples cp ./libdie++/install/die/*.dll . cargo test -vv - cargo run --example scan_file -- -vv /bin/ls --database-path $env:DIE_DB_PATH + cargo run --example scan_file -- -vv C:\Windows\System32\winver.exe - name: Build (Linux) if: startsWith(matrix.variants.os, 'ubuntu-') From c9b52fdce58a1490df3b3664469394012c41e9ca Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 12:08:47 -0800 Subject: [PATCH 13/15] test release build on windows --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c4d3e2..7651dc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,9 +43,9 @@ jobs: run: | $env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib" $env:DIE_DB_PATH="./libdie++/install/die/db/db" - cargo build -vv --tests --examples + cargo build -vv --tests --examples --release cp ./libdie++/install/die/*.dll . - cargo test -vv + cargo test -vv --release cargo run --example scan_file -- -vv C:\Windows\System32\winver.exe - name: Build (Linux) From 6bf25e3bef7821be36018112de95d5b5cef5ac4d Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 12:26:26 -0800 Subject: [PATCH 14/15] test release build on windows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7651dc5..0090fb0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: cargo build -vv --tests --examples --release cp ./libdie++/install/die/*.dll . cargo test -vv --release - cargo run --example scan_file -- -vv C:\Windows\System32\winver.exe + cargo run --release --example scan_file -- -vv C:\Windows\System32\winver.exe - name: Build (Linux) if: startsWith(matrix.variants.os, 'ubuntu-') From fc55c758b03843e115a727b44b96ba7d5e52c732 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Thu, 6 Nov 2025 13:27:31 -0800 Subject: [PATCH 15/15] updated readme --- README.md | 50 ++------------------------------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 61eea81..c5cc923 100644 --- a/README.md +++ b/README.md @@ -12,20 +12,8 @@ This module provides Rust bindings for the [Detect-It-Easy](https://github.com/h ### Build -> [!IMPORTANT] -> [**Qt6**](https://qt.io) libraries must be installed for Detect-it-Easy to work. -> On Linux and macOS, `die-rust` can be built using the Qt6 provided by the typical package management systems (`apt`, `dnf`, `brew`, etc.). -> If you do not wish to install those packages system-wide, if you are running Windows, or if you wish/need to use a specific version of Qt6, it is possible to build `die-rust` by installing those libraries in a specific folder, using [`aqtinstall`](https://github.com/miurahr/aqtinstall) - (see below). Then build `die-rust` by passing the paths to the Qt6 libraries with the `QT6_LIB_PATH` environment. - -### As a dependency - -Use `cargo` to add `die-rust` as a dependency to your project: - -```console -cargo add --git https://github.com/elastic/die-rust.git -``` - -### On the terminal +> [!Warning] +> `Detect-It-Easy` has a hard requirement for Qt6 libraries. `cargo build` will manage the entire building process in an automated, but to be able to link against Qt6, it will use the library [`aqtinstall`](). Therefore `python` must be installed on the system. Note that downloading the Qt libraries may take some time, depending on your Internet connection. The installation can be done using `cargo`. @@ -35,40 +23,6 @@ cd die-rust cargo build ``` -The build requires Qt6 libraries. On Linux/macOS they can usually be obtained from the system's package manager. To use a specific Qt6 version, it is possible to use `aqtinstall` as follow - -### Linux - -```bash -export QT_BUILD_VERSION=6.10.0 -git clone https://github.com/elastic/die-rust.git && cd die-rust -python -m pip install aqtinstall -python -m aqt install-qt -O ./libdie++/build/ linux desktop ${QT_BUILD_VERSION} gcc_64 -export QT6_LIB_PATH=./libdie++/build/6.10.0/gcc_64/lib -``` - -### macOS - -```bash -export QT_BUILD_VERSION=6.10.0 -git clone https://github.com/calladoum-elastic/die-rust.git && cd die-rust -python -m pip install aqtinstall -python -m aqt install-qt -O ./libdie++/build/ mac desktop ${QT_BUILD_VERSION} clang_64 -export QT6_LIB_PATH=./libdie++/build/6.10.0/clang_64/lib # macos -``` - -### Windows - -```pwsh -$env:QT_BUILD_VERSION="6.10.0" -git clone https://github.com/calladoum-elastic/die-rust.git && cd die-rust -python -m pip install aqtinstall -python -m aqt install-qt -O ./libdie++/build/ windows desktop $env:QT_BUILD_VERSION win64_msvc2022_64 -$env:QT6_LIB_PATH="./libdie++/build/6.10.0/msvc2022_64/lib" -``` - - - ## Examples