Add Windows Driver Kit (WDK) support for building KMDF/UMDF drivers

download --with-wdk fetches the WDK headers/libs/host-tools NuGet
packages (nuget.org has no vsman-manifest entry for this content) and
lays them out where the DriverKit.BuildTools PlatformToolset expects
them. msbuildEnv wires WDKContentRoot/WDKBuildFolder through
DisableRegistryUse the same way the SDK/toolset paths already are.

Two WDK-package fixups were needed for a real driver to actually
build under Wine: the bundled build-task assembly is versioned for an
older VisualStudioVersion than ours, and the package ships no x86
host-tools directory at all (only x64/arm64), which StampInf hardcodes
a path to.

Also force TZ=UTC for msbuild invocations: StampInf stamps DriverVer
using the local wall-clock date while Inf2Cat validates it against
UTC "now", so any timezone east of UTC sees a "postdated DriverVer"
failure for most of the day.

Verified against a real KMDF sample driver (microsoft/Windows-driver-
samples' echo_2): compiles, links, INF stamps and passes Inf2Cat's
signability check with SignMode=off.
This commit is contained in:
Cheviiot
2026-07-25 03:24:44 +10:00
parent 44fee57ddd
commit 8551d7fe99
4 changed files with 347 additions and 3 deletions
+10 -2
View File
@@ -43,7 +43,15 @@ type Options struct {
SkipRecommended bool
Language string
WithWDKInstallers string
// WithWDK selects the PlatformToolset registration
// (Component.Microsoft.Windows.DriverKit.BuildTools) that lets MSBuild
// recognize WindowsKernelModeDriver10.0/WindowsUserModeDriver10.0
// PlatformToolsets. It's not part of the manifest-driven default
// selection - unlike everything else it depends on, it's opt-in via
// --with-wdk, since the actual driver headers/libs come from a separate
// NuGet package download handled outside ExpandSelection entirely (see
// wdk.go and cmd/msvc-go-wine's runDownload).
WithWDK bool
}
func addIfWanted(opts *Options, flag TriState, pkg string) {
@@ -242,7 +250,7 @@ func ResolveSelection(opts *Options, idx Index) error {
addIfWanted(opts, opts.WithDevCmd, "Microsoft.VisualStudio.VC.vcvars")
addIfWanted(opts, opts.WithDevCmd, "Microsoft.VisualStudio.PackageGroup.VsDevCmd")
if opts.WithWDKInstallers != "" {
if opts.WithWDK {
opts.Package = append(opts.Package, "Component.Microsoft.Windows.DriverKit.BuildTools")
}