Conditionally output the PropertyGroup by previously capturing the result of the global configuration property function. If there's nothing to capture, don't emit.

This commit is contained in:
Emilio López 2018-04-13 00:29:49 +01:00
parent e4c2318de8
commit d528430f08
2 changed files with 46 additions and 4 deletions

View File

@ -296,10 +296,12 @@
]]
end
function suite.windowsTargetPlatformVersionConditional_on2015Default()
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">
@ -310,6 +312,34 @@
</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()
p.action.set("vs2015")
systemversion "8.1"
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>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</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

View File

@ -146,9 +146,21 @@
-- 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>')
-- Find out whether we're going to actually write a property out
local captured = p.capture( function()
p.push()
p.callArray(m.elements.globalsCondition, prj, cfg)
p.pop()
end)
-- If we do have something, create the entry, skip otherwise
if captured ~= '' then
m.propertyGroup(cfg, "Globals")
p.callArray(m.elements.globalsCondition, prj, cfg)
p.pop('</PropertyGroup>')
end
end
end