From 742e916cbd2a2d72ec8e7f59b3ca02e137d0bae2 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 23 Apr 2021 00:48:07 +0800 Subject: improve target sourcefiles --- xmake/core/language/language.lua | 10 ++++++---- xmake/core/project/target.lua | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/xmake/core/language/language.lua b/xmake/core/language/language.lua index 2b3e9d813..4815d47db 100644 --- a/xmake/core/language/language.lua +++ b/xmake/core/language/language.lua @@ -260,10 +260,12 @@ function language.load(name) -- load all languages if not name then - for _, name in ipairs(table.wrap(os.match(path.join(language._directory(), "*"), true))) do - local instance, errors = language.load(path.basename(name)) - if not instance then - return nil, errors + if not language._LANGUAGES then + for _, name in ipairs(table.wrap(os.match(path.join(language._directory(), "*"), true))) do + local instance, errors = language.load(path.basename(name)) + if not instance then + return nil, errors + end end end return language._LANGUAGES diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 531ffb887..356358fab 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1180,6 +1180,7 @@ function _instance:sourcefiles() local sourcefiles_deleted = {} local sourcefiles_inserted = {} local deleted_count = 0 + local targetcache = memcache.cache("core.project.target") for _, file in ipairs(table.wrap(files)) do -- mark as deleted files? @@ -1189,13 +1190,18 @@ function _instance:sourcefiles() deleted = true end - -- find source files - local 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) + -- find source files and try to cache the matching results of os.match across targets + -- @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) + end end + targetcache:set2("sourcefiles", file, results) end if #results == 0 then local sourceinfo = (self:get("__sourceinfo_files") or {})[file] or {} -- cgit v1.3.1