summaryrefslogtreecommitdiff
path: root/xmake/core/base/interpreter.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-06 22:51:24 +0800
committerruki <[email protected]>2025-01-06 18:12:52 +0800
commit36a07b48ce45afc4f91aa0120aa419eb9b5943d1 (patch)
tree3497bda5d4b801dc1734528d89017f59eda5d740 /xmake/core/base/interpreter.lua
parent4b35267f3de12f93234467e84b08f5c8b7aef281 (diff)
add root tests
Diffstat (limited to 'xmake/core/base/interpreter.lua')
-rw-r--r--xmake/core/base/interpreter.lua24
1 files changed, 19 insertions, 5 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index ccf49f1ec..4652dfd36 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -239,11 +239,16 @@ function interpreter:_api_register_xxx_values(scope_kind, action, apifunc, ...)
local implementation = function (self, scopes, apiname, ...)
-- init root scopes
+ local namespace = self._NAMESPACE_STR
scopes._ROOT = scopes._ROOT or {}
-- init current root scope
- local root = scopes._ROOT[scope_kind] or {}
- scopes._ROOT[scope_kind] = root
+ local rootkey = scope_kind
+ if namespace then
+ rootkey = scope_kind .. "@@" .. namespace .. "::"
+ end
+ local root = scopes._ROOT[rootkey] or {}
+ scopes._ROOT[rootkey] = root
-- clear the current scope if be not belong to the current scope kind
if scopes._CURRENT and scopes._CURRENT_KIND ~= scope_kind then
@@ -926,7 +931,7 @@ end
-- {
-- scope_kind1
-- {
--- "scope_name1"
+-- "namespace1::scope_name1"
-- {
--
-- }
@@ -934,7 +939,7 @@ end
--
-- scope_kind2
-- {
--- "scope_name1"
+-- "namespace1::namespace2::scope_name1"
-- {
--
-- }
@@ -955,6 +960,9 @@ function interpreter:api_register_scope(...)
local scope_name = scope_args[1]
local scope_info = scope_args[2]
local namespace = self._NAMESPACE_STR
+ if scope_name ~= nil and namespace then
+ scope_name = namespace .. "::" .. scope_name
+ end
-- check invalid scope name, @see https://github.com/xmake-io/xmake/issues/4547
if scope_args.n > 0 and type(scope_name) ~= "string" then
@@ -995,6 +1003,8 @@ function interpreter:api_register_scope(...)
scopes._ROOT = scopes._ROOT or {}
if scope_name ~= nil then
scopes._ROOT[scope_kind .. "@@" .. scope_name] = {}
+ elseif namespace then
+ scopes._ROOT[scope_kind .. "@@" .. namespace .. "::"] = {}
end
-- with scope info? translate it
@@ -1061,13 +1071,17 @@ end
-- {
-- scope_kind
-- {
+-- name1 = {"value3"}
+-- }
+-- scope_kind@@namespace::
+-- {
-- name2 = {"value3"}
-- }
-- }
--
-- scope_kind
-- {
--- "scope_name" <-- _SCOPES._CURRENT
+-- "namespace::scope_name" <-- _SCOPES._CURRENT
-- {
-- name1 = {"value1"}
-- name2 = {"value1", "value2", ...}