//! Separate diagnostic only: actual Microsoft outputs from native case 149bafe2. //! No generator execution/fallback, NDR edits, header-version overrides or //! modification of the product crate's build script/output directory. use sha2::{Digest, Sha256}; use std::{env, fs, path::Path}; fn pinned(path: &Path, expected: &str) { let bytes = fs::read(path).expect("missing pinned diagnostic input"); assert_eq!( format!("{:x}", Sha256::digest(bytes)), expected, "diagnostic input changed: {}", path.display() ); println!("cargo:rerun-if-changed={}", path.display()); } fn main() { let here = env::current_dir().unwrap(); let root = here.join("../../.."); for (name, digest) in [ ( "examples/clock_readiness.rs", "77433fafc9891ada53571bc070e33b9c9998379b7dadf48c1e19dc3851e44fe7", ), ( "src/clock.rs", "08b983095015cc7ba08ce08e9436d1519bf720c5501dd7af8b8b3dbae56b356f", ), ( "native/clock_rpc.c", "74aceb6e2b70c5dd628fae069a842c356c20300b8c8ab12754258c78eaf295c8", ), ( "native/clock_endpoints.c", "85c563bc8824bc30f7e80ef36e3dae5548c1f7a94faf5e882e98f275ab9a55e7", ), ( "native/w32time.idl", "37da4acb622daf9acf1aa6f1218ff9f52e5a2def14e58d8d9dd8da65078b3c6c", ), ] { pinned(&root.join("crates/agent-windows").join(name), digest); } let generated = here.join("generated"); pinned( &generated.join("w32time.h"), "db5dbe5b335eaa58a6512d4abfda44e7273f3aa8a43077dcb0719e4b97ee2bde", ); pinned( &generated.join("w32time_c.c"), "d806adb431f16724c8afdea0c0751588a4bc6f82b6f0b8391d4d189d6a6f4a38", ); if env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") { return; } assert_eq!(env::var("TARGET").as_deref(), Ok("x86_64-pc-windows-gnu")); // Microsoft guards its AMD64 stub using this architecture macro. Clang's // GNU target does not predefine it. This declares the actual selected x64 // architecture; no SDK/RPCNDR version or _MSC_VER is fabricated. cc::Build::new() .compiler("clang") .flag("--target=x86_64-w64-windows-gnu") .flag("-fms-extensions") .flag("-Werror") .define("_M_AMD64", Some("100")) .include(&generated) .file(root.join("crates/agent-windows/native/clock_rpc.c")) .file(root.join("crates/agent-windows/native/clock_endpoints.c")) .compile("rmm_clock_rpc"); // MIDL's unchanged descriptor initializer uses legal C brace elision for // MinGW's union field and emits two unused const tables. Keep these style // warnings visible only for this pinned generated unit; do not edit NDR // data, suppress type/security errors, or weaken wrapper diagnostics. cc::Build::new() .compiler("clang") .flag("--target=x86_64-w64-windows-gnu") .flag("-fms-extensions") .flag("-Werror") .flag("-Wno-error=missing-braces") .flag("-Wno-error=unused-const-variable") .define("_M_AMD64", Some("100")) .include(&generated) .file(generated.join("w32time_c.c")) .compile("rmm_clock_midl_stub"); println!("cargo:rustc-link-lib=rpcrt4"); println!("cargo:rustc-link-lib=advapi32"); // The existing GNU readiness artifact imports both precise interrupt-time // getters through the Windows realtime API set. This SDK's kernel32 import // archive omits them; its mincore archive supplies those same OS imports. // No clock implementation, API fallback or generated code is substituted. println!("cargo:rustc-link-lib=mincore"); }