diff options
| author | ruki <[email protected]> | 2017-06-13 10:44:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-13 10:44:07 +0800 |
| commit | c0943c86f7ce1ae303e4ba909d29a11f750a9cda (patch) | |
| tree | a4dca6ed45969b9a05f562f11babe5cacca45db2 | |
| parent | a1304d43b58dcd7f0ee3a822781af8f67def640f (diff) | |
cache find_package for each plat and arch
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_package.lua | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_package.lua b/xmake/core/sandbox/modules/import/lib/detect/find_package.lua index 2a54a1d36..a5284ec89 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_package.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_package.lua @@ -126,11 +126,6 @@ function sandbox_lib_detect_find_package._find(name, opt) , sandbox_lib_detect_find_package._find_from_modules } - -- init options - opt = opt or {} - opt.plat = opt.plat or config.get("plat") or os.host() - opt.arch = opt.arch or config.get("arch") or os.arch() - -- find package from the current host platform if opt.plat == os.host() and opt.arch == os.arch() then table.insert(findscripts, sandbox_lib_detect_find_package._find_from_pkg_config) @@ -168,8 +163,16 @@ function sandbox_lib_detect_find_package.main(name, opt) -- get detect cache local detectcache = cache(utils.ifelse(os.isfile(project.file()), "local.detect", "memory.detect")) + -- init options + opt = opt or {} + opt.plat = opt.plat or config.get("plat") or os.host() + opt.arch = opt.arch or config.get("arch") or os.arch() + + -- init cache key + local key = "find_package_" .. opt.plat .. "_" .. opt.arch + -- attempt to get result from cache first - local cacheinfo = detectcache:get("find_package") or {} + local cacheinfo = detectcache:get(key) or {} local result = cacheinfo[name] if result ~= nil then return utils.ifelse(result, result, nil) @@ -182,7 +185,7 @@ function sandbox_lib_detect_find_package.main(name, opt) cacheinfo[name] = utils.ifelse(result, result, false) -- save cache info - detectcache:set("find_package", cacheinfo) + detectcache:set(key, cacheinfo) detectcache:flush() -- trace |
