summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-17 17:28:54 +0800
committerruki <[email protected]>2017-05-17 17:28:54 +0800
commit90d2cd04af190d1dec82da892de1d7a6f86ed0c7 (patch)
tree50f61d19854106e8a20803b0a11a15289379bc5e
parentd0fe0eeb1c9385777b8319d6f92dbc907b917f84 (diff)
add clear_cache for detecting
-rw-r--r--xmake/actions/config/main.lua4
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/clear_cache.lua58
2 files changed, 62 insertions, 0 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index cf74d1af4..a2f2e2737 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -29,6 +29,7 @@ import("core.project.global")
import("core.project.project")
import("core.platform.platform")
import("core.project.cache")
+import("lib.detect.clear_cache")
import("scanner")
import("configheader")
@@ -221,6 +222,9 @@ function main()
-- rebuild it
cache.set("rebuild", true)
+
+ -- clear detect cache
+ clear_cache()
end
-- merge the cached configure
diff --git a/xmake/core/sandbox/modules/import/lib/detect/clear_cache.lua b/xmake/core/sandbox/modules/import/lib/detect/clear_cache.lua
new file mode 100644
index 000000000..81cca369e
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/detect/clear_cache.lua
@@ -0,0 +1,58 @@
+--!The Make-like Build Utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you 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 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file clear_cache.lua
+--
+
+-- define module
+local sandbox_lib_detect_clear_cache = sandbox_lib_detect_clear_cache or {}
+
+-- load modules
+local os = require("base/os")
+local path = require("base/path")
+local table = require("base/table")
+local utils = require("base/utils")
+local option = require("base/option")
+local cache = require("project/cache")
+local project = require("project/project")
+local sandbox = require("sandbox/sandbox")
+local raise = require("sandbox/modules/raise")
+
+-- clear detect cache
+--
+-- @param name the cache name. .e.g find_program, find_programver, ..
+--
+function sandbox_lib_detect_clear_cache.main(name)
+
+ -- get detect cache
+ local detectcache = cache(utils.ifelse(os.isfile(project.file()), "local.detect", "memory.detect"))
+
+ -- clear cache info
+ if name then
+ detectcache:set(name, {})
+ else
+ detectcache:clear()
+ end
+ detectcache:flush()
+end
+
+-- return module
+return sandbox_lib_detect_clear_cache