From d40756de311f62d81a8a02b1701eb809586a0c0f Mon Sep 17 00:00:00 2001 From: jinke18 Date: Mon, 29 Jul 2024 22:47:14 +0800 Subject: [PATCH 1/2] fixbug: for cases when WindowsSDKVersion variable is not available --- xmake/modules/detect/sdks/find_vstudio.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index 2ce2b44eb56..ca49d8d0731 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -186,6 +186,16 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt) 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 From ad6f76074557007d56b6755f387c9e60ea12a278 Mon Sep 17 00:00:00 2001 From: jinke18 Date: Tue, 30 Jul 2024 23:35:48 +0800 Subject: [PATCH 2/2] make pattern more strict --- xmake/modules/detect/sdks/find_vstudio.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index ca49d8d0731..0bc37420459 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -191,7 +191,7 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt) -- 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") + WindowsSDKVersion = string.match(WindowsSdkBinPath, "\\(%d+%.%d+)\\bin$") if WindowsSDKVersion then variables["WindowsSDKVersion"] = WindowsSDKVersion end