Function find [src]
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.
After finishing work, call free(allocator).
Prototype
pub fn find(allocator: std.mem.Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk
Parameters
allocator: std.mem.Allocator
arch: std.Target.Cpu.Arch
Possible Errors
Source
pub fn find(allocator: std.mem.Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {
if (builtin.os.tag != .windows) return error.NotFound;
//note(dimenus): If this key doesn't exist, neither the Win 8 SDK nor the Win 10 SDK is installed
const roots_key = RegistryWtf8.openKey(windows.HKEY_LOCAL_MACHINE, windows_kits_reg_key, .{ .wow64_32 = true }) catch |err| switch (err) {
error.KeyNotFound => return error.NotFound,
};
defer roots_key.closeKey();
const windows10sdk = Installation.find(allocator, roots_key, "KitsRoot10", "", "v10.0") catch |err| switch (err) {
error.InstallationNotFound => null,
error.PathTooLong => null,
error.VersionTooLong => null,
error.OutOfMemory => return error.OutOfMemory,
};
errdefer if (windows10sdk) |*w| w.free(allocator);
const windows81sdk = Installation.find(allocator, roots_key, "KitsRoot81", "winver", "v8.1") catch |err| switch (err) {
error.InstallationNotFound => null,
error.PathTooLong => null,
error.VersionTooLong => null,
error.OutOfMemory => return error.OutOfMemory,
};
errdefer if (windows81sdk) |*w| w.free(allocator);
const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(allocator, arch) catch |err| switch (err) {
error.MsvcLibDirNotFound => null,
error.OutOfMemory => return error.OutOfMemory,
};
errdefer allocator.free(msvc_lib_dir);
return .{
.windows10sdk = windows10sdk,
.windows81sdk = windows81sdk,
.msvc_lib_dir = msvc_lib_dir,
};
}