mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 21:11:52 +00:00
The pdfcraft-print unit-test executable imported windows.data.pdf.dll and prntvpt.dll at load time (the windows crate binds them with raw-dylib), so on a Windows installation without them it could not start, and the tests of the missing-DLL guard never ran there. crates/print/build.rs now passes /DELAYLOAD for both and delayimp.lib on MSVC, as the applications' build scripts do. Link arguments from a build script reach only this package's own executables, so dependents are unaffected. dumpbin /imports: before, both DLLs under "the following imports"; after, under "the following delay load imports". A copy of each test binary with prntvpt.dll renamed to a DLL that doesn't exist: the old one exits with 0xC0000135 (STATUS_DLL_NOT_FOUND) before main, the new one starts and runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
24 lines
1.1 KiB
Rust
24 lines
1.1 KiB
Rust
//! Windows (MSVC) only: delay-load the print DLLs in this crate's own test executable, as the
|
|
//! applications do (`apps/pdfcraft{,-cli}/build.rs`), so it starts on a Windows installation that
|
|
//! lacks them (#2630) and its tests of the missing-DLL guard in `src/spool.rs` run there. Link
|
|
//! arguments from a build script reach only this package's own executables (its tests), never
|
|
//! the crates that depend on it; each application sets its own.
|
|
//!
|
|
//! On every other target this does nothing.
|
|
|
|
/// The in-box DLLs only printing uses (Windows.Data.Pdf draws the job, prntvpt reads the
|
|
/// driver's print capabilities). Same list in `apps/pdfcraft{,-cli}/build.rs` and
|
|
/// `src/spool.rs`.
|
|
const DELAY_LOADED: [&str; 2] = ["windows.data.pdf.dll", "prntvpt.dll"];
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") || std::env::var("CARGO_CFG_TARGET_ENV").as_deref() != Ok("msvc") {
|
|
return;
|
|
}
|
|
for dll in DELAY_LOADED {
|
|
println!("cargo:rustc-link-arg=/DELAYLOAD:{dll}");
|
|
}
|
|
println!("cargo:rustc-link-arg=delayimp.lib");
|
|
}
|