summaryrefslogtreecommitdiff
path: root/xmake/core/base
diff options
context:
space:
mode:
authorruki <[email protected]>2017-08-10 09:05:03 +0800
committerruki <[email protected]>2017-08-10 09:05:03 +0800
commit3a1d05fd170148a6ae6342bda2e077431bb7570a (patch)
treed1b16fde057219e6934e45d0c103db75ee695f88 /xmake/core/base
parent467e97b99dc9b16dd3db3a5ad743ea954185d497 (diff)
improve add_files and compile speed
Diffstat (limited to 'xmake/core/base')
-rw-r--r--xmake/core/base/interpreter.lua84
1 files changed, 74 insertions, 10 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 28d4994c7..d8831154f 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -1068,12 +1068,27 @@ function interpreter:api_register_set_values(scope_kind, ...)
-- define implementation
local implementation = function (self, scope, name, ...)
+
+ -- get extra config
local values = {...}
- if table.is_dictionary(values[#values]) then
- scope["__extra_" .. name] = values[#values] -- save extra info
+ local extra_config = values[#values]
+ if table.is_dictionary(extra_config) then
table.remove(values)
+ else
+ extra_config = nil
end
+
+ -- save values
scope[name] = values
+
+ -- save extra config
+ if extra_config then
+ scope["__extra_" .. name] = scope["__extra_" .. name] or {}
+ local extrascope = scope["__extra_" .. name]
+ for _, value in ipairs(values) do
+ extrascope[value] = extra_config
+ end
+ end
end
-- register implementation
@@ -1088,12 +1103,27 @@ function interpreter:api_register_add_values(scope_kind, ...)
-- define implementation
local implementation = function (self, scope, name, ...)
+
+ -- get extra config
local values = {...}
- if table.is_dictionary(values[#values]) then
- scope["__extra_" .. name] = table.join2(scope["__extra_" .. name] or {}, values[#values]) -- save extra info
+ local extra_config = values[#values]
+ if table.is_dictionary(extra_config) then
table.remove(values)
+ else
+ extra_config = nil
end
+
+ -- save values
scope[name] = table.join2(scope[name] or {}, values)
+
+ -- save extra config
+ if extra_config then
+ scope["__extra_" .. name] = scope["__extra_" .. name] or {}
+ local extrascope = scope["__extra_" .. name]
+ for _, value in ipairs(values) do
+ extrascope[value] = extra_config
+ end
+ end
end
-- register implementation
@@ -1261,12 +1291,29 @@ function interpreter:api_register_set_pathes(scope_kind, ...)
-- define implementation
local implementation = function (self, scope, name, ...)
+ -- get extra config
local values = {...}
- if table.is_dictionary(values[#values]) then
- scope["__extra_" .. name] = values[#values] -- save extra info
+ local extra_config = values[#values]
+ if table.is_dictionary(extra_config) then
table.remove(values)
+ else
+ extra_config = nil
+ end
+
+ -- translate pathes
+ local pathes = self:_api_translate_pathes(values)
+
+ -- save values
+ scope[name] = pathes
+
+ -- save extra config
+ if extra_config then
+ scope["__extra_" .. name] = scope["__extra_" .. name] or {}
+ local extrascope = scope["__extra_" .. name]
+ for _, value in ipairs(pathes) do
+ extrascope[value] = extra_config
+ end
end
- scope[name] = self:_api_translate_pathes(values)
end
-- register implementation
@@ -1282,12 +1329,29 @@ function interpreter:api_register_add_pathes(scope_kind, ...)
-- define implementation
local implementation = function (self, scope, name, ...)
+ -- get extra config
local values = {...}
- if table.is_dictionary(values[#values]) then
- scope["__extra_" .. name] = table.join2(scope["__extra_" .. name] or {}, values[#values]) -- save extra info
+ local extra_config = values[#values]
+ if table.is_dictionary(extra_config) then
table.remove(values)
+ else
+ extra_config = nil
+ end
+
+ -- translate pathes
+ local pathes = self:_api_translate_pathes(values)
+
+ -- save values
+ scope[name] = table.join2(scope[name] or {}, pathes)
+
+ -- save extra config
+ if extra_config then
+ scope["__extra_" .. name] = scope["__extra_" .. name] or {}
+ local extrascope = scope["__extra_" .. name]
+ for _, value in ipairs(pathes) do
+ extrascope[value] = extra_config
+ end
end
- scope[name] = table.join2(scope[name] or {}, self:_api_translate_pathes(values))
end
-- register implementation