summaryrefslogtreecommitdiff
path: root/xmake/core/package/package.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-12 23:47:45 +0800
committerruki <[email protected]>2018-09-12 16:46:30 +0800
commitd5bbf65a46f53058816081631fafc015bce83ba3 (patch)
tree423fb3cdb60159e2e99b2b42bf4ffe588088f0c5 /xmake/core/package/package.lua
parent6c804755e70f08edb7c83031abc739db0561b75c (diff)
clear cache when removing package
Diffstat (limited to 'xmake/core/package/package.lua')
-rw-r--r--xmake/core/package/package.lua18
1 files changed, 12 insertions, 6 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 5888bff80..532cc1e23 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -311,14 +311,19 @@ end
-- fetch package info from the local packages
--
+-- @param opt the fetch option, .e.g {force = true, system = false}
+--
-- @return {packageinfo}, fetchfrom (.e.g local/global/system)
--
-function _instance:fetch(force)
+function _instance:fetch(opt)
+
+ -- init options
+ opt = opt or {}
-- attempt to get it from cache
local fetchfrom = self._FETCHFROM
local fetchinfo = self._FETCHINFO
- if not force and fetchinfo then
+ if not opt.force and fetchinfo then
return fetchinfo, fetchfrom
end
@@ -331,7 +336,7 @@ function _instance:fetch(force)
self._find_tool = self._find_tool or sandbox_module.import("lib.detect.find_tool", {anonymous = true})
-- fetch it from the system directories
- fetchinfo = self._find_tool(self:name(), {force = force})
+ fetchinfo = self._find_tool(self:name(), {force = opt.force})
if fetchinfo then
fetchfrom = "system" -- ignore self:requireinfo().system
end
@@ -343,18 +348,19 @@ function _instance:fetch(force)
-- fetch it from the package directories first
local packagedir = self:directory()
if not fetchinfo and packagedir then
- fetchinfo = self._find_package(self:name(), {packagedirs = packagedir, system = false, cachekey = "package:fetch", force = force})
+ -- add cache key to make a distinction with finding system package
+ fetchinfo = self._find_package(self:name(), {packagedirs = packagedir, system = false, cachekey = "package:fetch", force = opt.force})
if fetchinfo then fetchfrom = self._FROMKIND end
end
-- fetch it from the system directories
if not fetchinfo then
- local system = self:requireinfo().system
+ local system = opt.system or self:requireinfo().system
if system == nil then -- find system package by default
system = true
end
if system then
- fetchinfo = self._find_package(self:name(), {force = force})
+ fetchinfo = self._find_package(self:name(), {force = opt.force})
if fetchinfo then fetchfrom = "system" end
end
end