summaryrefslogtreecommitdiff
path: root/xmake/core/base/interpreter.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-27 23:53:21 +0800
committerruki <[email protected]>2023-09-27 23:53:21 +0800
commit6ffb48dd54c6d2d4e6168fac56943481d58e29c4 (patch)
tree7a463c358d683d9a9ad047ed0e1a052c488ee8fa /xmake/core/base/interpreter.lua
parentd53b673e631873b21b07665498a142cc31059c81 (diff)
add groups for interpreter
Diffstat (limited to 'xmake/core/base/interpreter.lua')
-rw-r--r--xmake/core/base/interpreter.lua67
1 files changed, 67 insertions, 0 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 8a64aaa58..ab25e927e 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -1214,6 +1214,73 @@ function interpreter:api_register_set_keyvalues(scope_kind, ...)
self:_api_register_xxx_values(scope_kind, "set", implementation, ...)
end
+-- register api for set_groups
+function interpreter:api_register_set_groups(scope_kind, ...)
+
+ -- define implementation
+ local implementation = function (self, scope, name, ...)
+
+ -- get extra config
+ local values = {...}
+ local extra_config = values[#values]
+ if table.is_dictionary(extra_config) then
+ table.remove(values)
+ else
+ extra_config = nil
+ end
+
+ -- expand values
+ values = table.join(table.unpack(values))
+
+ -- save values
+ scope[name] = values
+
+ -- save extra config
+ if extra_config and extra_config.name then
+ scope["__extra_" .. name] = scope["__extra_" .. name] or {}
+ local extrascope = scope["__extra_" .. name]
+ extrascope[extra_config.name] = extra_config
+ end
+ end
+
+ -- register implementation
+ self:_api_register_xxx_values(scope_kind, "set", implementation, ...)
+end
+
+-- register api for add_groups
+function interpreter:api_register_add_groups(scope_kind, ...)
+
+ -- define implementation
+ local implementation = function (self, scope, name, ...)
+
+ -- get extra config
+ local values = {...}
+ local extra_config = values[#values]
+ if table.is_dictionary(extra_config) then
+ table.remove(values)
+ else
+ extra_config = nil
+ end
+
+ -- expand values
+ values = table.join(table.unpack(values))
+
+ -- save values
+ scope[name] = scope[name] or {}
+ table.insert(scope[name], values)
+
+ -- save extra config
+ if extra_config and extra_config.name then
+ scope["__extra_" .. name] = scope["__extra_" .. name] or {}
+ local extrascope = scope["__extra_" .. name]
+ extrascope[extra_config.name] = extra_config
+ end
+ end
+
+ -- register implementation
+ self:_api_register_xxx_values(scope_kind, "add", implementation, ...)
+end
+
-- register api for add_keyvalues
--
-- interp:api_register_add_keyvalues("scope_kind", "name1", "name2", ...)