diff options
| author | ruki <[email protected]> | 2021-04-26 22:42:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-04-26 22:42:10 +0800 |
| commit | 8ecc5df949d9c366b5ff0f96cf2bedab62c1bb51 (patch) | |
| tree | 16661f7081cba09840b24f9fcd1c21c6162afa2c | |
| parent | 6f54b6144373895cd158616dc63c7763021804d4 (diff) | |
improve del_files
| -rw-r--r-- | xmake/core/project/target.lua | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 356358fab..1ab9d3212 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1194,11 +1194,15 @@ function _instance:sourcefiles() -- @see https://github.com/xmake-io/xmake/issues/1353 local results = targetcache:get2("sourcefiles", file) if not results then - results = os.files(file) - if #results == 0 then - -- attempt to find source directories if maybe compile it as directory with the custom rules - if #self:filerules(file) > 0 then - results = os.dirs(file) + if deleted then + results = {file} + else + results = os.files(file) + if #results == 0 then + -- attempt to find source directories if maybe compile it as directory with the custom rules + if #self:filerules(file) > 0 then + results = os.dirs(file) + end end end targetcache:set2("sourcefiles", file, results) @@ -1219,7 +1223,7 @@ function _instance:sourcefiles() -- add or delete it if deleted then deleted_count = deleted_count + 1 - sourcefiles_deleted[sourcefile] = true + table.insert(sourcefiles_deleted, sourcefile) elseif not sourcefiles_inserted[sourcefile] then table.insert(sourcefiles, sourcefile) sourcefiles_inserted[sourcefile] = true @@ -1231,8 +1235,15 @@ function _instance:sourcefiles() if deleted_count > 0 then for i = #sourcefiles, 1, -1 do local sourcefile = sourcefiles[i] - if sourcefiles_deleted[sourcefile] then - table.remove(sourcefiles, i) + for _, deletefile in ipairs(sourcefiles_deleted) do + local pattern = path.translate(deletefile:gsub("|.*$", "")) + if pattern:sub(1, 2):find('%.[/\\]') then + pattern = pattern:sub(3) + end + pattern = path.pattern(pattern) + if sourcefile:match(pattern) then + table.remove(sourcefiles, i) + end end end end |
