When configuration settings overlap, give precedence to the later settings

This commit is contained in:
Jason Perkins 2012-05-21 17:55:07 -04:00
parent bf65487655
commit e9a81b6f86
3 changed files with 33 additions and 7 deletions

View File

@ -424,11 +424,16 @@
function oven.mergetables(original, additions)
for _, item in ipairs(additions) do
-- prevent duplicates
if not original[item] then
original[item] = item
table.insert(original, item)
-- if the item is already in the list, remove it. This allows a
-- later configuration block (i.e. a project) to override the
-- ordering of values from an earlier block (i.e. a solution).
-- Could be a performance hit; have to wait and see.
if original[item] then
local i = table.indexof(original, item)
table.remove(original, i)
end
original[item] = item
table.insert(original, item)
end
return original
end

View File

@ -150,5 +150,5 @@
prj = project("MyProject")
defines { "PROJECT", "DUPLICATE" }
cfg = oven.bake(prj, sln, {"Debug"})
test.isequal("SOLUTION|DUPLICATE|PROJECT", table.concat(cfg.defines, "|"))
test.isequal("SOLUTION|PROJECT|DUPLICATE", table.concat(cfg.defines, "|"))
end

View File

@ -18,8 +18,11 @@
sln = solution("MySolution")
end
local function prepare()
local function prepare(buildcfgs)
project("MyProject")
if buildcfgs then
configurations ( buildcfgs )
end
prj = premake.solution.getproject_ng(sln, 1)
for cfg in premake5.project.eachconfig(prj, field) do
_p(2,'%s:%s', cfg.buildcfg or "", cfg.platform or "")
@ -148,3 +151,21 @@
]]
end
--
-- If there is overlap in the solution and project configuration lists,
-- the ordering at the project level should be maintained to avoid
-- unnecessarily dirtying the project file.
--
function suite.maintainsProjectOrdering_onSolutionOverlap()
configurations { "Debug", "Release" }
prepare { "Debug", "Development", "Profile", "Release" }
test.capture [[
Debug:
Development:
Profile:
Release:
]]
end