Skip to content

Commit

Permalink
Merge pull request #1048 from redorav/systemversion
Browse files Browse the repository at this point in the history
Add conditional behavior to global variables, add systemversion as first implementation
  • Loading branch information
samsinsane authored Apr 17, 2018
2 parents c802adf + 92e32dd commit 35194f6
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/vstudio/tests/vc2010/test_config_props.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,4 @@
<PlatformToolset>v100</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
]]
end
end
49 changes: 49 additions & 0 deletions modules/vstudio/tests/vc2010/test_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,52 @@
</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()
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

64 changes: 56 additions & 8 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,43 @@
m.ignoreWarnDuplicateFilename,
m.keyword,
m.projectName,
m.targetPlatformVersion,
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

-- 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


Expand Down Expand Up @@ -2473,21 +2501,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
Expand Down
2 changes: 1 addition & 1 deletion src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@

api.register {
name = "systemversion",
scope = "project",
scope = "config",
kind = "string",
}

Expand Down

0 comments on commit 35194f6

Please sign in to comment.