summaryrefslogtreecommitdiff
path: root/xmake/core/base/interpreter.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2019-04-08 23:10:27 +0800
committerruki <[email protected]>2019-04-08 13:02:46 +0800
commite27ac0a2f2bff920a5bdc8d8b542e29b59cc95f8 (patch)
tree149e8d1e9ac511a80ebc361cf32919db642db71a /xmake/core/base/interpreter.lua
parentfd990589bde78eb58393d7b19438c860b7db2d7c (diff)
simplify simple scope settings
Diffstat (limited to 'xmake/core/base/interpreter.lua')
-rw-r--r--xmake/core/base/interpreter.lua40
1 files changed, 12 insertions, 28 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 6f32225e9..0dc87e6da 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -915,36 +915,12 @@ function interpreter:api_register_scope(...)
assert(self)
-- define implementation
- local implementation = function (self, scopes, scope_kind, scope_name)
+ local implementation = function (self, scopes, scope_kind, scope_name, scope_info)
-- init scope for kind
local scope_for_kind = scopes[scope_kind] or {}
scopes[scope_kind] = scope_for_kind
- -- is dictionary mode?
- --
- -- .e.g
- -- target
- -- {
- -- name = "tbox"
- -- kind = "static",
- -- files =
- -- {
- -- "src/*.c",
- -- "*.cpp"
- -- }
- --}
- local scope_info = nil
- if type(scope_name) == "table" and scope_name["name"] ~= nil then
-
- -- get the scope info
- scope_info = scope_name
-
- -- get the scope name from the dictionary
- scope_name = scope_name["name"]
- end
-
-
-- enter the given scope
if scope_name ~= nil then
@@ -972,9 +948,13 @@ function interpreter:api_register_scope(...)
scopes._ROOT[scope_kind .. "@@" .. scope_name] = {}
end
- -- translate scope info
- if scope_info then
- scope_info["name"] = nil
+ -- with scope info? translate it
+ --
+ -- .e.g
+ -- option("text", {showmenu = true, default = true, description = "test option"})
+ -- target("tbox", {kind = "static", files = {"src/*.c", "*.cpp"}})
+ --
+ if scope_info and table.is_dictionary(scope_info) then
for name, values in pairs(scope_info) do
local apifunc = self:api_func("set_" .. name) or self:api_func("add_" .. name) or self:api_func("on_" .. name) or self:api_func(name)
if apifunc then
@@ -983,6 +963,10 @@ function interpreter:api_register_scope(...)
os.raise("unknown %s for %s(\"%s\")", name, scope_kind, scope_name)
end
end
+
+ -- enter root scope
+ scopes._CURRENT = nil
+ scopes._CURRENT_KIND = nil
end
end