summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-01-21 12:48:07 +0800
committerruki <[email protected]>2016-02-15 19:10:25 +0800
commit1242c86015675ef739347efd3af67c91c4067867 (patch)
tree909ebc86d1ffa4d1986ff819dc1691db5654f9d0
parenta187eafee62e611520b73b4942565e70747059e5 (diff)
remove repeat values
-rw-r--r--tests/interpreter/tests.lua2
-rw-r--r--xmake/core/base/interpreter.lua29
2 files changed, 25 insertions, 6 deletions
diff --git a/tests/interpreter/tests.lua b/tests/interpreter/tests.lua
index a01d010f3..dc659edd1 100644
--- a/tests/interpreter/tests.lua
+++ b/tests/interpreter/tests.lua
@@ -111,7 +111,7 @@ function tests.main(self, file)
-- load targets
- local targets, errors = interp:load(file[1], "target")
+ local targets, errors = interp:load(file[1], "target", true)
if not targets then
print(errors)
return false
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 98f3c354f..cac14895c 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -240,7 +240,7 @@ function interpreter._clear(self)
end
-- make results
-function interpreter._make(self, scope_kind)
+function interpreter._make(self, scope_kind, remove_repeat)
-- check
assert(self and self._PRIVATE and scope_kind)
@@ -287,8 +287,27 @@ function interpreter._make(self, scope_kind)
end
end
+ -- remove repeat values and unwrap it
+ local result_values = {}
+ for name, values in pairs(scope_values) do
+
+ -- remove repeat first
+ if remove_repeat then
+ values = utils.unique(values)
+ end
+
+ -- filter values
+ -- TODO
+
+ -- unwrap it if be only one
+ values = utils.unwrap(values)
+
+ -- update it
+ result_values[name] = values
+ end
+
-- add this scope
- results[scope_name] = scope_values
+ results[scope_name] = result_values
end
-- ok?
@@ -322,8 +341,8 @@ function interpreter.init(rootdir)
return interp
end
--- load interpreter
-function interpreter.load(self, file, scope_kind)
+-- load results
+function interpreter.load(self, file, scope_kind, remove_repeat)
-- check
assert(self and self._PUBLIC and self._PRIVATE and file and scope_kind)
@@ -353,7 +372,7 @@ function interpreter.load(self, file, scope_kind)
end
-- make results
- return self:_make(scope_kind)
+ return self:_make(scope_kind, remove_repeat)
end
-- get mtimes