summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-25 22:35:49 +0800
committerruki <[email protected]>2022-02-25 22:35:49 +0800
commit69235493bfdafde85187c565dc45bf9cde9abeaa (patch)
treeba9873e172b87d129ae3b66ee01d4b112908b94f
parentae25e418f786b926b291c9bd40de5d0d871e48b5 (diff)
add global detect cache
-rw-r--r--xmake/actions/global/main.lua7
-rw-r--r--xmake/core/cache/global_detectcache.lua22
-rw-r--r--xmake/core/sandbox/modules/import/core/cache/global_detectcache.lua23
-rw-r--r--xmake/modules/private/tools/codesign.lua26
4 files changed, 65 insertions, 13 deletions
diff --git a/xmake/actions/global/main.lua b/xmake/actions/global/main.lua
index b2b9c6da4..785237e32 100644
--- a/xmake/actions/global/main.lua
+++ b/xmake/actions/global/main.lua
@@ -22,6 +22,7 @@
import("core.base.option")
import("core.base.global")
import("core.theme.theme")
+import("core.cache.global_detectcache")
import("menuconf", {alias = "menuconf_show"})
-- main
@@ -68,6 +69,12 @@ function main()
-- save it
global.save()
+ -- clear detect cache
+ if option.get("clean") then
+ global_detectcache:clear()
+ global_detectcache:save()
+ end
+
-- dump it
global.dump()
end
diff --git a/xmake/core/cache/global_detectcache.lua b/xmake/core/cache/global_detectcache.lua
new file mode 100644
index 000000000..f96d12449
--- /dev/null
+++ b/xmake/core/cache/global_detectcache.lua
@@ -0,0 +1,22 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file global_detectcache.lua
+--
+
+return require("cache/globalcache").cache("detect")
+
diff --git a/xmake/core/sandbox/modules/import/core/cache/global_detectcache.lua b/xmake/core/sandbox/modules/import/core/cache/global_detectcache.lua
new file mode 100644
index 000000000..3fbc0b3be
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/cache/global_detectcache.lua
@@ -0,0 +1,23 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file global_detectcache.lua
+--
+
+-- return module
+return require("cache/global_detectcache")
+
diff --git a/xmake/modules/private/tools/codesign.lua b/xmake/modules/private/tools/codesign.lua
index 0eb42860c..cdb643f04 100644
--- a/xmake/modules/private/tools/codesign.lua
+++ b/xmake/modules/private/tools/codesign.lua
@@ -20,7 +20,7 @@
-- imports
import("lib.detect.find_tool")
-import("core.cache.globalcache")
+import("core.cache.global_detectcache")
-- get mobile provision name
function _get_mobile_provision_name(provision)
@@ -46,9 +46,9 @@ end
-- get codesign identities
function codesign_identities()
- local identities = globalcache.get("codesign", "identities")
- local lastime = globalcache.get("codesign", "lastime")
- if lastime and os.time() - lastime > 3 * 24 * 3600 then -- > 3 days
+ local identities = global_detectcache:get2("codesign", "identities")
+ local lastime = global_detectcache:get2("codesign", "lastime")
+ if type(lastime) == "number" and os.time() - lastime > 3 * 24 * 3600 then -- > 3 days
identities = nil
end
if identities == nil then
@@ -72,18 +72,18 @@ function codesign_identities()
end
end
end
- globalcache.set("codesign", "identities", identities or false)
- globalcache.set("codesign", "lastime", os.time())
- globalcache.save("codesign")
+ global_detectcache:set2("codesign", "identities", identities or false)
+ global_detectcache:set2("codesign", "lastime", os.time())
+ global_detectcache:save()
end
return identities or nil
end
-- get provision profiles only for mobile
function mobile_provisions()
- local mobile_provisions = globalcache.get("codesign", "mobile_provisions")
- local lastime = globalcache.get("codesign", "lastime")
- if lastime and os.time() - lastime > 3 * 24 * 3600 then -- > 3 days
+ local mobile_provisions = global_detectcache:get2("codesign", "mobile_provisions")
+ local lastime = global_detectcache:get2("codesign", "lastime")
+ if type(lastime) == "number" and os.time() - lastime > 3 * 24 * 3600 then -- > 3 days
mobile_provisions = nil
end
if mobile_provisions == nil then
@@ -98,9 +98,9 @@ function mobile_provisions()
end
end
end
- globalcache.set("codesign", "mobile_provisions", mobile_provisions or false)
- globalcache.set("codesign", "lastime", os.time())
- globalcache.save("codesign")
+ global_detectcache:set2("codesign", "mobile_provisions", mobile_provisions or false)
+ global_detectcache:set2("codesign", "lastime", os.time())
+ global_detectcache:save()
end
return mobile_provisions or nil
end