diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 55647471..af7583e8 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -120,7 +120,7 @@ api.register { name = "configmap", scope = "config", - kind = "keyed:table", + kind = "keyed:array:string", } api.register { diff --git a/src/base/api.lua b/src/base/api.lua index c832eaf5..9218d318 100755 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -267,7 +267,7 @@ local status, err = configset.store(target, field, value) if err then - error(result, 3) + error(err, 3) end end @@ -415,6 +415,38 @@ +-- +-- Arrays are integer indexed tables; unlike lists, a new array value +-- will replace the old one, rather than merging both. +-- + + premake.field.kind("array", { + store = function(field, current, value, processor) + if type(value) ~= "table" then + value = { value } + end + + for i, item in ipairs(value) do + value[i] = processor(field, nil, value[i]) + end + + return value + end, + compare = function(field, a, b, processor) + if #a ~= #b then + return false + end + for i = 1, #a do + if not processor(field, a[i], b[i]) then + return false + end + end + return true + end + }) + + + -- -- Directory data kind; performs wildcard directory searches, converts -- results to absolute paths. @@ -652,7 +684,7 @@ premake.field.kind("string", { store = function(field, current, value, processor) if type(value) == "table" then - error({ msg="expected string; got table" }) + error { msg="expected string; got table" } end if value ~= nil then