This commit is contained in:
jinke18 2024-10-29 12:08:25 +08:00 committed by GitHub
commit 0cff8d097f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 19 deletions

View File

@ -179,24 +179,6 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt)
end
end
-- fix WindowsSDKVersion
local WindowsSDKVersion = variables["WindowsSDKVersion"]
if WindowsSDKVersion then
WindowsSDKVersion = WindowsSDKVersion:gsub("\\", ""):trim()
if WindowsSDKVersion ~= "" then
variables["WindowsSDKVersion"] = WindowsSDKVersion
end
else
-- sometimes the variable `WindowsSDKVersion` is not available
-- then parse it from `WindowsSdkBinPath`, such as: `C:\\Program Files (x86)\\Windows Kits\\8.1\\bin`
local WindowsSdkBinPath = variables["WindowsSdkBinPath"]
if WindowsSdkBinPath then
WindowsSDKVersion = string.match(WindowsSdkBinPath, "\\(%d+%.%d+)\\bin$")
if WindowsSDKVersion then
variables["WindowsSDKVersion"] = WindowsSDKVersion
end
end
end
-- fix UCRTVersion
--
@ -218,6 +200,28 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt)
variables["UCRTVersion"] = UCRTVersion
end
-- fix WindowsSDKVersion
local WindowsSDKVersion = variables["WindowsSDKVersion"]
if WindowsSDKVersion then
WindowsSDKVersion = WindowsSDKVersion:gsub("\\", ""):trim()
if WindowsSDKVersion ~= "" then
variables["WindowsSDKVersion"] = WindowsSDKVersion
end
end
WindowsSDKVersion = variables["WindowsSDKVersion"]
if not WindowsSDKVersion or WindowsSDKVersion == "" then
-- sometimes the variable `WindowsSDKVersion` is not available
-- then parse it from `WindowsSdkDir`, such as: `C:\\Program Files (x86)\\Windows Kits\\8.1\\`
local WindowsSdkDir = variables["WindowsSdkDir"]
if WindowsSdkDir then
WindowsSDKVersion = string.match(WindowsSdkDir, "\\(%d+%.%d+)\\$")
if WindowsSDKVersion then
variables["WindowsSDKVersion"] = WindowsSDKVersion
end
end
end
-- convert path/lib/include to PATH/LIB/INCLUDE
variables.PATH = variables.path
variables.LIB = variables.lib

View File

@ -58,7 +58,7 @@ function main(opt)
-- e.g. C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64
--
local envs = opt.envs
if envs and envs.WindowsSdkDir and envs.WindowsSDKVersion then
if envs and envs.WindowsSdkDir and envs.WindowsSDKVersion and type(envs.WindowsSDKVersion) == "string" then
local toolchain = opt.toolchain
local arch = toolchain and toolchain:arch() or config.arch()
local bindir = path.join(envs.WindowsSdkDir, "bin", envs.WindowsSDKVersion, arch)