summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-24 21:48:22 +0800
committerGitHub <[email protected]>2020-12-24 21:48:22 +0800
commit95cfe53e0e9963b1c791f3bd3a3a9b7eda3b3b10 (patch)
tree137fac8018667ad280eb6f2bb7a1171c02ae8d6a /xmake/modules
parent9d1ea2ecbc19153c1fcc2355aab3e6e09cbe7b12 (diff)
parent3118b46c20edbdade2aed0b50b7ed668e4301d70 (diff)
Merge pull request #1152 from xmake-io/cache
Improve cache
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/core/tools/cl.lua19
-rw-r--r--xmake/modules/core/tools/link.lua7
-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/net/ping.lua7
-rw-r--r--xmake/modules/package/tools/cmake.lua13
-rw-r--r--xmake/modules/package/tools/xmake.lua3
-rw-r--r--xmake/modules/private/tools/cl/parse_include.lua11
32 files changed, 139 insertions, 203 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index ba9e82d84..64d4d2773 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -142,8 +142,6 @@ end
-- make the warning flag
function nf_warning(self, level)
-
- -- the maps
local maps =
{
none = "-W0"
@@ -154,15 +152,11 @@ function nf_warning(self, level)
, everything = "-Wall"
, error = "-WX"
}
-
- -- make it
return maps[level]
end
-- make the optimize flag
function nf_optimize(self, level)
-
- -- the maps
local maps =
{
none = "-Od"
@@ -171,15 +165,18 @@ function nf_optimize(self, level)
, smallest = "-O1 -GL" -- /GL and (/OPT:REF is on by default in linker), we need enable /ltcg
, aggressive = "-Ox -fp:fast"
}
-
- -- make it
return maps[level]
end
+-- make vs runtime flag
+function nf_runtime(self, vs_runtime)
+ if vs_runtime then
+ return "-" .. vs_runtime
+ end
+end
+
-- make the vector extension flag
function nf_vectorext(self, extension)
-
- -- the maps
local maps =
{
sse = "-arch:SSE"
@@ -187,8 +184,6 @@ function nf_vectorext(self, extension)
, avx = "-arch:AVX"
, avx2 = "-arch:AVX2"
}
-
- -- check it
local flag = maps[extension]
if flag and self:has_flags(flag, "cxflags") then
return flag
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index 844b5d67a..26abc8983 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -96,6 +96,13 @@ function nf_syslink(self, lib)
return nf_link(self, lib)
end
+-- make vs runtime flag
+function nf_runtime(self, vs_runtime)
+ if vs_runtime and vs_runtime:startswith("MT") then
+ return "-nodefaultlib:msvcrt.lib"
+ end
+end
+
-- make the linkdir flag
function nf_linkdir(self, dir)
return "-libpath:" .. os.args(path.translate(dir))
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/net/ping.lua b/xmake/modules/net/ping.lua
index a783866fc..1f361a5d6 100644
--- a/xmake/modules/net/ping.lua
+++ b/xmake/modules/net/ping.lua
@@ -19,7 +19,7 @@
--
-- imports
-import("lib.detect.cache")
+import("core.cache.detectcache")
import("detect.tools.find_ping")
import("detect.tools.find_nmap")
import("private.async.runjobs")
@@ -45,7 +45,7 @@ function main(hosts, opt)
-- do not force ping? enable cache
local cacheinfo = nil
if not opt.force then
- cacheinfo = cache.load("net.ping")
+ cacheinfo = detectcache:get("net.ping")
end
-- run tasks
@@ -111,7 +111,8 @@ function main(hosts, opt)
-- save cache
if cacheinfo then
- cache.save("net.ping", cacheinfo)
+ detectcache:set("net.ping", cacheinfo)
+ detectcache:save()
end
-- ok?
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 3835e0d3b..a126fe514 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -197,10 +197,19 @@ function _get_configs_for_windows(package, configs, opt)
end
end
local vs_runtime = package:config("vs_runtime")
+ if vs_runtime == "MT" then
+ table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded")
+ elseif vs_runtime == "MTd" then
+ table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug")
+ elseif vs_runtime == "MD" then
+ table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL")
+ elseif vs_runtime == "MDd" then
+ table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL")
+ end
if vs_runtime then
- table.insert(configs, '-DCMAKE_CXX_FLAGS_DEBUG="/' .. vs_runtime .. 'd"')
+ table.insert(configs, '-DCMAKE_CXX_FLAGS_DEBUG="/' .. vs_runtime .. '"')
table.insert(configs, '-DCMAKE_CXX_FLAGS_RELEASE="/' .. vs_runtime .. '"')
- table.insert(configs, '-DCMAKE_C_FLAGS_DEBUG="/' .. vs_runtime .. 'd"')
+ table.insert(configs, '-DCMAKE_C_FLAGS_DEBUG="/' .. vs_runtime .. '"')
table.insert(configs, '-DCMAKE_C_FLAGS_RELEASE="/' .. vs_runtime .. '"')
end
_get_configs_for_generic(package, configs, opt)
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index 84ef7ef5b..115a5fbe8 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -33,8 +33,7 @@ function _get_configs(package, configs)
if package:is_plat("windows") then
local vs_runtime = package:config("vs_runtime")
if vs_runtime then
- local vs_runtime_cxflags = "/" .. vs_runtime .. (package:debug() and "d" or "")
- table.insert(cxflags, vs_runtime_cxflags)
+ table.insert(configs, "--vs_runtime=" .. vs_runtime)
end
end
table.insert(configs, "--mode=" .. (package:debug() and "debug" or "release"))
diff --git a/xmake/modules/private/tools/cl/parse_include.lua b/xmake/modules/private/tools/cl/parse_include.lua
index 32088b890..afb43b056 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 key = "cldeps.parse_include.note"
+ local note = detectcache:get(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:set(key, note)
+ detectcache:save()
end
return note
end