summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-04 09:04:08 +0800
committerruki <[email protected]>2017-09-04 09:04:08 +0800
commit08ec1c7dcab891641f6b2fb6a61c2c3b210f5f55 (patch)
tree0f60dce704ce1c7ad0633670f595d07d7d13031d
parent111ed1d840b96e4ceafabf0d033f72edb5753dca (diff)
optimize to detect flags
-rw-r--r--CHANGELOG.md2
-rw-r--r--xmake/modules/lib/detect/has_flags.lua15
2 files changed, 10 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1da9a3792..0188316bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
* Improve `set_version("x.x.x", {build = "%Y%m%d%H%M"})` and add build version
* Move docs directory to xmake-docs repo
* Improve install and uninstall actions and support DESTDIR and PREFIX envirnoment variables
+* Optimize to detect flags
### Bugs fixed
@@ -358,6 +359,7 @@
* 改进`set_version("x.x.x", {build = "%Y%m%d%H%M"})` 支持buildversion设置
* 移除docs目录,将其放置到独立xmake-docs仓库中,减少xmake.zip的大小,优化下载安装的效率
* 改进安装和卸载脚本,支持DESTDIR和PREFIX环境变量设置
+* 通过缓存优化flags探测,加速编译效率
### Bugs修复
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index 8fe025682..adf2c4adb 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -25,6 +25,7 @@
-- imports
import("core.base.option")
import("core.project.config")
+import("lib.detect.cache")
import("lib.detect.find_tool")
-- has the given flags for the current tool?
@@ -82,10 +83,8 @@ function main(name, flags, opt)
--
local arch = config.get("arch") or os.arch()
- -- init cache and key
- local key = tool.program .. "_" .. (tool.version or "") .. "_" .. (opt.toolkind or "") .. "_" .. table.concat(flags, " ") .. "_" .. arch
- _g._RESULTS = _g._RESULTS or {}
- local results = _g._RESULTS
+ -- init cache key
+ local key = tool.program .. "_" .. (tool.version or "") .. "_" .. (opt.toolkind or "") .. "_" .. table.concat(flags, " ") .. "_" .. arch
-- @note avoid detect the same program in the same time if running in the coroutine (.e.g ccache)
local coroutine_running = coroutine.running()
@@ -95,8 +94,9 @@ function main(name, flags, opt)
end
end
- -- get result from the cache first
- local result = results[key]
+ -- attempt to get result from cache first
+ local cacheinfo = cache.load("lib.detect.has_flags")
+ local result = cacheinfo[key]
if result ~= nil then
return result
end
@@ -117,7 +117,8 @@ function main(name, flags, opt)
end
-- save result to cache
- results[key] = ifelse(result, result, false)
+ cacheinfo[key] = ifelse(result, result, false)
+ cache.save("lib.detect.has_flags", cacheinfo)
-- ok?
return result