From 136b0d445b6400213c036fb31891813c7776a565 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 18 Sep 2026 18:45:41 +0000 Subject: [PATCH 1/7] Initial plan From a48672c3b19a4c8cafd7a56266611f0268fbbcb4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 18 Sep 2026 18:48:16 +0000 Subject: [PATCH 2/7] Resolve Windows SDK ucrt path dynamically Co-authored-by: calladoum-elastic <85187342+calladoum-elastic@users.noreply.github.com> --- build.rs | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index ef07124..b7be906 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,10 @@ #[allow(dead_code)] // build.rs // https://doc.rust-lang.org/cargo/reference/build-scripts.html -use std::env; +use std::{ + env, fs, + path::{Path, PathBuf}, +}; const QT_VERSION: &'static str = "6.10.0"; const BASE_DIR: &'static str = "."; @@ -11,7 +14,7 @@ const LIBDIE_INSTALL_DIR: &'static str = "./libdie++/install"; const LIB_DIE_PATH: &'static str = "./libdie++/build/_deps/dielibrary-build/src"; #[cfg(target_os = "windows")] -const MSVC_PATH: &'static str = r"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0"; +const WINDOWS_KITS_LIB_DIR: &'static str = r"C:\Program Files (x86)\Windows Kits\10\Lib"; #[cfg(debug_assertions)] const BUILD_TYPE: &'static str = "Debug"; @@ -138,6 +141,70 @@ fn cmake_build_die() { } } +fn has_windows_ucrt_libs(path: &Path) -> bool { + path.join("ucrt").join("x64").exists() +} + +fn normalized_windows_sdk_version(version: &str) -> &str { + version.trim_end_matches(['\\', '/']) +} + +fn parse_windows_sdk_version(version: &str) -> Option> { + normalized_windows_sdk_version(version) + .split('.') + .map(|segment| segment.parse::().ok()) + .collect() +} + +fn find_latest_windows_sdk_dir(base_dir: &Path) -> Option { + fs::read_dir(base_dir) + .ok()? + .filter_map(|entry| { + let entry = entry.ok()?; + let path = entry.path(); + + if !path.is_dir() || !has_windows_ucrt_libs(&path) { + return None; + } + + let version = entry.file_name(); + let version = version.to_str()?; + let version = parse_windows_sdk_version(version)?; + + Some((version, path)) + }) + .max_by(|(left, _), (right, _)| left.cmp(right)) + .map(|(_, path)| path) +} + +#[cfg(target_os = "windows")] +fn resolve_windows_sdk_dir() -> Option { + if let Some(path) = env::var_os("MSVC_PATH") { + let path = PathBuf::from(path); + if has_windows_ucrt_libs(&path) { + return Some(path); + } + } + + if let Some(root) = env::var_os("WindowsSdkDir") { + let version = env::var("WindowsSDKLibVersion") + .or_else(|_| env::var("WindowsSDKVersion")) + .ok(); + + if let Some(version) = version { + let path = PathBuf::from(root) + .join("Lib") + .join(normalized_windows_sdk_version(&version)); + + if has_windows_ucrt_libs(&path) { + return Some(path); + } + } + } + + find_latest_windows_sdk_dir(Path::new(WINDOWS_KITS_LIB_DIR)) +} + fn setup_common() { // die & die++ println!("cargo:rustc-link-lib=static=die++"); @@ -216,6 +283,11 @@ fn install() { #[cfg(target_os = "windows")] fn install() { + println!("cargo:rerun-if-env-changed=MSVC_PATH"); + println!("cargo:rerun-if-env-changed=WindowsSdkDir"); + println!("cargo:rerun-if-env-changed=WindowsSDKLibVersion"); + println!("cargo:rerun-if-env-changed=WindowsSDKVersion"); + match BUILD_TYPE { "Release" => { println!("cargo:rustc-link-lib=static=Qt6Core"); @@ -226,13 +298,18 @@ fn install() { println!("cargo:rustc-link-lib=dylib=Qt6Network"); } "Debug" => { + let windows_sdk_dir = resolve_windows_sdk_dir().expect( + "failed to locate Windows SDK ucrt path; set MSVC_PATH or install a Windows 10 SDK", + ); + let ucrt_dir = windows_sdk_dir.join("ucrt").join("x64"); + 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-search=native={}", ucrt_dir.display()); println!("cargo:rustc-link-lib=static=ucrtd"); } _ => { @@ -317,3 +394,46 @@ fn main() { println!("cargo:rerun-if-changed=src/lib.rs"); } + +#[cfg(test)] +mod tests { + use super::*; + use std::time::{SystemTime, UNIX_EPOCH}; + + fn temp_test_dir(name: &str) -> PathBuf { + let timestamp = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_nanos(); + env::temp_dir().join(format!("die-rust-build-rs-{name}-{timestamp}")) + } + + #[test] + fn normalizes_windows_sdk_version() { + assert_eq!( + normalized_windows_sdk_version("10.0.26100.0\\"), + "10.0.26100.0" + ); + assert_eq!( + normalized_windows_sdk_version("10.0.26100.0/"), + "10.0.26100.0" + ); + } + + #[test] + fn finds_latest_windows_sdk_dir() { + let base_dir = temp_test_dir("windows-sdk"); + let older = base_dir.join("10.0.22000.0").join("ucrt").join("x64"); + let newer = base_dir.join("10.0.26100.0").join("ucrt").join("x64"); + let invalid = base_dir.join("invalid").join("ucrt").join("x64"); + + fs::create_dir_all(&older).unwrap(); + fs::create_dir_all(&newer).unwrap(); + fs::create_dir_all(&invalid).unwrap(); + + let latest = find_latest_windows_sdk_dir(&base_dir).unwrap(); + assert_eq!(latest, base_dir.join("10.0.26100.0")); + + fs::remove_dir_all(&base_dir).unwrap(); + } +} From e5de912ced02e6f5edc850b60814f902ab612dcb Mon Sep 17 00:00:00 2001 From: Christophe Alladoum <85187342+calladoum-elastic@users.noreply.github.com> Date: Fri, 18 Sep 2026 12:27:09 -0700 Subject: [PATCH 3/7] Update build.rs --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index b7be906..41201ef 100644 --- a/build.rs +++ b/build.rs @@ -44,7 +44,7 @@ fn qt_download() { assert!( std::process::Command::new("python") .current_dir(BASE_DIR) - .args(["-m", "pip", "install", "--user", "--upgrade", "aqtinstall"]) + .args(["-m", "pip", "install", "--upgrade", "aqtinstall"]) .spawn() .unwrap() .wait() From e5302666e4dc7a348e660e5af17340eb0ba925ce Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Fri, 18 Sep 2026 14:01:31 -0700 Subject: [PATCH 4/7] clippy --- build.rs | 35 +++++++++++++++++++++-------------- src/lib.rs | 2 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/build.rs b/build.rs index 41201ef..2cae83f 100644 --- a/build.rs +++ b/build.rs @@ -1,25 +1,28 @@ #[allow(dead_code)] // build.rs // https://doc.rust-lang.org/cargo/reference/build-scripts.html +use std:: env; + +#[cfg(target_os = "windows")] use std::{ - env, fs, - path::{Path, PathBuf}, + fs, + path::{Path, PathBuf} }; -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"; +const QT_VERSION: &str = "6.10.0"; +const BASE_DIR: &str = "."; +const LIBDIE_BASE_DIR: &str = "./libdie++"; +const LIBDIE_BUILD_DIR: &str = "./libdie++/build"; +const LIBDIE_INSTALL_DIR: &str = "./libdie++/install"; +const LIB_DIE_PATH: &str = "./libdie++/build/_deps/dielibrary-build/src"; #[cfg(target_os = "windows")] -const WINDOWS_KITS_LIB_DIR: &'static str = r"C:\Program Files (x86)\Windows Kits\10\Lib"; +const WINDOWS_KITS_LIB_DIR: &str = r"C:\Program Files (x86)\Windows Kits\10\Lib"; #[cfg(debug_assertions)] -const BUILD_TYPE: &'static str = "Debug"; +const BUILD_TYPE: &str = "Debug"; #[cfg(not(debug_assertions))] -const BUILD_TYPE: &'static str = "Release"; +const BUILD_TYPE: &str = "Release"; fn get_qt_libs_path() -> String { #[cfg(target_os = "windows")] @@ -76,7 +79,7 @@ fn qt_download() { cmd.spawn() .unwrap() .wait() - .expect(format!("failed to install Qt {QT_VERSION} using AQT").as_str()) + .unwrap_or_else(|_| panic!("failed to install Qt {QT_VERSION} using AQT")) .success() ); } @@ -141,14 +144,17 @@ fn cmake_build_die() { } } +#[cfg(target_os = "windows")] fn has_windows_ucrt_libs(path: &Path) -> bool { path.join("ucrt").join("x64").exists() } +#[cfg(target_os = "windows")] fn normalized_windows_sdk_version(version: &str) -> &str { version.trim_end_matches(['\\', '/']) } +#[cfg(target_os = "windows")] fn parse_windows_sdk_version(version: &str) -> Option> { normalized_windows_sdk_version(version) .split('.') @@ -156,6 +162,7 @@ fn parse_windows_sdk_version(version: &str) -> Option> { .collect() } +#[cfg(target_os = "windows")] fn find_latest_windows_sdk_dir(base_dir: &Path) -> Option { fs::read_dir(base_dir) .ok()? @@ -347,7 +354,7 @@ fn install() { } fn is_qt_missing() -> bool { - std::path::Path::new(get_qt_libs_path().as_str()).exists() == false + !std::path::Path::new(get_qt_libs_path().as_str()).exists() } fn should_rebuild_libdie() -> bool { @@ -374,7 +381,7 @@ fn should_rebuild_libdie() -> bool { #[cfg(target_os = "macos")] fpath.push("lib/libdie.a"); - return fpath.exists() == false; + !fpath.exists() } fn main() { diff --git a/src/lib.rs b/src/lib.rs index b20ee53..a837d50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -263,7 +263,7 @@ pub fn scan_memory_with_db(mem: &[u8], flags: ScanFlags, db_path: &Path) -> Resu /// # Returns /// /// * `Result<()>` - On success, returns `Ok()`. -/// On failure, returns an `Err` with the error details. +/// On failure, returns an `Err` with the error details. /// /// # Examples /// From ef0a8c46b8289994e5bd6aa8809f38d291c12785 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Fri, 18 Sep 2026 14:09:51 -0700 Subject: [PATCH 5/7] add libqt into rpath (linux) --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index 2cae83f..7874dcd 100644 --- a/build.rs +++ b/build.rs @@ -259,6 +259,7 @@ fn install() { LIB_DIE_PATH, _mod ); } + println!("cargo:rustc-link-arg=-Wl,-rpath,{}/die/lib", LIBDIE_INSTALL_DIR); } #[cfg(target_os = "macos")] From cf1188da998890668a339a2123608710983d12d3 Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Fri, 18 Sep 2026 14:10:12 -0700 Subject: [PATCH 6/7] (ghactions) bump versions --- .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 ef8b859..919e907 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,8 @@ jobs: # - {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 - - uses: actions/cache@v4 + - uses: actions/checkout@v7 + - uses: actions/cache@v6 with: path: | ~/.cargo/bin/ From 8fa921be8900d76fcecaa23e4985e04ca115e99f Mon Sep 17 00:00:00 2001 From: Christophe Alladoum Date: Fri, 18 Sep 2026 14:18:01 -0700 Subject: [PATCH 7/7] mark cargo.lock as linguist-generated --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..220f6aa --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +Cargo.lock linguist-generated