Added buildrule() to the API
This commit is contained in:
parent
198a9896fb
commit
399739d012
@ -45,6 +45,12 @@
|
||||
scope = "config",
|
||||
},
|
||||
|
||||
buildrule =
|
||||
{
|
||||
kind = "object",
|
||||
scope = "config",
|
||||
},
|
||||
|
||||
configurations =
|
||||
{
|
||||
kind = "list",
|
||||
@ -506,6 +512,24 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Sets the value of an object field on the provided container.
|
||||
--
|
||||
-- @param obj
|
||||
-- The object containing the field to be set.
|
||||
-- @param fieldname
|
||||
-- The name of the object field to be set.
|
||||
-- @param value
|
||||
-- The new object value for the field.
|
||||
-- @return
|
||||
-- The new value of the field.
|
||||
--
|
||||
|
||||
function premake.setobject(obj, fieldname, value)
|
||||
obj[fieldname] = value
|
||||
return value
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Adds values to an array field.
|
||||
@ -625,7 +649,7 @@
|
||||
return field
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Set a new value for a string field of a solution/project/configuration. `ctype`
|
||||
-- specifies the container type (see premake.getobject) for the field.
|
||||
@ -689,6 +713,8 @@
|
||||
return premake.setfilearray(container, name, value)
|
||||
elseif kind == "keyvalue" or kind == "keypath" then
|
||||
return premake.setkeyvalue(scope, name, value)
|
||||
elseif kind == "object" then
|
||||
return premake.setobject(container, name, value)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -90,7 +90,6 @@
|
||||
local configurations = {}
|
||||
local platforms = {}
|
||||
|
||||
-- for _, prj in ipairs(sln.projects) do
|
||||
for prj in solution.eachproject_ng(sln) do
|
||||
-- iterate build configs and add missing
|
||||
if prj.configurations then
|
||||
|
@ -188,6 +188,8 @@
|
||||
for key, keyvalue in pairs(value) do
|
||||
cfg[name][key] = oven.mergetables(cfg[name][key] or {}, keyvalue)
|
||||
end
|
||||
elseif field.kind == "object" then
|
||||
cfg[name] = value
|
||||
elseif type(value) == "table" then
|
||||
cfg[name] = oven.mergetables(cfg[name] or {}, value)
|
||||
else
|
||||
|
@ -234,6 +234,25 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Object values should be merged into baked results.
|
||||
--
|
||||
|
||||
function suite.objectValuesAreMerged()
|
||||
buildrule { description="test" }
|
||||
cfg = oven.bake(sln)
|
||||
test.isequal("test", cfg.buildrule.description)
|
||||
end
|
||||
|
||||
function suite.objectValueOverwritten_onMultipleValues()
|
||||
buildrule { description="sln" }
|
||||
prj = project("MyProject")
|
||||
buildrule { description="prj" }
|
||||
cfg = oven.bake(prj, {"Debug"})
|
||||
test.isequal("prj", cfg.buildrule.description)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test pulling "project global" values, which are associated with
|
||||
-- all configurations in the project.
|
||||
|
Reference in New Issue
Block a user