Find path and version of Windows 10 SDK and Windows 8.1 SDK, and find path to MSVC's lib/ directory.
Caller owns the result's fields.
Returns memory allocated by gpa
pub fn find(
gpa: Allocator,
io: Io,
arch: std.Target.Cpu.Arch,
environ_map: *const Environ.Map,
) error
pub fn find(
gpa: Allocator,
io: Io,
arch: std.Target.Cpu.Arch,
environ_map: *const Environ.Map,
) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {
if (builtin.os.tag != .windows) return error.NotFound;
var registry: Registry = .{};
defer registry.deinit();
// If this key doesn't exist, neither the Win 8 SDK nor the Win 10 SDK is installed
const roots_key = registry.openSoftwareKey(.{ .root = .local_machine, .wow64 = .wow64_32 }, L(windows_kits_reg_key)) catch |err| switch (err) {
error.KeyNotFound => return error.NotFound,
};
defer roots_key.close();
const windows10sdk = Installation.find(gpa, io, ®istry, roots_key, L("KitsRoot10"), "", L("v10.0")) catch |err| switch (err) {
error.InstallationNotFound => null,
error.PathTooLong => null,
error.VersionTooLong => null,
error.OutOfMemory => |e| return e,
};
errdefer if (windows10sdk) |*w| w.free(gpa);
const windows81sdk = Installation.find(gpa, io, ®istry, roots_key, L("KitsRoot81"), "winver", L("v8.1")) catch |err| switch (err) {
error.InstallationNotFound => null,
error.PathTooLong => null,
error.VersionTooLong => null,
error.OutOfMemory => |e| return e,
};
errdefer if (windows81sdk) |*w| w.free(gpa);
const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, ®istry, arch, environ_map) catch |err| switch (err) {
error.MsvcLibDirNotFound => null,
error.OutOfMemory => |e| return e,
};
errdefer gpa.free(msvc_lib_dir);
return .{
.windows10sdk = windows10sdk,
.windows81sdk = windows81sdk,
.msvc_lib_dir = msvc_lib_dir,
};
}