Merge deterministic configuration map fixes

- Store maps in a list, so the project script ordering will be maintained when applied
This commit is contained in:
Jason Perkins 2014-08-28 09:38:20 -04:00
commit 7e345ea1ac
4 changed files with 21 additions and 28 deletions

View File

@ -137,7 +137,7 @@
api.register {
name = "configmap",
scope = "config",
kind = "keyed:array:string",
kind = "list:keyed:array:string",
}
api.register {

View File

@ -380,17 +380,7 @@
local terms = table.deepcopy(ctx.terms)
terms.configurations = configurations
terms.platforms = platforms
-- assemble all matching configmaps, and then merge their keys
-- into the project's configmap
local map = configset.fetch(cset, premake.field.get("configmap"), terms)
if map then
for key, value in pairs(map) do
ctx.configmap[key] = value
end
end
ctx.configmap = configset.fetch(cset, premake.field.get("configmap"), terms)
end

View File

@ -510,19 +510,22 @@
return true
end
for pattern, replacements in pairs(prj.configmap or {}) do
if type(pattern) ~= "table" then
pattern = { pattern }
end
local maps = prj.configmap or {}
for mi = 1, #maps do
for pattern, replacements in pairs(maps[mi]) do
if type(pattern) ~= "table" then
pattern = { pattern }
end
-- does this pattern match any part of the pair? If so,
-- replace it with the corresponding values
for i = 1, #pairing do
if testpattern(pattern, pairing, i) then
if #pattern == 1 and #replacements == 1 then
pairing[i] = replacements[1]
else
pairing = { replacements[1], replacements[2] }
-- does this pattern match any part of the pair? If so,
-- replace it with the corresponding values
for i = 1, #pairing do
if testpattern(pattern, pairing, i) then
if #pattern == 1 and #replacements == 1 then
pairing[i] = replacements[1]
else
pairing = { replacements[1], replacements[2] }
end
end
end
end

View File

@ -210,7 +210,7 @@
configset.addblock(cset, { "windows" })
configset.store(cset, f, { Profile="Profile" })
local x = configset.fetch(cset, f, {"windows"})
test.istrue(x.Debug and x.Release and x.Profile)
test.istrue(x[1].Debug and x[1].Release and x[2].Profile)
end
@ -223,7 +223,7 @@
configset.store(cset, f, { Debug="Debug", Release="Release" })
configset.store(cset, f, { Profile="Profile" })
local x = configset.fetch(cset, f, {"windows"})
test.istrue(x.Debug and x.Release and x.Profile)
test.istrue(x[1].Debug and x[1].Release and x[2].Profile)
end
@ -237,7 +237,7 @@
configset.addblock(cset, { "windows" })
configset.store(cset, f, { Debug="Development" })
local x = configset.fetch(cset, f, {"windows"})
test.isequal({"Development"}, x.Debug)
test.isequal({"Development"}, x[2].Debug)
end
function suite.keyed_overwritesValues_onNonMergeAdd()
@ -245,5 +245,5 @@
configset.store(cset, f, { Debug="Debug" })
configset.store(cset, f, { Debug="Development" })
local x = configset.fetch(cset, f, {"windows"})
test.isequal({"Development"}, x.Debug)
test.isequal({"Development"}, x[2].Debug)
end