variable WindowsSDKVersion
and the issues it causes
#5421
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
vcvarsall.bat
,得到的环境变量WindowsSDKVersion
不存在或者为空这会影响生成的vs工程的配置,例如
所以需要修复
WindowsSDKVersion
的检测函数我们可以从
WindowsSdkDir
变量中提取WindowsSDKVersion
,这是我的第一个更改。在更改1的基础上,这种情况会导致在提取
WindowsSDKVersion
后,后续的fix UCRTVersion代码执行不正确。它会将windows sdk10的lib环境更改为windows sdk8中的路径,这会导致c++在链接时找不到ucrt.lib。所以我将fix UCRTVersion代码移到了fix WindowsSDKVersion前面。这是我的第二个更改。
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
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.