Merge pull request #1424 from starkos/fix/vs2017-system-latest
Fix systemversion("latest") on VS2017
This commit is contained in:
commit
07ab4ccee4
@ -44,6 +44,7 @@
|
||||
test.capture [[
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
|
||||
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
|
||||
<Keyword>Android</Keyword>
|
||||
<RootNamespace>MyProject</RootNamespace>
|
||||
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
|
||||
|
@ -254,31 +254,43 @@
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Check that the "latest" systemversion works.
|
||||
-- note: we override the os.getWindowsRegistry method for reliable tests.
|
||||
--
|
||||
---
|
||||
-- Check handling of systemversion("latest")
|
||||
---
|
||||
|
||||
function suite.windowsTargetPlatformVersionLatest_on2017()
|
||||
function suite.windowsTargetPlatformVersion_latest_on2015()
|
||||
p.action.set("vs2015")
|
||||
systemversion "latest"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
|
||||
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>MyProject</RootNamespace>
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.windowsTargetPlatformVersion_latest_on2017()
|
||||
p.action.set("vs2017")
|
||||
systemversion "latest"
|
||||
local oldRegistry = os["getWindowsRegistry"]
|
||||
os["getWindowsRegistry"] = function (key) return "10.0.11111" end
|
||||
prepare()
|
||||
os["getWindowsRegistry"] = oldRegistry
|
||||
test.capture [[
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
|
||||
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>MyProject</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.11111.0</WindowsTargetPlatformVersion>
|
||||
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.windowsTargetPlatformVersionLatest_on2019()
|
||||
|
||||
function suite.windowsTargetPlatformVersion_latest_on2019()
|
||||
p.action.set("vs2019")
|
||||
systemversion "latest"
|
||||
prepare()
|
||||
@ -293,49 +305,12 @@
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Check that the "latest" systemversion will not add <WindowsTargetPlatformVersion>
|
||||
-- when the action is less than 2017
|
||||
--
|
||||
|
||||
function suite.windowsTargetPlatformVersionLatest_on2015()
|
||||
p.action.set("vs2015")
|
||||
systemversion "latest"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
|
||||
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>MyProject</RootNamespace>
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.windowsTargetPlatformVersionMultipleConditional_on2015Default()
|
||||
p.action.set("vs2015")
|
||||
filter "Debug"
|
||||
systemversion "10.0.10240.0"
|
||||
filter "Release"
|
||||
systemversion "10.0.10240.1"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
|
||||
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>MyProject</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
|
||||
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Globals">
|
||||
<WindowsTargetPlatformVersion>10.0.10240.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.windowsTargetPlatformVersionGlobalMultipleConditional_on2015Default()
|
||||
---
|
||||
-- Check handling of per-configuration systemversion
|
||||
---
|
||||
|
||||
function suite.windowsTargetPlatformVersion_perConfig_on2015()
|
||||
p.action.set("vs2015")
|
||||
systemversion "8.1"
|
||||
filter "Debug"
|
||||
@ -359,4 +334,31 @@
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
|
||||
function suite.windowsTargetPlatformVersion_perConfig_on2017()
|
||||
p.action.set("vs2017")
|
||||
systemversion "8.1"
|
||||
filter "Debug"
|
||||
systemversion "latest"
|
||||
filter "Release"
|
||||
systemversion "10.0.10240.1"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
|
||||
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>MyProject</RootNamespace>
|
||||
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
|
||||
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Globals">
|
||||
<WindowsTargetPlatformVersion>10.0.10240.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
@ -131,13 +131,14 @@
|
||||
m.keyword,
|
||||
m.projectName,
|
||||
m.preferredToolArchitecture,
|
||||
m.targetPlatformVersionGlobal,
|
||||
m.latestTargetPlatformVersion,
|
||||
m.windowsTargetPlatformVersion,
|
||||
}
|
||||
end
|
||||
|
||||
m.elements.globalsCondition = function(prj, cfg)
|
||||
return {
|
||||
m.targetPlatformVersionCondition,
|
||||
m.windowsTargetPlatformVersion,
|
||||
}
|
||||
end
|
||||
|
||||
@ -2580,43 +2581,43 @@
|
||||
end
|
||||
|
||||
|
||||
function m.targetPlatformVersion(cfgOrPrj)
|
||||
function m.latestTargetPlatformVersion(prj)
|
||||
-- See https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html
|
||||
if _ACTION == "vs2017" then
|
||||
m.element("LatestTargetPlatformVersion", nil, "$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))")
|
||||
end
|
||||
end
|
||||
|
||||
if _ACTION >= "vs2015" then
|
||||
local min = project.systemversion(cfgOrPrj)
|
||||
-- handle special "latest" version
|
||||
if min == "latest" then
|
||||
-- vs2015 and lower can't build against SDK 10
|
||||
-- vs2019 allows for automatic assignment to latest
|
||||
-- Windows 10 sdk if you set to "10.0"
|
||||
if _ACTION >= "vs2019" then
|
||||
min = "10.0"
|
||||
else
|
||||
min = iif(_ACTION == "vs2017", m.latestSDK10Version(), nil)
|
||||
end
|
||||
|
||||
function m.windowsTargetPlatformVersion(prj, cfg)
|
||||
if _ACTION < "vs2015" then
|
||||
return
|
||||
end
|
||||
|
||||
local target = cfg or prj
|
||||
local version = project.systemversion(target)
|
||||
|
||||
-- if this is a config, only emit if different from project
|
||||
if cfg then
|
||||
local prjVersion = project.systemversion(prj)
|
||||
if not prjVersion or version == prjVersion then
|
||||
return
|
||||
end
|
||||
|
||||
return min
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function m.targetPlatformVersionGlobal(prj)
|
||||
local min = m.targetPlatformVersion(prj)
|
||||
if min ~= nil then
|
||||
m.element("WindowsTargetPlatformVersion", nil, min)
|
||||
-- See https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html
|
||||
if version == "latest" then
|
||||
if _ACTION == "vs2015" then
|
||||
version = nil -- SDK v10 is not supported by VS2015
|
||||
elseif _ACTION == "vs2017" then
|
||||
version = "$(LatestTargetPlatformVersion)"
|
||||
else
|
||||
version = "10.0"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function m.targetPlatformVersionCondition(prj, cfg)
|
||||
|
||||
local cfgPlatformVersion = m.targetPlatformVersion(cfg)
|
||||
local prjPlatformVersion = m.targetPlatformVersion(prj)
|
||||
|
||||
if cfgPlatformVersion ~= nil and cfgPlatformVersion ~= prjPlatformVersion then
|
||||
m.element("WindowsTargetPlatformVersion", nil, cfgPlatformVersion)
|
||||
if version then
|
||||
m.element("WindowsTargetPlatformVersion", nil, version)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user