From e9a81b6f8643181ba613b31543e5c0b8ff524323 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Mon, 21 May 2012 17:55:07 -0400 Subject: [PATCH] When configuration settings overlap, give precedence to the later settings --- src/project/oven.lua | 13 +++++++++---- tests/oven/test_lists.lua | 2 +- tests/project/test_eachconfig.lua | 25 +++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/project/oven.lua b/src/project/oven.lua index daba6fef..06cac68b 100755 --- a/src/project/oven.lua +++ b/src/project/oven.lua @@ -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 diff --git a/tests/oven/test_lists.lua b/tests/oven/test_lists.lua index 8eafcd36..45860a2b 100644 --- a/tests/oven/test_lists.lua +++ b/tests/oven/test_lists.lua @@ -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 diff --git a/tests/project/test_eachconfig.lua b/tests/project/test_eachconfig.lua index 4fc56f54..e3ff016d 100755 --- a/tests/project/test_eachconfig.lua +++ b/tests/project/test_eachconfig.lua @@ -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 "") @@ -147,4 +150,22 @@ Release: ]] 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 +