summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-02-17 20:35:09 +0800
committerruki <[email protected]>2019-02-18 10:09:01 +0800
commit8e9016cc9c2ff0ad97427d22c7ea6d7349e12e57 (patch)
tree27926b6932ccac0a1d383278c4d6bfdf3f960f76
parente9639a1d7ef67477ba12b740e38a5d5b4f774865 (diff)
fix interpreter for scope info
-rw-r--r--xmake/core/base/interpreter.lua59
-rw-r--r--xmake/core/project/template.lua4
2 files changed, 32 insertions, 31 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index b916a4aa3..fe957ef3c 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -486,8 +486,8 @@ function interpreter:_filter(values)
return results
end
--- get scope info
-function interpreter:_scopeinfo(scope_kind, scope, remove_repeat, enable_filter)
+-- handle scope data
+function interpreter:_handle(scope, remove_repeat, enable_filter)
-- check
assert(scope)
@@ -512,7 +512,7 @@ function interpreter:_scopeinfo(scope_kind, scope, remove_repeat, enable_filter)
-- update it
results[name] = values
end
- return scopeinfo.new(scope_kind, results)
+ return results
end
-- make results
@@ -529,58 +529,59 @@ function interpreter:_make(scope_kind, remove_repeat, enable_filter)
os.raise("the scope %s() is empty!", scope_kind)
end
- -- get the root results of the given scope kind, e.g. root.target
+ -- get the root scope info of the given scope kind, e.g. root.target
local results = {}
if scope_kind and scope_kind:startswith("root.") then
local root_scope = scopes._ROOT[scope_kind:sub(6)]
if root_scope then
- results = self:_scopeinfo(scope_kind, root_scope, remove_repeat, enable_filter)
+ results = self:_handle(root_scope, remove_repeat, enable_filter)
end
+ return scopeinfo.new(scope_kind, results)
- -- get the root results without scope kind
+ -- get the root scope info without scope kind
elseif scope_kind == "root" or scope_kind == nil then
local root_scope = scopes._ROOT["__rootkind"]
if root_scope then
- results = self:_scopeinfo(scope_kind, root_scope, remove_repeat, enable_filter)
+ results = self:_handle(root_scope, remove_repeat, enable_filter)
end
+ return scopeinfo.new(scope_kind, results)
-- get the results of the given scope kind
elseif scope_kind then
-- not this scope for kind?
local scope_for_kind = scopes[scope_kind]
- if not scope_for_kind then
- return {}
- end
+ if scope_for_kind then
- -- fetch the root values in root scope first
- interpreter._fetch_root_scope(scopes._ROOT)
+ -- fetch the root values in root scope first
+ interpreter._fetch_root_scope(scopes._ROOT)
- -- merge results
- for scope_name, scope in pairs(scope_for_kind) do
+ -- merge results
+ for scope_name, scope in pairs(scope_for_kind) do
- -- add scope values
- local scope_values = {}
- for name, values in pairs(scope) do
- if not name:startswith("__override_") then
- scope_values[name] = values
+ -- add scope values
+ local scope_values = {}
+ for name, values in pairs(scope) do
+ if not name:startswith("__override_") then
+ scope_values[name] = values
+ end
end
- end
- -- merge root values with the given scope name
- local scope_root = scopes._ROOT[scope_kind .. "@@" .. scope_name]
- if scope_root then
- for name, values in pairs(scope_root) do
- if not scope["__override_" .. name] then
- scope_values[name] = table.join(values, scope_values[name] or {})
+ -- merge root values with the given scope name
+ local scope_root = scopes._ROOT[scope_kind .. "@@" .. scope_name]
+ if scope_root then
+ for name, values in pairs(scope_root) do
+ if not scope["__override_" .. name] then
+ scope_values[name] = table.join(values, scope_values[name] or {})
+ end
end
end
- end
- -- add this scope
- results[scope_name] = self:_scopeinfo(scope_kind, scope_values, remove_repeat, enable_filter)
+ -- add this scope
+ results[scope_name] = scopeinfo.new(scope_kind, self:_handle(scope_values, remove_repeat, enable_filter))
+ end
end
end
return results
diff --git a/xmake/core/project/template.lua b/xmake/core/project/template.lua
index 2834091e3..9295f2335 100644
--- a/xmake/core/project/template.lua
+++ b/xmake/core/project/template.lua
@@ -158,10 +158,10 @@ function template.templates(language)
end
-- save template directory
- results._DIRECTORY = path.directory(templatefile)
+ results:set("_DIRECTORY", path.directory(templatefile))
-- insert to templates
- table.insert(templates, results)
+ table.insert(templates, results:info())
end
end