Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variable WindowsSDKVersion and the issues it causes #5421

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions xmake/modules/detect/sdks/find_vstudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
Expand All @@ -218,6 +200,28 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt)
variables["UCRTVersion"] = UCRTVersion
end

-- fix WindowsSDKVersion
local WindowsSDKVersion = variables["WindowsSDKVersion"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,这里也不能移到 ucrt 后面,ucrt 里面还依赖 WindowsSDKVersion 的修复呢

    if UCRTVersion and WindowsSDKVersion and UCRTVersion ~= WindowsSDKVersion and WindowsSDKVersion ~= "" then

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
Expand Down
2 changes: 1 addition & 1 deletion xmake/modules/detect/tools/find_rc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading