Files
punktfunk/packaging/windows/drivers/wdk-probe/build.rs
T
enricobuehler 3fbabc854c
apple / swift (push) Failing after 1s
apple / screenshots (push) Has been skipped
windows-drivers / probe-and-proto (push) Successful in 19s
windows-drivers / driver-build (push) Successful in 1m5s
windows-host / package (push) Successful in 5m19s
ci / rust (push) Successful in 4m13s
ci / web (push) Successful in 41s
ci / docs-site (push) Successful in 53s
android / android (push) Successful in 9m59s
ci / bench (push) Successful in 4m48s
decky / build-publish (push) Successful in 11s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 5s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 4s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 4s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 4s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 3s
deb / build-publish (push) Successful in 2m19s
rpm / build-publish (bazzite, punktfunk-fedora-rpm) (push) Successful in 8m33s
rpm / build-publish (fedora-44, punktfunk-fedora44-rpm) (push) Successful in 8m13s
docker / deploy-docs (push) Has been cancelled
feat(windows-drivers): IddCx link probe — call init DDIs via table dispatch
First USE of the iddcx binding: a minimal table-dispatch (src/iddcx_rt.rs) over
wdk_sys::iddcx — IddFunctions[_IDDFUNCENUM::<Name>TableIndex] cast to PFN_*,
IddDriverGlobals as implicit arg 1 (the WDF model; ModuleConsts i32 index, not the
oracle NewType .0). The probe EvtDeviceAdd now calls IddCxDeviceInitConfig →
WdfDeviceCreate → IddCxDeviceInitialize → IddCxAdapterInitAsync, exports
IddMinimumVersionRequired=4, and build.rs links IddCxStub (globbed from the SDK
Lib dir that ships iddcx). CI gate = compile + link IddCxStub.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 15:18:48 +00:00

42 lines
1.9 KiB
Rust

//! Emits the WDK link flags for the cdylib (the same call the gamepad drivers use). If wdk-build adds
//! `/INTEGRITYCHECK`, it shows up in the produced DLL's PE DllCharacteristics — which the CI step
//! inspects to answer the M0 self-signed-load question. Also links `IddCxStub` so the `iddcx` DDIs the
//! probe calls resolve (the M1 link gate).
fn main() -> Result<(), wdk_build::ConfigError> {
wdk_build::configure_wdk_binary_build()?;
link_iddcx_stub();
Ok(())
}
/// Link `IddCxStub.lib`. It ships only under the SDK *version* that includes IddCx (e.g. 10.0.26100.0),
/// at `Lib\<ver>\um\<arch>\iddcx\<iddcxver>\` — a newer base SDK installed alongside (e.g. 10.0.28000.0)
/// has `um\<arch>` but no `iddcx`, so we glob for the dir that actually contains the lib rather than
/// trusting the max SDK version (the same gotcha the `wdf-umdf` oracle's build script documents). x64
/// only (the Windows host is x64-only).
fn link_iddcx_stub() {
const ARCH: &str = "x64";
const ROOTS: [&str; 2] = [
r"C:\Program Files (x86)\Windows Kits\10\Lib",
r"C:\Program Files\Windows Kits\10\Lib",
];
for root in ROOTS {
let Ok(versions) = std::fs::read_dir(root) else {
continue;
};
for ver in versions.flatten() {
let iddcx = ver.path().join("um").join(ARCH).join("iddcx");
let Ok(subdirs) = std::fs::read_dir(&iddcx) else {
continue;
};
for sub in subdirs.flatten() {
if sub.path().join("IddCxStub.lib").is_file() {
println!("cargo:rustc-link-search={}", sub.path().display());
println!("cargo:rustc-link-lib=static=IddCxStub");
return;
}
}
}
}
panic!("IddCxStub.lib not found under any Windows Kits Lib\\<ver>\\um\\{ARCH}\\iddcx\\<iddcxver>\\");
}