Merge pull request #950 from LORgames/ssurtees/gmakeDefaultPlatform

Added defaultplatform support to gmake and gmake2 actions
This commit is contained in:
Tom van Dijck 2017-11-29 12:14:30 -08:00 committed by GitHub
commit 1279e6baf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 8 deletions

View File

@ -25,13 +25,27 @@
function make.defaultconfig(target) function make.defaultconfig(target)
-- find the right configuration iterator function for this object -- find the right configuration iterator function for this object
local eachconfig = iif(target.project, project.eachconfig, p.workspace.eachconfig) local eachconfig = iif(target.project, project.eachconfig, p.workspace.eachconfig)
local iter = eachconfig(target) local defaultconfig = nil
-- find the right default configuration platform, grab first configuration that matches
if target.defaultplatform then
for cfg in eachconfig(target) do
if cfg.platform == target.defaultplatform then
defaultconfig = cfg
break
end
end
end
-- grab the first configuration and write the block -- grab the first configuration and write the block
local cfg = iter() if not defaultconfig then
if cfg then local iter = eachconfig(target)
defaultconfig = iter()
end
if defaultconfig then
_p('ifndef config') _p('ifndef config')
_x(' config=%s', cfg.shortname) _x(' config=%s', defaultconfig.shortname)
_p('endif') _p('endif')
_p('') _p('')
end end

View File

@ -69,3 +69,19 @@ ifndef config
endif endif
]] ]]
end end
--
-- Verify handling of defaultplatform
--
function suite.defaultsToSpecifiedPlatform()
platforms { "Win32", "Win64" }
defaultplatform "Win64"
prepare()
test.capture [[
ifndef config
config=debug_win64
endif
]]
end

View File

@ -20,13 +20,27 @@
function gmake2.defaultconfig(target) function gmake2.defaultconfig(target)
-- find the right configuration iterator function for this object -- find the right configuration iterator function for this object
local eachconfig = iif(target.project, project.eachconfig, p.workspace.eachconfig) local eachconfig = iif(target.project, project.eachconfig, p.workspace.eachconfig)
local iter = eachconfig(target) local defaultconfig = nil
-- find the right default configuration platform, grab first configuration that matches
if target.defaultplatform then
for cfg in eachconfig(target) do
if cfg.platform == target.defaultplatform then
defaultconfig = cfg
break
end
end
end
-- grab the first configuration and write the block -- grab the first configuration and write the block
local cfg = iter() if not defaultconfig then
if cfg then local iter = eachconfig(target)
defaultconfig = iter()
end
if defaultconfig then
_p('ifndef config') _p('ifndef config')
_x(' config=%s', cfg.shortname) _x(' config=%s', defaultconfig.shortname)
_p('endif') _p('endif')
_p('') _p('')
end end