Move the systemversion back to globals, and create additional global entries based on configuration

This commit is contained in:
Emilio López 2018-04-12 21:09:31 +01:00
parent aa41dad734
commit e4c2318de8
3 changed files with 166 additions and 110 deletions

View File

@ -292,106 +292,4 @@
<PlatformToolset>v100</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
]]
end
--
-- VS 2015 adds the <WindowsTargetPlatformVersion> to allow developers
-- to target different versions of the Windows SDK.
--
function suite.windowsTargetPlatformVersionMissing_on2013Default()
p.action.set("vs2013")
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
]]
end
function suite.windowsTargetPlatformVersionMissing_on2013()
p.action.set("vs2013")
systemversion "10.0.10240.0"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
]]
end
function suite.windowsTargetPlatformVersionMissing_on2015Default()
p.action.set("vs2015")
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
]]
end
function suite.windowsTargetPlatformVersion_on2015()
p.action.set("vs2015")
systemversion "10.0.10240.0"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
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"
local oldRegistry = os["getWindowsRegistry"]
os["getWindowsRegistry"] = function (key) return "10.0.11111" end
prepare()
os["getWindowsRegistry"] = oldRegistry
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<WindowsTargetPlatformVersion>10.0.11111.0</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
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 Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
]]
end

View File

@ -192,3 +192,125 @@
</PropertyGroup>
]]
end
--
-- VS 2015 adds the <WindowsTargetPlatformVersion> to allow developers
-- to target different versions of the Windows SDK.
--
function suite.windowsTargetPlatformVersionMissing_on2013Default()
p.action.set("vs2013")
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.windowsTargetPlatformVersionMissing_on2013()
p.action.set("vs2013")
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
function suite.windowsTargetPlatformVersionMissing_on2015Default()
p.action.set("vs2015")
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_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>
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
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"
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>
</PropertyGroup>
]]
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.windowsTargetPlatformVersionConditional_on2015Default()
p.action.set("vs2015")
filter "Debug"
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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
end

View File

@ -126,14 +126,31 @@
m.ignoreWarnDuplicateFilename,
m.keyword,
m.projectName,
m.preferredToolArchitecture
m.preferredToolArchitecture,
m.targetPlatformVersionGlobal,
}
end
m.elements.globalsCondition = function(prj, cfg)
return {
m.targetPlatformVersionCondition,
}
end
function m.globals(prj)
-- Write out the project-level globals
m.propertyGroup(nil, "Globals")
p.callArray(m.elements.globals, prj)
p.pop('</PropertyGroup>')
-- Write out the configurable globals
for cfg in project.eachconfig(prj) do
m.propertyGroup(cfg, "Globals")
p.callArray(m.elements.globalsCondition, prj, cfg)
p.pop('</PropertyGroup>')
end
end
@ -160,7 +177,6 @@
m.wholeProgramOptimization,
m.nmakeOutDirs,
m.windowsSDKDesktopARMSupport,
m.targetPlatformVersion,
}
end
end
@ -2452,21 +2468,41 @@
m.element("TargetName", nil, "%s%s", cfg.buildtarget.prefix, cfg.buildtarget.basename)
end
function m.targetPlatformVersion(prj)
function m.targetPlatformVersion(cfgOrPrj)
if _ACTION >= "vs2015" then
local min = project.systemversion(prj)
local min = project.systemversion(cfgOrPrj)
-- 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
return min
end
end
function m.targetPlatformVersionGlobal(prj)
local min = m.targetPlatformVersion(prj)
if min ~= nil then
m.element("WindowsTargetPlatformVersion", nil, min)
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)
end
end
function m.preferredToolArchitecture(prj)
if _ACTION >= "vs2013" then