summaryrefslogtreecommitdiff
path: root/xmake/core/package/package.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-23 00:39:38 +0800
committerruki <[email protected]>2020-12-23 00:39:38 +0800
commit58f26afbf964ee3a873021b972df868f23cc16c3 (patch)
tree558429ade5878c40357f944d44cad0f5a2812b83 /xmake/core/package/package.lua
parente7f4ab3c95a04731de70991b401d78555c9fb1de (diff)
improve package
Diffstat (limited to 'xmake/core/package/package.lua')
-rw-r--r--xmake/core/package/package.lua21
1 files changed, 15 insertions, 6 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 8d828b961..873cc119b 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -33,6 +33,7 @@ local semver = require("base/semver")
local option = require("base/option")
local scopeinfo = require("base/scopeinfo")
local interpreter = require("base/interpreter")
+local memcache = require("cache/memcache")
local sandbox = require("sandbox/sandbox")
local config = require("project/config")
local platform = require("platform/platform")
@@ -710,7 +711,8 @@ end
-- get the build hash
function _instance:buildhash()
- if self._BUILDHASH == nil then
+ local buildhash = package._memcache():get2(self, "buildhash")
+ if buildhash == nil then
local str = self:plat() .. self:arch()
local configs = self:configs()
if configs then
@@ -727,9 +729,10 @@ function _instance:buildhash()
configs_str = configs_str:gsub("\"", "")
str = str .. configs_str
end
- self._BUILDHASH = hash.uuid4(str):gsub('-', ''):lower()
+ buildhash = hash.uuid4(str):gsub('-', ''):lower()
+ package._memcache():set2(self, "buildhash", buildhash)
end
- return self._BUILDHASH
+ return buildhash
end
-- get the group name
@@ -858,7 +861,7 @@ function _instance:fetch(opt)
opt = opt or {}
-- attempt to get it from cache
- local fetchinfo = self._FETCHINFO
+ local fetchinfo = package._memcache():get2(self, "fetchinfo")
if not opt.force and opt.external == nil and fetchinfo then
return fetchinfo
end
@@ -959,7 +962,7 @@ function _instance:fetch(opt)
end
-- save to cache
- self._FETCHINFO = fetchinfo
+ package._memcache():set2(self, "fetchinfo", fetchinfo)
-- mark as system package?
if isSys ~= nil then
@@ -970,7 +973,8 @@ end
-- exists this package?
function _instance:exists()
- return self._FETCHINFO ~= nil
+ local fetchinfo = package._memcache():get2(self, "fetchinfo")
+ return fetchinfo ~= nil
end
-- fetch all local info with dependencies
@@ -1283,6 +1287,11 @@ function package._interpreter()
return interp
end
+-- get package memcache
+function package._memcache()
+ return memcache.cache("core.base.package")
+end
+
-- get package apis
function package.apis()