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

Conversation

jinke18
Copy link
Contributor

@jinke18 jinke18 commented Aug 1, 2024

  1. 在find_vstudio中有的时候调用vcvarsall.bat,得到的环境变量WindowsSDKVersion不存在或者为空
    这会影响生成的vs工程的配置,例如
xmake f --vs_sdkver=8.1
xmake project -k vs2015

所以需要修复WindowsSDKVersion的检测函数

我们可以从WindowsSdkDir变量中提取WindowsSDKVersion,这是我的第一个更改。

  1. 安装vs2015后,会存在window sdk8.1与windows sdk10共存的影响。可能是vs2015需要windows sdk 10中的UCRT环境?具体原因我不清楚,但是我的个人电脑和工作电脑都是这样,分别为win11和win10。

在更改1的基础上,这种情况会导致在提取WindowsSDKVersion后,后续的fix UCRTVersion代码执行不正确。它会将windows sdk10的lib环境更改为windows sdk8中的路径,这会导致c++在链接时找不到ucrt.lib。

所以我将fix UCRTVersion代码移到了fix WindowsSDKVersion前面。这是我的第二个更改。

  1. WindowsSDKVersion为空时,会引起find_rc内部的envs.WindowsSDKVersion为一个空table
    这导致xmake运行报错

具体引发envs.WindowsSDKVersion为一个空table的原因我定位不到,所以我简单判断了一下变量类型以保证xmake运行不报错。这是我的第三个更改。


Sometimes when calling 'vcvarsall. bat', the environment variable 'Windows SDK Version' obtained does not exist or is empty
This will affect the configuration of the generated VS project, for example

xmake f --vs_sdkver=8.1
xmake project -k vs2015

So it is necessary to fix the detection function of 'Windows SDK Version'

We can extract 'Windows SDK Version' from the 'Windows SDK' variable, which is my first change.

After installing VS2015, there will be an impact of coexistence between Windows SDK 8.1 and Windows SDK 10. Could it be that VS2015 requires the UCRT environment in Windows SDK 10? I'm not sure about the specific reason, but my personal computer and work computer are both like this, with Win11 and Win10 respectively.

On the basis of changing 1, this situation will result in incorrect execution of the subsequent fix UCRTVersion code after extracting 'Windows SDK Version'. It will change the lib environment of Windows SDK 10 to the path in Windows SDK 8, which will cause C++to not find ucrt.lib when linking.

So I moved the fix UCRTVersion code before fix Windows SDK Version. This is my second change.

When 'Windows SDK Version' is empty, it will cause envs inside find_rc Windows SDK Version is an empty table
This causes xmake to run with errors

I cannot locate the reason why Windows SDK Version is an empty table, so I simply checked the variable type to ensure that xmake runs without errors. This is my third change.

@waruqi
Copy link
Member

waruqi commented Aug 1, 2024

具体引发envs.WindowsSDKVersion为一个空table的原因我定位不到,所以我简单判断了一下变量类型以保证xmake运行不报错。这是我的第三个更改。

这个还是要定位下,不然没解决根本原因。。可以用 debug.traceback 看下栈,按理应该是 string 才对

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I can't find the specific reason why envs.WindowsSDKVersion is an empty table, so I simply judged the variable type to ensure that xmake does not report an error when running. This is my third change.

This still needs to be positioned, otherwise the root cause will not be solved. . You can use debug.traceback to look at the stack. It should be a string.

@@ -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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants