From 6ffb48dd54c6d2d4e6168fac56943481d58e29c4 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 27 Sep 2023 23:53:21 +0800 Subject: add groups for interpreter --- xmake/core/base/scopeinfo.lua | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'xmake/core/base/scopeinfo.lua') diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua index d7215917f..8254ffc98 100644 --- a/xmake/core/base/scopeinfo.lua +++ b/xmake/core/base/scopeinfo.lua @@ -188,6 +188,66 @@ function _instance:_api_add_values(name, ...) end end +-- set the api groups to the scope info +function _instance:_api_set_groups(name, ...) + + -- get the scope info + local scope = self._INFO + + -- 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 + +-- add the api groups to the scope info +function _instance:_api_add_groups(name, ...) + + -- get the scope info + local scope = self._INFO + + -- 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) + scope[name] = self:_api_handle(name, scope[name]) + + -- 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 + -- set the api key-values to the scope info function _instance:_api_set_keyvalues(name, key, ...) -- cgit v1.3.1