summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-02 23:18:40 +0800
committerruki <[email protected]>2022-03-02 23:18:40 +0800
commit6026401e3bc55e0b5974c0aa18aefe4d7135fe89 (patch)
tree435735b6009ece189bda720db95ceda0f69cb928 /xmake/core
parent0654d3ea2b7a9063adadd6b3a2c5fe2b0ff7883f (diff)
improve table.wrap
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/base/scopeinfo.lua10
-rw-r--r--xmake/core/base/table.lua10
2 files changed, 11 insertions, 9 deletions
diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua
index 8a69a9299..e3d9a8500 100644
--- a/xmake/core/base/scopeinfo.lua
+++ b/xmake/core/base/scopeinfo.lua
@@ -154,8 +154,14 @@ function _instance:_api_add_values(name, ...)
extra_config = nil
end
- -- expand values
- if not extra_config or extra_config.expand ~= false then
+ if extra_config and extra_config.expand == false then
+ for _, value in ipairs(values) do
+ if type(value) == "table" then
+ setmetatable(value, {})
+ end
+ end
+ else
+ -- expand values
values = table.join(table.unpack(values))
end
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 2cf617f3b..1c19f588d 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -165,13 +165,9 @@ end
-- copy the table to self
function table.copy2(self, copied)
-
- -- clear self first
+ assert(type(copied) == "table")
table.clear(self)
-
- -- copy it
- copied = copied or {}
- for k, v in pairs(table.wrap(copied)) do
+ for k, v in pairs(copied) do
self[k] = v
end
end
@@ -327,7 +323,7 @@ function table.wrap(object)
if nil == object then
return {}
end
- if type(object) ~= "table" then
+ if type(object) ~= "table" or getmetatable(object) then -- maybe object, we need wrap it too
return {object}
end
return object