summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-23 00:00:24 +0800
committerruki <[email protected]>2020-12-23 00:00:24 +0800
commit5eb09e88851744fb544c5b6ed5e20a448928daa0 (patch)
treef65e2570f193ec11693b174bc0b2b4ff1d37a421
parentfd125f21ece875cd6a5037725f2d84f24e658f41 (diff)
remove lib.detect.cache
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/cache.lua71
-rw-r--r--xmake/modules/detect/sdks/find_android_sdk.lua9
-rw-r--r--xmake/modules/detect/sdks/find_cuda.lua9
-rw-r--r--xmake/modules/detect/sdks/find_dotnet.lua9
-rw-r--r--xmake/modules/detect/sdks/find_mingw.lua9
-rw-r--r--xmake/modules/detect/sdks/find_ndk.lua9
-rw-r--r--xmake/modules/detect/sdks/find_qt.lua9
-rw-r--r--xmake/modules/detect/sdks/find_wdk.lua9
-rw-r--r--xmake/modules/detect/sdks/find_xcode.lua7
-rw-r--r--xmake/modules/detect/tools/ar/has_flags.lua11
-rw-r--r--xmake/modules/detect/tools/cl/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/clang_cl/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/dmd/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/gcc/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/gdc/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/gfortran/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/go/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/link/has_flags.lua11
-rw-r--r--xmake/modules/detect/tools/ml/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/nvcc/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/rustc/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/sdcc/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/swiftc/has_flags.lua13
-rw-r--r--xmake/modules/detect/tools/zig/has_flags.lua13
-rw-r--r--xmake/modules/lib/detect/find_cudadevices.lua7
-rw-r--r--xmake/modules/lib/detect/find_package.lua7
-rw-r--r--xmake/modules/lib/detect/has_flags.lua7
-rw-r--r--xmake/modules/private/tools/cl/parse_include.lua9
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x.lua6
29 files changed, 111 insertions, 257 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/cache.lua b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
deleted file mode 100644
index 743b75c80..000000000
--- a/xmake/core/sandbox/modules/import/lib/detect/cache.lua
+++ /dev/null
@@ -1,71 +0,0 @@
---!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 cache.lua
---
-
--- define module
-local sandbox_lib_detect_cache = sandbox_lib_detect_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 sandbox = require("sandbox/sandbox")
-local raise = require("sandbox/modules/raise")
-local detectcache = require("cache/detectcache")
-
--- load detect cache
---
--- @param name the cache name. e.g. find_program, find_programver, ..
---
-function sandbox_lib_detect_cache.load(name)
- local cacheinfo = detectcache:get(name)
- if cacheinfo == nil then
- cacheinfo = {}
- detectcache:set(name, cacheinfo)
- end
- return cacheinfo
-end
-
--- save detect cache
---
--- @param name the cache name. e.g. find_program, find_programver, ..
--- @param info the cache info
---
-function sandbox_lib_detect_cache.save(name, info)
- detectcache:set(name, info)
- detectcache:save()
-end
-
--- clear detect cache
---
--- @param name the cache name. e.g. find_program, find_programver, ..
---
-function sandbox_lib_detect_cache.clear(name)
- if name then
- detectcache:set(name, {})
- else
- detectcache:clear()
- end
- detectcache:flush()
-end
-
--- return module
-return sandbox_lib_detect_cache
diff --git a/xmake/modules/detect/sdks/find_android_sdk.lua b/xmake/modules/detect/sdks/find_android_sdk.lua
index a15cab02b..047f2aac4 100644
--- a/xmake/modules/detect/sdks/find_android_sdk.lua
+++ b/xmake/modules/detect/sdks/find_android_sdk.lua
@@ -19,11 +19,11 @@
--
-- imports
-import("lib.detect.cache")
import("core.base.semver")
import("core.base.option")
import("core.base.global")
import("core.project.config")
+import("core.cache.detectcache")
import("lib.detect.find_directory")
-- find sdk directory
@@ -95,7 +95,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_android_sdk"
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.sdk and cacheinfo.sdk.sdkdir and os.isdir(cacheinfo.sdk.sdkdir) then
return cacheinfo.sdk
end
@@ -123,8 +123,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.sdk = sdk or false
- cache.save(key, cacheinfo)
-
- -- ok?
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return sdk
end
diff --git a/xmake/modules/detect/sdks/find_cuda.lua b/xmake/modules/detect/sdks/find_cuda.lua
index f8e6b954e..0f2b28cef 100644
--- a/xmake/modules/detect/sdks/find_cuda.lua
+++ b/xmake/modules/detect/sdks/find_cuda.lua
@@ -19,11 +19,11 @@
--
-- imports
-import("lib.detect.cache")
import("lib.detect.find_file")
import("core.base.option")
import("core.base.global")
import("core.project.config")
+import("core.cache.detectcache")
-- find cuda sdk directory
function _find_sdkdir()
@@ -108,7 +108,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_cuda"
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.cuda and cacheinfo.cuda.sdkdir and os.isdir(cacheinfo.cuda.sdkdir) then
return cacheinfo.cuda
end
@@ -134,8 +134,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.cuda = cuda or false
- cache.save(key, cacheinfo)
-
- -- ok?
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return cuda
end
diff --git a/xmake/modules/detect/sdks/find_dotnet.lua b/xmake/modules/detect/sdks/find_dotnet.lua
index 1557edd50..fcfa4c966 100644
--- a/xmake/modules/detect/sdks/find_dotnet.lua
+++ b/xmake/modules/detect/sdks/find_dotnet.lua
@@ -19,12 +19,12 @@
--
-- imports
-import("lib.detect.cache")
import("lib.detect.find_file")
import("core.tool.toolchain")
import("core.base.option")
import("core.base.global")
import("core.project.config")
+import("core.cache.detectcache")
-- find dotnet directory
function _find_sdkdir(sdkdir)
@@ -101,7 +101,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_dotnet." .. (sdkdir or "")
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.dotnet then
return cacheinfo.dotnet
end
@@ -129,8 +129,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.dotnet = dotnet or false
- cache.save(key, cacheinfo)
-
- -- ok?
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return dotnet
end
diff --git a/xmake/modules/detect/sdks/find_mingw.lua b/xmake/modules/detect/sdks/find_mingw.lua
index 77ef47f98..7be315a9c 100644
--- a/xmake/modules/detect/sdks/find_mingw.lua
+++ b/xmake/modules/detect/sdks/find_mingw.lua
@@ -19,11 +19,11 @@
--
-- imports
-import("lib.detect.cache")
import("lib.detect.find_path")
import("core.base.option")
import("core.base.global")
import("core.project.config")
+import("core.cache.detectcache")
import("detect.sdks.find_cross_toolchain")
-- find mingw directory
@@ -121,7 +121,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_mingw"
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.mingw and cacheinfo.mingw.sdkdir and os.isdir(cacheinfo.mingw.sdkdir) then
return cacheinfo.mingw
end
@@ -147,8 +147,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.mingw = mingw or false
- cache.save(key, cacheinfo)
-
- -- ok?
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return mingw
end
diff --git a/xmake/modules/detect/sdks/find_ndk.lua b/xmake/modules/detect/sdks/find_ndk.lua
index 3298d0eec..996b63e8c 100644
--- a/xmake/modules/detect/sdks/find_ndk.lua
+++ b/xmake/modules/detect/sdks/find_ndk.lua
@@ -19,10 +19,10 @@
--
-- imports
-import("lib.detect.cache")
import("core.base.option")
import("core.base.global")
import("core.project.config")
+import("core.cache.detectcache")
import("lib.detect.find_directory")
-- find ndk directory
@@ -196,7 +196,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_ndk"
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.ndk and cacheinfo.ndk.sdkdir and os.isdir(cacheinfo.ndk.sdkdir) then
return cacheinfo.ndk
end
@@ -230,8 +230,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.ndk = ndk or false
- cache.save(key, cacheinfo)
-
- -- ok?
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return ndk
end
diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua
index 663b50afe..1996ac2f9 100644
--- a/xmake/modules/detect/sdks/find_qt.lua
+++ b/xmake/modules/detect/sdks/find_qt.lua
@@ -19,12 +19,12 @@
--
-- imports
-import("lib.detect.cache")
import("lib.detect.find_file")
import("lib.detect.find_tool")
import("core.base.option")
import("core.base.global")
import("core.project.config")
+import("core.cache.detectcache")
-- find qt sdk directory
function _find_sdkdir(sdkdir, sdkver)
@@ -195,7 +195,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_qt"
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.qt and cacheinfo.qt.sdkdir and os.isdir(cacheinfo.qt.sdkdir) then
return cacheinfo.qt
end
@@ -227,8 +227,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.qt = qt or false
- cache.save(key, cacheinfo)
-
- -- ok?
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return qt
end
diff --git a/xmake/modules/detect/sdks/find_wdk.lua b/xmake/modules/detect/sdks/find_wdk.lua
index 3c7b989b7..b7683211c 100644
--- a/xmake/modules/detect/sdks/find_wdk.lua
+++ b/xmake/modules/detect/sdks/find_wdk.lua
@@ -19,12 +19,12 @@
--
-- imports
-import("lib.detect.cache")
import("lib.detect.find_file")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.tool.toolchain")
+import("core.cache.detectcache")
import("detect.sdks.find_vstudio")
-- find WDK directory
@@ -153,7 +153,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_wdk"
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.wdk and cacheinfo.wdk.sdkdir and os.isdir(cacheinfo.wdk.sdkdir) then
return cacheinfo.wdk
end
@@ -181,8 +181,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.wdk = wdk or false
- cache.save(key, cacheinfo)
-
- -- ok?
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return wdk
end
diff --git a/xmake/modules/detect/sdks/find_xcode.lua b/xmake/modules/detect/sdks/find_xcode.lua
index 80d7cf5cf..02ea606bf 100644
--- a/xmake/modules/detect/sdks/find_xcode.lua
+++ b/xmake/modules/detect/sdks/find_xcode.lua
@@ -19,10 +19,10 @@
--
-- imports
-import("lib.detect.cache")
import("core.base.option")
import("core.base.global")
import("core.project.config")
+import("core.cache.detectcache")
import("lib.detect.find_directory")
import("private.tools.codesign")
@@ -144,7 +144,7 @@ function main(sdkdir, opt)
-- attempt to load cache first
local key = "detect.sdks.find_xcode"
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.xcode and cacheinfo.xcode.sdkdir and os.isdir(cacheinfo.xcode.sdkdir) then
return cacheinfo.xcode
end
@@ -158,6 +158,7 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.xcode = xcode or false
- cache.save(key, cacheinfo)
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
return xcode
end
diff --git a/xmake/modules/detect/tools/ar/has_flags.lua b/xmake/modules/detect/tools/ar/has_flags.lua
index 9a528a4a5..914680d69 100644
--- a/xmake/modules/detect/tools/ar/has_flags.lua
+++ b/xmake/modules/detect/tools/ar/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
-- attempt to check it from the argument list
function _check_from_arglist(flags, opt)
@@ -35,11 +35,8 @@ function _check_from_arglist(flags, opt)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -65,8 +62,8 @@ function _check_from_arglist(flags, opt)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-- ok?
diff --git a/xmake/modules/detect/tools/cl/has_flags.lua b/xmake/modules/detect/tools/cl/has_flags.lua
index bfa738fab..2a398041d 100644
--- a/xmake/modules/detect/tools/cl/has_flags.lua
+++ b/xmake/modules/detect/tools/cl/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
-- attempt to check it from the argument list
function _check_from_arglist(flags, opt)
@@ -35,11 +35,8 @@ function _check_from_arglist(flags, opt)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -52,11 +49,9 @@ function _check_from_arglist(flags, opt)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]:gsub("/", "-")]
end
diff --git a/xmake/modules/detect/tools/clang_cl/has_flags.lua b/xmake/modules/detect/tools/clang_cl/has_flags.lua
index ffd3ad99a..27728697f 100644
--- a/xmake/modules/detect/tools/clang_cl/has_flags.lua
+++ b/xmake/modules/detect/tools/clang_cl/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("core.language.language")
-- attempt to check it from the argument list
@@ -36,11 +36,8 @@ function _check_from_arglist(flags, opt)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -53,11 +50,9 @@ function _check_from_arglist(flags, opt)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]:gsub("/", "-")]
end
diff --git a/xmake/modules/detect/tools/dmd/has_flags.lua b/xmake/modules/detect/tools/dmd/has_flags.lua
index 372b25416..459db9228 100644
--- a/xmake/modules/detect/tools/dmd/has_flags.lua
+++ b/xmake/modules/detect/tools/dmd/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
-- is linker?
function _islinker(flags, opt)
@@ -57,11 +57,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -74,11 +71,9 @@ function _check_from_arglist(flags, opt, islinker)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua
index fd1abd9ed..391ff2bfb 100644
--- a/xmake/modules/detect/tools/gcc/has_flags.lua
+++ b/xmake/modules/detect/tools/gcc/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("core.language.language")
-- is linker?
@@ -56,11 +56,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make flags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all flags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -73,11 +70,9 @@ function _check_from_arglist(flags, opt, islinker)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/gdc/has_flags.lua b/xmake/modules/detect/tools/gdc/has_flags.lua
index 8520240b7..1ba8c98b0 100644
--- a/xmake/modules/detect/tools/gdc/has_flags.lua
+++ b/xmake/modules/detect/tools/gdc/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("core.language.language")
-- is linker?
@@ -56,11 +56,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make flags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all flags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -73,11 +70,9 @@ function _check_from_arglist(flags, opt, islinker)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/gfortran/has_flags.lua b/xmake/modules/detect/tools/gfortran/has_flags.lua
index 9fad1e779..62a35c653 100644
--- a/xmake/modules/detect/tools/gfortran/has_flags.lua
+++ b/xmake/modules/detect/tools/gfortran/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("core.language.language")
-- is linker?
@@ -56,11 +56,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make flags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all flags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -73,11 +70,9 @@ function _check_from_arglist(flags, opt, islinker)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/go/has_flags.lua b/xmake/modules/detect/tools/go/has_flags.lua
index 006e26c7f..267d4de8a 100644
--- a/xmake/modules/detect/tools/go/has_flags.lua
+++ b/xmake/modules/detect/tools/go/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("core.language.language")
-- is linker?
@@ -52,11 +52,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make flags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all flags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- attempt to get argument list from the error info (help menu)
@@ -78,11 +75,9 @@ function _check_from_arglist(flags, opt, islinker)
}
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/link/has_flags.lua b/xmake/modules/detect/tools/link/has_flags.lua
index 82d4f6854..819a84279 100644
--- a/xmake/modules/detect/tools/link/has_flags.lua
+++ b/xmake/modules/detect/tools/link/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("lib.detect.find_tool")
-- try running
@@ -42,11 +42,8 @@ function _check_from_arglist(flags, opt)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -67,8 +64,8 @@ function _check_from_arglist(flags, opt)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
return allflags[flags[1]:gsub("/", "-"):lower()]
end
diff --git a/xmake/modules/detect/tools/ml/has_flags.lua b/xmake/modules/detect/tools/ml/has_flags.lua
index 439c0fa5a..53576fa22 100644
--- a/xmake/modules/detect/tools/ml/has_flags.lua
+++ b/xmake/modules/detect/tools/ml/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
-- attempt to check it from the argument list
function _check_from_arglist(flags, opt)
@@ -35,11 +35,8 @@ function _check_from_arglist(flags, opt)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -52,11 +49,9 @@ function _check_from_arglist(flags, opt)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]:gsub("/", "-")]
end
diff --git a/xmake/modules/detect/tools/nvcc/has_flags.lua b/xmake/modules/detect/tools/nvcc/has_flags.lua
index 594368e81..9a66c5f42 100644
--- a/xmake/modules/detect/tools/nvcc/has_flags.lua
+++ b/xmake/modules/detect/tools/nvcc/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("core.language.language")
-- is linker?
@@ -78,11 +78,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make flags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all flags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -95,11 +92,9 @@ function _check_from_arglist(flags, opt, islinker)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/rustc/has_flags.lua b/xmake/modules/detect/tools/rustc/has_flags.lua
index 1e8506249..e7c55a180 100644
--- a/xmake/modules/detect/tools/rustc/has_flags.lua
+++ b/xmake/modules/detect/tools/rustc/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
-- try running
function _try_running(...)
@@ -43,11 +43,8 @@ function _check_from_arglist(flags, opt)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -60,11 +57,9 @@ function _check_from_arglist(flags, opt)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/sdcc/has_flags.lua b/xmake/modules/detect/tools/sdcc/has_flags.lua
index c2b144334..1198b6f44 100644
--- a/xmake/modules/detect/tools/sdcc/has_flags.lua
+++ b/xmake/modules/detect/tools/sdcc/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("core.language.language")
-- is linker?
@@ -58,11 +58,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make flags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all flags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -75,11 +72,9 @@ function _check_from_arglist(flags, opt, islinker)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/swiftc/has_flags.lua b/xmake/modules/detect/tools/swiftc/has_flags.lua
index 3a0749edb..541b897a9 100644
--- a/xmake/modules/detect/tools/swiftc/has_flags.lua
+++ b/xmake/modules/detect/tools/swiftc/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
-- try running
function _try_running(...)
@@ -43,11 +43,8 @@ function _check_from_arglist(flags, opt)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -60,11 +57,9 @@ function _check_from_arglist(flags, opt)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/detect/tools/zig/has_flags.lua b/xmake/modules/detect/tools/zig/has_flags.lua
index 12091eb87..b12f3defb 100644
--- a/xmake/modules/detect/tools/zig/has_flags.lua
+++ b/xmake/modules/detect/tools/zig/has_flags.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
-- is linker?
function _islinker(flags, opt)
@@ -51,11 +51,8 @@ function _check_from_arglist(flags, opt, islinker)
-- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
- -- load cache
- local cacheinfo = cache.load(key)
-
-- get all allflags from argument list
- local allflags = cacheinfo[flagskey]
+ local allflags = detectcache:get2(key, flagskey)
if not allflags then
-- get argument list
@@ -68,11 +65,9 @@ function _check_from_arglist(flags, opt, islinker)
end
-- save cache
- cacheinfo[flagskey] = allflags
- cache.save(key, cacheinfo)
+ detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
-
- -- ok?
return allflags[flags[1]]
end
diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua
index 92ffcf5cd..c55cc26f8 100644
--- a/xmake/modules/lib/detect/find_cudadevices.lua
+++ b/xmake/modules/lib/detect/find_cudadevices.lua
@@ -22,7 +22,7 @@
import("core.base.option")
import("core.platform.platform")
import("core.project.config")
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("lib.detect.find_tool")
-- a magic string to filter output
@@ -181,7 +181,7 @@ function _get_devices(opt)
end
-- check cache
- local cachedata = cache.load(cachekey)
+ local cachedata = detectcache:get(cachekey) or {}
if cachedata.succeed and not opt.force then
return cachedata.data
end
@@ -196,7 +196,8 @@ function _get_devices(opt)
end
-- fill cache
- cache.save(cachekey, cachedata)
+ detectcache:set(cachekey, cachedata)
+ detectcache:save()
return devices
end
diff --git a/xmake/modules/lib/detect/find_package.lua b/xmake/modules/lib/detect/find_package.lua
index e6f4c8f21..5e50c2345 100644
--- a/xmake/modules/lib/detect/find_package.lua
+++ b/xmake/modules/lib/detect/find_package.lua
@@ -21,7 +21,7 @@
-- imports
import("core.base.option")
import("core.project.config")
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("package.manager.find_package")
-- find package using the package manager
@@ -71,7 +71,7 @@ function main(name, opt)
end
-- attempt to get result from cache first
- local cacheinfo = cache.load(key)
+ local cacheinfo = detectcache:get(key) or {}
local result = cacheinfo[name]
if result == nil or opt.force then
@@ -87,7 +87,8 @@ function main(name, opt)
-- cache result
cacheinfo[name] = result and result or false
- cache.save(key, cacheinfo)
+ detectcache:set(key, cacheinfo)
+ detectcache:save()
-- trace
if opt.verbose or option.get("verbose") then
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index 4f151740f..4559f7959 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -22,7 +22,7 @@
import("core.base.option")
import("core.base.scheduler")
import("core.project.config")
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("lib.detect.find_tool")
-- has the given flags for the current tool?
@@ -84,7 +84,7 @@ function main(name, flags, opt)
end
-- attempt to get result from cache first
- local cacheinfo = cache.load("lib.detect.has_flags")
+ local cacheinfo = detectcache:get("lib.detect.has_flags") or {}
local result = cacheinfo[key]
if result ~= nil and not opt.force then
return result
@@ -137,7 +137,8 @@ function main(name, flags, opt)
-- save result to cache
cacheinfo[key] = result
- cache.save("lib.detect.has_flags", cacheinfo)
+ detectcache:set("lib.detect.has_flags", cacheinfo)
+ detectcache:save()
return result
end
diff --git a/xmake/modules/private/tools/cl/parse_include.lua b/xmake/modules/private/tools/cl/parse_include.lua
index 32088b890..4175e9019 100644
--- a/xmake/modules/private/tools/cl/parse_include.lua
+++ b/xmake/modules/private/tools/cl/parse_include.lua
@@ -22,15 +22,14 @@
import("core.project.project")
import("core.base.hashset")
import("core.tool.toolchain")
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("lib.detect.find_tool")
import("private.tools.vstool")
-- probe include note prefix from cl
function _probe_include_note_from_cl()
local key = "note_include"
- local cacheinfo = cache.load("cldeps.parse_include")
- local note = cacheinfo[key]
+ local note = detectcache:get2("cldeps.parse_include", key)
if not note then
local cl = find_tool("cl")
if cl then
@@ -60,8 +59,8 @@ function _probe_include_note_from_cl()
end
os.tryrm(projectdir)
end
- cacheinfo[key] = note
- cache.save("cldeps.parse_include", cacheinfo)
+ detectcache:set2("cldeps.parse_include", key, note)
+ detectcache:save()
end
return note
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua
index 5c4276326..0d17886f2 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x.lua
@@ -29,7 +29,7 @@ import("core.tool.toolchain")
import("vs201x_solution")
import("vs201x_vcxproj")
import("vs201x_vcxproj_filters")
-import("lib.detect.cache", {alias = "detectcache"})
+import("core.cache.localcache")
import("actions.require.install", {alias = "install_requires", rootdir = os.programdir()})
import("actions.config.configfiles", {alias = "generate_configfiles", rootdir = os.programdir()})
import("actions.config.configheader", {alias = "generate_configheader", rootdir = os.programdir()})
@@ -232,8 +232,8 @@ function make(outputdir, vsinfo)
-- reload config, project and platform
if mode ~= config.mode() or arch ~= config.arch() then
- -- clear detect cache
- detectcache.clear()
+ -- clear local cache
+ localcache.clear()
-- modify config
config.set("as", nil, {force = true}) -- force to re-check as for ml/ml64