summaryrefslogtreecommitdiff
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
parente7f4ab3c95a04731de70991b401d78555c9fb1de (diff)
improve package
-rw-r--r--xmake/actions/require/install.lua4
-rw-r--r--xmake/core/package/package.lua21
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x.lua4
3 files changed, 18 insertions, 11 deletions
diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua
index d76ecfd3e..cedc3e434 100644
--- a/xmake/actions/require/install.lua
+++ b/xmake/actions/require/install.lua
@@ -165,10 +165,6 @@ end
-- install packages
function main(requires_raw)
- -- avoid to run this task repeatly
- if _g.installed then return end
- _g.installed = true
-
-- get requires and extra config
local requires_extra = nil
local requires, requires_extra = get_requires(requires_raw)
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()
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua
index 0d17886f2..cdb18a828 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x.lua
@@ -29,6 +29,7 @@ import("core.tool.toolchain")
import("vs201x_solution")
import("vs201x_vcxproj")
import("vs201x_vcxproj_filters")
+import("core.cache.memcache")
import("core.cache.localcache")
import("actions.require.install", {alias = "install_requires", rootdir = os.programdir()})
import("actions.config.configfiles", {alias = "generate_configfiles", rootdir = os.programdir()})
@@ -232,7 +233,8 @@ function make(outputdir, vsinfo)
-- reload config, project and platform
if mode ~= config.mode() or arch ~= config.arch() then
- -- clear local cache
+ -- clear cache
+ memcache.clear()
localcache.clear()
-- modify config