summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-10 00:52:47 +0800
committerruki <[email protected]>2024-01-10 00:52:47 +0800
commit41b348d3cc68845e121aa489c4b20fb06026cfe8 (patch)
treecb88d7d4cd12a282a41ff97c8faed3dbc8a32d15
parent95474ba466926b8a06bc0a610305d0ad3373c1d9 (diff)
fix test #4582
-rw-r--r--xmake/core/base/scopeinfo.lua5
-rw-r--r--xmake/core/base/table.lua10
-rw-r--r--xmake/core/project/target.lua8
3 files changed, 19 insertions, 4 deletions
diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua
index a7bbb4a19..abe1d10fb 100644
--- a/xmake/core/base/scopeinfo.lua
+++ b/xmake/core/base/scopeinfo.lua
@@ -748,7 +748,10 @@ end
-- clone a new instance from the current
function _instance:clone()
- return _instance.new(self:kind(), table.clone(self:info()), {interpreter = self:interpreter(), deduplicate = self._DEDUPLICATE, enable_filter = self._ENABLE_FILTER})
+ return _instance.new(self:kind(), table.clone(self:info(), 3), { -- @note we need do deep clone
+ interpreter = self:interpreter(),
+ deduplicate = self._DEDUPLICATE,
+ enable_filter = self._ENABLE_FILTER})
end
-- new a scope instance
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index f954596b8..fbef78a25 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -154,12 +154,16 @@ function table.append(array, ...)
end
-- clone table
-function table.clone(self)
+--
+-- @param depth e.g. shallow: 1, deep: -1
+--
+function table.clone(self, depth)
+ depth = depth or 1
local result = self
- if type(self) == "table" then
+ if type(self) == "table" and depth > 0 then
result = {}
for k, v in pairs(self) do
- result[k] = v
+ result[k] = table.clone(v, depth - 1)
end
end
return result
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 3ef33cedf..569502e51 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -280,6 +280,8 @@ function _instance:_invalidate(name)
if name == "files" then
self._SOURCEFILES = nil
self._FILESCONFIG = nil
+ self._OBJECTFILES = nil
+ self._SOURCEBATCHES = nil
elseif name == "deps" then
self._DEPS = nil
self._ORDERDEPS = nil
@@ -521,6 +523,12 @@ function _instance:clone()
if self._SOURCEFILES then
instance._SOURCEFILES = table.clone(self._SOURCEFILES)
end
+ if self._OBJECTFILES then
+ instance._OBJECTFILES = table.clone(self._OBJECTFILES)
+ end
+ if self._SOURCEBATCHES then
+ instance._SOURCEBATCHES = table.clone(self._SOURCEBATCHES, 3)
+ end
instance._LOADED = self._LOADED
instance._LOADED_AFTER = true
return instance