summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-15 22:36:48 +0800
committerruki <[email protected]>2024-03-15 22:36:48 +0800
commit033d921aa7c7e9c54b05f62943359dee3a0eee04 (patch)
tree93073bcd6429100ca72c2736bfea7742fa50dc48
parentfa824cccb3765035444015e0dc979cbd4fda0348 (diff)
fix fileconfigs
-rw-r--r--xmake/core/project/target.lua35
1 files changed, 28 insertions, 7 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 3e97d85d3..476db548e 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -235,13 +235,15 @@ function _instance:_invalidate(name)
self._SOURCEFILES = nil
self._OBJECTFILES = nil
self._SOURCEBATCHES = nil
- self:_memcache():set("filesconfig", nil)
self:_update_filerules()
elseif name == "deps" then
self._DEPS = nil
self._ORDERDEPS = nil
self._INHERITDEPS = nil
end
+ if self._FILESCONFIG then
+ self._FILESCONFIG[name] = nil
+ end
end
-- build deps
@@ -1689,7 +1691,19 @@ end
function _instance:fileconfig(sourcefile, opt)
opt = opt or {}
local filetype = opt.filetype or "files"
- local filesconfig = self:_memcache():get2("filesconfig", filetype)
+
+ -- get configs from user, e.g. target:fileconfig_set/add
+ -- it has contained all original configs
+ if self._FILESCONFIG_USER then
+ local filesconfig = self._FILESCONFIG_USER[filetype]
+ if filesconfig and filesconfig[sourcefile] then
+ return filesconfig[sourcefile]
+ end
+ end
+
+ -- get orignal configs from `add_xxxfiles()`
+ self._FILESCONFIG = self._FILESCONFIG or {}
+ local filesconfig = self._FILESCONFIG[filetype]
if not filesconfig then
filesconfig = {}
for filepath, fileconfig in pairs(table.wrap(self:extraconf(filetype))) do
@@ -1708,7 +1722,7 @@ function _instance:fileconfig(sourcefile, opt)
end
end
end
- self:_memcache():set2("filesconfig", filetype, filesconfig)
+ self._FILESCONFIG[filetype] = filesconfig
end
return filesconfig[sourcefile]
end
@@ -1716,11 +1730,12 @@ end
-- set the config info to the given source file
function _instance:fileconfig_set(sourcefile, info, opt)
opt = opt or {}
+ self._FILESCONFIG_USER = self._FILESCONFIG_USER or {}
local filetype = opt.filetype or "files"
- local filesconfig = self:_memcache():get2("filesconfig", filetype)
+ local filesconfig = self._FILESCONFIG_USER[filetype]
if not filesconfig then
filesconfig = {}
- self:_memcache():set2("filesconfig", filetype, filesconfig)
+ self._FILESCONFIG_USER[filetype] = filesconfig
end
filesconfig[sourcefile] = info
end
@@ -1728,14 +1743,20 @@ end
-- add the config info to the given source file
function _instance:fileconfig_add(sourcefile, info, opt)
opt = opt or {}
+ self._FILESCONFIG_USER = self._FILESCONFIG_USER or {}
local filetype = opt.filetype or "files"
- local filesconfig = self:_memcache():get2("filesconfig", filetype)
+ local filesconfig = self._FILESCONFIG_USER[filetype]
if not filesconfig then
filesconfig = {}
- self:_memcache():set2("filesconfig", filetype, filesconfig)
+ self._FILESCONFIG_USER[filetype] = filesconfig
end
+ -- we fetch orignal configs first if no user configs
local fileconfig = filesconfig[sourcefile]
+ if not filesconfig then
+ fileconfig = table.clone(self:fileconfig(sourcefile, opt))
+ filesconfig[sourcefile] = fileconfig
+ end
if fileconfig then
for k, v in pairs(info) do
if k == "force" then