diff options
| author | ruki <[email protected]> | 2022-10-08 17:35:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-10-08 17:35:46 +0800 |
| commit | 35aa721e0eb879324e5f985a085d51ddfb251e05 (patch) | |
| tree | 580b343139e30c802cb57e8a4ad2e4ddb2bf37ca | |
| parent | ae84c24d057752b7d3fe2101020e97e697fdd70d (diff) | |
improve target:pkgs
| -rw-r--r-- | xmake/core/project/target.lua | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 22ddd267c..08fa6593c 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -876,24 +876,28 @@ function _instance:orderopts(opt) end -- get the enabled package -function _instance:pkg(name) - return self:pkgs()[name] +function _instance:pkg(name, opt) + return self:pkgs(opt)[name] end -- get the enabled packages -function _instance:pkgs() - - -- attempt to get it from cache first - if self._PKGS_ENABLED then - return self._PKGS_ENABLED +function _instance:pkgs(opt) + opt = opt or {} + local cachekey = "pkgs" + if opt.public then + cachekey = cachekey .. "_public" + elseif opt.interface then + cachekey = cachekey .. "_interface" end - - -- load packages if be enabled - self._PKGS_ENABLED = {} - for _, pkg in ipairs(self:orderpkgs()) do - self._PKGS_ENABLED[pkg:name()] = pkg + local packages = self:_memcache():get(cachekey) + if not packages then + packages = {} + for _, pkg in ipairs(self:orderpkgs(opt)) do + packages[pkg:name()] = pkg + end + self:_memcache():set(cachekey, packages) end - return self._PKGS_ENABLED + return packages end -- get the required packages with {interface|public = ..} |
