added a 'latest' systemversion for vs2017

forgot to add the ".0" suffix


added unit tests for systemversion "latest"
This commit is contained in:
Damien Courtois 2018-01-16 16:45:47 +01:00
parent e9dda518cf
commit d5089b5d9b
2 changed files with 64 additions and 3 deletions

View File

@ -253,3 +253,48 @@
</PropertyGroup> </PropertyGroup>
]] ]]
end end
--
-- Check that the "latest" systemversion works.
-- note: we override the os.getWindowsRegistry method for reliable tests.
--
function suite.windowsTargetPlatformVersionLatest_on2017()
p.action.set("vs2017")
systemversion "latest"
prepare()
local oldRegistry = os.getWindowsRegistry
os.getWindowsRegistry = function (key)
return "10.0.11111"
end
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>
</PropertyGroup>
]]
-- restore the registry function
os.getWindowsRegistry = oldRegistry
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 "10.0.10240.0"
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
</PropertyGroup>
]]
end

View File

@ -2356,9 +2356,16 @@
function m.targetPlatformVersion(prj) function m.targetPlatformVersion(prj)
local min = project.systemversion(prj) if _ACTION >= "vs2015" then
if min ~= nil and _ACTION >= "vs2015" then local min = project.systemversion(prj)
m.element("WindowsTargetPlatformVersion", nil, min) -- handle special "latest" version
if min == "latest" then
-- vs2015 and lower can't build against SDK 10
min = iif(_ACTION >= "vs2017", m.latestSDK10Version(), nil)
end
if min ~= nil then
m.element("WindowsTargetPlatformVersion", nil, min)
end
end end
end end
@ -2484,6 +2491,15 @@
return m.conditionFromConfigText(vstudio.projectConfig(cfg)) return m.conditionFromConfigText(vstudio.projectConfig(cfg))
end end
--
-- Get the latest installed SDK 10 version from the registry.
--
function m.latestSDK10Version()
local arch = iif(os.is64bit(), "\\WOW6432Node\\", "\\")
local version = os.getWindowsRegistry("HKLM:SOFTWARE" .. arch .."Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion")
return iif(version ~= nil, version .. ".0", nil)
end
-- --