Added defaultplatform support to gmake and gmake2 actions

This commit is contained in:
Sam Surtees 2017-11-24 00:07:26 +10:00
parent 96a020c532
commit de03bb3249
3 changed files with 52 additions and 8 deletions

View File

@ -25,13 +25,27 @@
function make.defaultconfig(target)
-- find the right configuration iterator function for this object
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
local cfg = iter()
if cfg then
if not defaultconfig then
local iter = eachconfig(target)
defaultconfig = iter()
end
if defaultconfig then
_p('ifndef config')
_x(' config=%s', cfg.shortname)
_x(' config=%s', defaultconfig.shortname)
_p('endif')
_p('')
end

View File

@ -69,3 +69,19 @@ ifndef config
endif
]]
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)
-- find the right configuration iterator function for this object
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
local cfg = iter()
if cfg then
if not defaultconfig then
local iter = eachconfig(target)
defaultconfig = iter()
end
if defaultconfig then
_p('ifndef config')
_x(' config=%s', cfg.shortname)
_x(' config=%s', defaultconfig.shortname)
_p('endif')
_p('')
end