summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-22 00:48:16 +0800
committerruki <[email protected]>2020-12-22 00:48:16 +0800
commit4782a9648e20c0e6a4620f7255ab3cb476dceb5e (patch)
treeb28369f767800262db24da6b347d62acf8ffad33
parent192f10c1d09e665f04dd5669fcaccc5abccbb9db (diff)
rewrite some caches
-rw-r--r--xmake/actions/config/main.lua16
-rw-r--r--xmake/actions/require/clean.lua6
-rw-r--r--xmake/core/cache/configcache.lua (renamed from xmake/core/sandbox/modules/import/core/project/history.lua)6
-rw-r--r--xmake/core/cache/globalcache.lua14
-rw-r--r--xmake/core/cache/localcache.lua14
-rw-r--r--xmake/core/main.lua5
-rw-r--r--xmake/core/package/repository.lua41
-rw-r--r--xmake/core/project/history.lua2
-rw-r--r--xmake/core/project/option.lua16
-rw-r--r--xmake/core/project/requireinfo.lua32
-rw-r--r--xmake/core/sandbox/modules/import/core/cache/configcache.lua (renamed from xmake/core/sandbox/modules/import/core/project/cache.lua)4
-rw-r--r--xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua27
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/cache.lua41
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua33
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_programver.lua27
-rw-r--r--xmake/core/tool/toolchain.lua8
-rw-r--r--xmake/plugins/macro/main.lua33
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua3
18 files changed, 133 insertions, 195 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 599224d42..cecd906aa 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -25,9 +25,9 @@ import("core.base.hashset")
import("core.project.config")
import("core.project.project")
import("core.platform.platform")
-import("core.project.cache")
import("private.detect.find_platform")
-import("lib.detect.cache", {alias = "detectcache"})
+import("core.cache.localcache")
+import("core.cache.configcache")
import("scangen")
import("menuconf", {alias = "menuconf_show"})
import("configfiles", {alias = "generate_configfiles"})
@@ -69,7 +69,6 @@ function _need_check(changed)
local mtimes = project.mtimes()
-- get the previous mtimes
- local configcache = cache("local.config")
if not changed then
local mtimes_prev = configcache:get("mtimes")
if mtimes_prev then
@@ -204,9 +203,6 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
-- the target name
local targetname = option.get("target") or "all"
- -- get config cache
- local configcache = cache("local.config")
-
-- load the project configure
--
-- priority: option > option_cache > global > option_default > config_check > project_check > config_cache
@@ -281,8 +277,8 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
local recheck = _need_check(options_changed or not configcache_loaded or autogen)
if recheck then
- -- clear detect cache
- detectcache.clear()
+ -- clear local cache
+ localcache.clear()
-- check platform
instance_plat:check()
@@ -333,8 +329,8 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
config.save()
configcache:set("options", options)
- -- flush config cache
- configcache:flush()
+ -- save config cache
+ configcache:save()
-- unlock the whole project
project.unlock()
diff --git a/xmake/actions/require/clean.lua b/xmake/actions/require/clean.lua
index d06617783..fb93e6304 100644
--- a/xmake/actions/require/clean.lua
+++ b/xmake/actions/require/clean.lua
@@ -20,8 +20,8 @@
-- imports
import("core.base.option")
-import("core.project.cache")
import("core.package.package")
+import("core.cache.localcache")
-- clear the unused or invalid package directories
function _clear_packagedirs(packagedir)
@@ -96,8 +96,8 @@ function main(package_names)
os.rm(package.cachedir())
-- clear require cache
- local require_cache = cache("local.require")
+ local require_cache = localcache.cache("package")
require_cache:clear()
- require_cache:flush()
+ require_cache:save()
end
diff --git a/xmake/core/sandbox/modules/import/core/project/history.lua b/xmake/core/cache/configcache.lua
index 40e32e719..889f7d1c4 100644
--- a/xmake/core/sandbox/modules/import/core/project/history.lua
+++ b/xmake/core/cache/configcache.lua
@@ -15,8 +15,8 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki
--- @file history.lua
+-- @file configcache.lua
--
--- return module
-return require("project/history")
+return require("cache/localcache").cache("config")
+
diff --git a/xmake/core/cache/globalcache.lua b/xmake/core/cache/globalcache.lua
index 812cf25f1..fbed27408 100644
--- a/xmake/core/cache/globalcache.lua
+++ b/xmake/core/cache/globalcache.lua
@@ -172,6 +172,20 @@ function globalcache.set3(cachename, key1, key2, key3, value)
return globalcache.cache(cachename):set3(key1, key2, key3, value)
end
+-- save the given cache, it will save all caches if cache name is nil
+function globalcache.save(cachename)
+ if cachename then
+ globalcache.cache(cachename):save()
+ else
+ local caches = globalcache.caches()
+ if caches then
+ for _, cache in pairs(caches) do
+ cache:save()
+ end
+ end
+ end
+end
+
-- clear the given cache, it will clear all caches if cache name is nil
function globalcache.clear(cachename)
if cachename then
diff --git a/xmake/core/cache/localcache.lua b/xmake/core/cache/localcache.lua
index 7ba00e7cc..3fd5d040f 100644
--- a/xmake/core/cache/localcache.lua
+++ b/xmake/core/cache/localcache.lua
@@ -172,6 +172,20 @@ function localcache.set3(cachename, key1, key2, key3, value)
return localcache.cache(cachename):set3(key1, key2, key3, value)
end
+-- save the given cache, it will save all caches if cache name is nil
+function localcache.save(cachename)
+ if cachename then
+ localcache.cache(cachename):save()
+ else
+ local caches = localcache.caches()
+ if caches then
+ for _, cache in pairs(caches) do
+ cache:save()
+ end
+ end
+ end
+end
+
-- clear the given cache, it will clear all caches if cache name is nil
function localcache.clear(cachename)
if cachename then
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index d9638459f..ad343edb4 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -37,7 +37,7 @@ local scheduler = require("base/scheduler")
local theme = require("theme/theme")
local config = require("project/config")
local project = require("project/project")
-local history = require("project/history")
+local localcache = require("cache/localcache")
--local profiler = require("base/profiler")
-- init the option menu
@@ -267,7 +267,8 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
-- save command lines to history and we need to make sure that the .xmake directory is not generated everywhere
local skip_history = (os.getenv('XMAKE_SKIP_HISTORY') or ''):trim()
if os.projectfile() and os.isfile(os.projectfile()) and os.isdir(config.directory()) and skip_history == '' then
- history("local.history"):save("cmdlines", option.cmdline())
+ localcache.set("history", "cmdlines", option.cmdline())
+ localcache.save("history")
end
-- get task instance
diff --git a/xmake/core/package/repository.lua b/xmake/core/package/repository.lua
index 38f0c15b1..736517d00 100644
--- a/xmake/core/package/repository.lua
+++ b/xmake/core/package/repository.lua
@@ -26,9 +26,10 @@ local _instance = _instance or {}
local utils = require("base/utils")
local string = require("base/string")
local global = require("base/global")
-local cache = require("project/cache")
local config = require("project/config")
local interpreter = require("base/interpreter")
+local localcache = require("cache/localcache")
+local globalcache = require("cache/globalcache")
-- new an instance
function _instance.new(name, url, branch, directory, is_global)
@@ -42,8 +43,6 @@ function _instance.new(name, url, branch, directory, is_global)
instance._BRANCH = branch
instance._DIRECTORY = directory
instance._IS_GLOBAL = is_global
-
- -- ok
return instance
end
@@ -119,21 +118,11 @@ end
-- get cache
function repository._cache(is_global)
-
- -- get position
- local position = is_global and "global" or "local"
-
- -- get it from cache first if exists
- if repository._CACHE and repository._CACHE[position] then
- return repository._CACHE[position]
+ if is_global then
+ return globalcache.cache("repository")
+ else
+ return localcache.cache("repository")
end
-
- -- init cache
- repository._CACHE = repository._CACHE or {}
- repository._CACHE[position] = cache(position .. ".repository")
-
- -- ok
- return repository._CACHE[position]
end
-- the interpreter
@@ -153,8 +142,6 @@ function repository._interpreter()
-- save interpreter
repository._INTERPRETER = interp
-
- -- ok?
return interp
end
@@ -207,8 +194,6 @@ function repository.load(name, url, branch, is_global)
-- save instance to the cache
repository._REPOS[name] = instance
-
- -- ok
return instance
end
@@ -243,9 +228,7 @@ function repository.add(name, url, branch, is_global)
-- save repositories
repository._cache(is_global):set("repositories", repositories)
-
- -- flush it
- repository._cache(is_global):flush()
+ repository._cache(is_global):save()
return true
end
@@ -263,20 +246,14 @@ function repository.remove(name, is_global)
-- save repositories
repository._cache(is_global):set("repositories", repositories)
-
- -- flush it
- repository._cache(is_global):flush()
+ repository._cache(is_global):save()
return true
end
-- clear all repositories
function repository.clear(is_global)
-
- -- clear repositories
repository._cache(is_global):set("repositories", {})
-
- -- flush it
- repository._cache(is_global):flush()
+ repository._cache(is_global):save()
return true
end
diff --git a/xmake/core/project/history.lua b/xmake/core/project/history.lua
index 9f36167b3..f34874fd1 100644
--- a/xmake/core/project/history.lua
+++ b/xmake/core/project/history.lua
@@ -27,7 +27,7 @@ local io = require("base/io")
local table = require("base/table")
local utils = require("base/utils")
local string = require("base/string")
-local cache = require("project/cache")
+local cache = require("cache/localcache")
-- the cache instance
--
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua
index fd343b8a6..4cee0d494 100644
--- a/xmake/core/project/option.lua
+++ b/xmake/core/project/option.lua
@@ -33,7 +33,7 @@ local global = require("base/global")
local scopeinfo = require("base/scopeinfo")
local interpreter = require("base/interpreter")
local config = require("project/config")
-local cache = require("project/cache")
+local localcache = require("cache/localcache")
local linker = require("tool/linker")
local compiler = require("tool/compiler")
local sandbox = require("sandbox/sandbox")
@@ -373,17 +373,7 @@ end
-- get cache
function option._cache()
-
- -- get it from cache first if exists
- if option._CACHE then
- return option._CACHE
- end
-
- -- init cache
- option._CACHE = cache("local.option")
-
- -- ok
- return option._CACHE
+ return localcache.cache("option")
end
-- get option apis
@@ -496,7 +486,7 @@ end
-- save all options to the cache file
function option.save()
- option._cache():flush()
+ option._cache():save()
end
-- return module
diff --git a/xmake/core/project/requireinfo.lua b/xmake/core/project/requireinfo.lua
index 04d8e89e4..205b7f6e9 100644
--- a/xmake/core/project/requireinfo.lua
+++ b/xmake/core/project/requireinfo.lua
@@ -22,29 +22,19 @@
local requireinfo = requireinfo or {}
-- load modules
-local io = require("base/io")
-local os = require("base/os")
-local path = require("base/path")
-local table = require("base/table")
-local utils = require("base/utils")
-local cache = require("project/cache")
-local config = require("project/config")
-local semver = require("base/semver")
-local sandbox = require("sandbox/sandbox")
+local io = require("base/io")
+local os = require("base/os")
+local path = require("base/path")
+local table = require("base/table")
+local utils = require("base/utils")
+local config = require("project/config")
+local semver = require("base/semver")
+local sandbox = require("sandbox/sandbox")
+local localcache = require("cache/localcache")
-- get cache
function requireinfo._cache()
-
- -- get it from cache first if exists
- if requireinfo._CACHE then
- return requireinfo._CACHE
- end
-
- -- init cache
- requireinfo._CACHE = cache("local.requires")
-
- -- ok
- return requireinfo._CACHE
+ return localcache.cache("package")
end
-- save the requires info to the cache
@@ -64,7 +54,7 @@ function requireinfo:save()
-- save it
requireinfo._cache():set(self:name(), self._INFO)
- requireinfo._cache():flush()
+ requireinfo._cache():save()
end
-- clear the requireinfo
diff --git a/xmake/core/sandbox/modules/import/core/project/cache.lua b/xmake/core/sandbox/modules/import/core/cache/configcache.lua
index 1397e7cfe..ae0e4181c 100644
--- a/xmake/core/sandbox/modules/import/core/project/cache.lua
+++ b/xmake/core/sandbox/modules/import/core/cache/configcache.lua
@@ -15,9 +15,9 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki
--- @file cache.lua
+-- @file configcache.lua
--
-- return module
-return require("project/cache")
+return require("cache/configcache")
diff --git a/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua b/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua
index 58c3ec783..89ba5494e 100644
--- a/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua
+++ b/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua
@@ -22,17 +22,17 @@
local sandbox_core_sandbox = sandbox_core_sandbox or {}
-- load modules
-local sandbox = require("sandbox/sandbox")
-local raise = require("sandbox/modules/raise")
-local try = require("sandbox/modules/try")
-local catch = require("sandbox/modules/catch")
-local utils = require("base/utils")
-local table = require("base/table")
-local colors = require("base/colors")
-local dump = require("base/dump")
-local option = require("base/option")
-local scheduler = require("base/scheduler")
-local history = require("project/history")
+local sandbox = require("sandbox/sandbox")
+local raise = require("sandbox/modules/raise")
+local try = require("sandbox/modules/try")
+local catch = require("sandbox/modules/catch")
+local utils = require("base/utils")
+local table = require("base/table")
+local colors = require("base/colors")
+local dump = require("base/dump")
+local option = require("base/option")
+local scheduler = require("base/scheduler")
+local globalcache = require("cache/globalcache")
-- print variables for interactive mode
function sandbox_core_sandbox._interactive_dump(...)
@@ -82,7 +82,7 @@ function sandbox_core_sandbox.interactive()
readline.clear_history()
-- load history
- replhistory = history("global.history"):load("replhistory") or {}
+ replhistory = globalcache.get("history", "replhistory") or {}
for _, ln in ipairs(replhistory) do
readline.add_history(ln)
end
@@ -110,8 +110,9 @@ function sandbox_core_sandbox.interactive()
local entries = readline.history_list()
if #entries > #replhistory then
for i = #replhistory + 1, #entries do
- history("global.history"):save("replhistory", entries[i].line)
+ globalcache.set("history", "replhistory", entries[i].line)
end
+ globalcache.save("history")
end
-- clear history
diff --git a/xmake/core/sandbox/modules/import/lib/detect/cache.lua b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
index d8b568416..743b75c80 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/cache.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
@@ -22,33 +22,20 @@
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 cache = require("project/cache")
-local project = require("project/project")
-local sandbox = require("sandbox/sandbox")
-local raise = require("sandbox/modules/raise")
-
--- get detect cache instance
-function sandbox_lib_detect_cache._instance()
- local detectcache = sandbox_lib_detect_cache._INSTANCE or cache(os.isfile(project.rootfile()) and "local.detect" or "memory.detect")
- sandbox_lib_detect_cache._INSTANCE = detectcache
- return detectcache
-end
+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)
-
- -- get detect cache
- local detectcache = sandbox_lib_detect_cache._instance()
-
- -- attempt to get result from cache first
local cacheinfo = detectcache:get(name)
if cacheinfo == nil then
cacheinfo = {}
@@ -63,13 +50,8 @@ end
-- @param info the cache info
--
function sandbox_lib_detect_cache.save(name, info)
-
- -- get detect cache
- local detectcache = sandbox_lib_detect_cache._instance()
-
- -- save cache info
detectcache:set(name, info)
- detectcache:flush()
+ detectcache:save()
end
-- clear detect cache
@@ -77,11 +59,6 @@ end
-- @param name the cache name. e.g. find_program, find_programver, ..
--
function sandbox_lib_detect_cache.clear(name)
-
- -- get detect cache
- local detectcache = sandbox_lib_detect_cache._instance()
-
- -- clear cache info
if name then
detectcache:set(name, {})
else
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index dc375251c..5397e488e 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -22,18 +22,18 @@
local sandbox_lib_detect_find_program = sandbox_lib_detect_find_program or {}
-- load modules
-local os = require("base/os")
-local path = require("base/path")
-local option = require("base/winos")
-local table = require("base/table")
-local utils = require("base/utils")
-local option = require("base/option")
-local project = require("project/project")
-local sandbox = require("sandbox/sandbox")
-local raise = require("sandbox/modules/raise")
-local vformat = require("sandbox/modules/vformat")
-local cache = require("sandbox/modules/import/lib/detect/cache")
-local scheduler = require("sandbox/modules/import/core/base/scheduler")
+local os = require("base/os")
+local path = require("base/path")
+local option = require("base/winos")
+local table = require("base/table")
+local utils = require("base/utils")
+local option = require("base/option")
+local project = require("project/project")
+local detectcache = require("cache/detectcache")
+local sandbox = require("sandbox/sandbox")
+local raise = require("sandbox/modules/raise")
+local vformat = require("sandbox/modules/vformat")
+local scheduler = require("sandbox/modules/import/core/base/scheduler")
-- globals
local checking = nil
@@ -255,8 +255,7 @@ function sandbox_lib_detect_find_program.main(name, opt)
end
-- attempt to get result from cache first
- local cacheinfo = cache.load(cachekey)
- local result = cacheinfo[name]
+ local result = detectcache:get2(cachekey, name)
if result ~= nil and not opt.force then
return result and result or nil
end
@@ -279,10 +278,8 @@ function sandbox_lib_detect_find_program.main(name, opt)
checking = nil
-- cache result
- cacheinfo[name] = result and result or false
-
- -- save cache info
- cache.save(cachekey, cacheinfo)
+ detectcache:set2(cachekey, name, result and result or false)
+ detectcache:save()
-- trace
if option.get("verbose") or opt.verbose then
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
index df5cae0eb..daa6b3ea5 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
@@ -22,16 +22,16 @@
local sandbox_lib_detect_find_programver = sandbox_lib_detect_find_programver 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 semver = require("base/semver")
-local project = require("project/project")
-local sandbox = require("sandbox/sandbox")
-local raise = require("sandbox/modules/raise")
-local cache = require("sandbox/modules/import/lib/detect/cache")
+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 semver = require("base/semver")
+local project = require("project/project")
+local detectcache = require("cache/detectcache")
+local sandbox = require("sandbox/sandbox")
+local raise = require("sandbox/modules/raise")
-- find program version
--
@@ -62,8 +62,7 @@ function sandbox_lib_detect_find_programver.main(program, opt)
end
-- attempt to get result from cache first
- local cacheinfo = cache.load(cachekey)
- local result = cacheinfo[program]
+ local result = detectcache:get2(cachekey, program)
if result ~= nil and not opt.force then
return result and result or nil
end
@@ -99,8 +98,8 @@ function sandbox_lib_detect_find_programver.main(program, opt)
end
-- save result
- cacheinfo[program] = result and result or false
- cache.save(cachekey, cacheinfo)
+ detectcache:set2(cachekey, program, result and result or false)
+ detectcache:save()
return result
end
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index ec07d1a24..053209fd6 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -31,6 +31,7 @@ local global = require("base/global")
local option = require("base/option")
local interpreter = require("base/interpreter")
local config = require("project/config")
+local localcache = require("cache/localcache")
local language = require("language/language")
local sandbox = require("sandbox/sandbox")
local sandbox_module = require("sandbox/modules/import/core/sandbox/module")
@@ -40,9 +41,9 @@ function _instance.new(name, info, cachekey, configs)
local instance = table.inherit(_instance)
instance._NAME = name
instance._INFO = info
- instance._CACHE = require("sandbox/modules/import/lib/detect/cache")
+ instance._CACHE = localcache.cache("toolchain")
instance._CACHEKEY = cachekey
- instance._CONFIGS = instance._CACHE.load(cachekey) or {}
+ instance._CONFIGS = instance._CACHE:get(cachekey) or {}
for k, v in pairs(configs) do
instance._CONFIGS[k] = v
end
@@ -227,7 +228,8 @@ end
-- save user configs
function _instance:configs_save()
- self._CACHE.save(self:cachekey(), self._CONFIGS)
+ self._CACHE:set(self:cachekey(), self._CONFIGS)
+ self._CACHE:save()
end
-- do check, we only check it once for all architectures
diff --git a/xmake/plugins/macro/main.lua b/xmake/plugins/macro/main.lua
index dbc94efe7..cd5aefb8e 100644
--- a/xmake/plugins/macro/main.lua
+++ b/xmake/plugins/macro/main.lua
@@ -21,7 +21,7 @@
-- imports
import("core.base.option")
import("core.project.config")
-import("core.project.history")
+import("core.cache.localcache")
-- the macro directories
function _directories()
@@ -46,32 +46,22 @@ function _directory(macroname)
-- check
assert(macrodir, "macro(%s) not found!", macroname)
-
- -- ok
return macrodir
end
-- the readable macro file
function _rfile(macroname)
-
- -- is anonymous?
if macroname == '.' then
macroname = "anonymous"
end
-
- -- get it
return path.join(_directory(macroname), macroname .. ".lua")
end
-- the writable macro file
function _wfile(macroname)
-
- -- is anonymous?
if macroname == '.' then
macroname = "anonymous"
end
-
- -- get it
return path.join(path.join(config.directory(), "macros"), macroname .. ".lua")
end
@@ -99,21 +89,14 @@ end
-- list macros
function _list()
-
- -- trace
cprint("${bright}macros:")
-
- -- find all macros
for _, macroname in ipairs(macros(".<anonymous>")) do
- -- show it
print(" " .. macroname)
end
end
-- show macro
function _show(macroname)
-
- -- show it
local file = _rfile(macroname)
if os.isfile(file) then
io.cat(file)
@@ -124,8 +107,6 @@ end
-- clear all macros
function _clear()
-
- -- clear all
os.rm(path.join(config.directory(), "macros"))
end
@@ -207,16 +188,15 @@ end
-- begin to record macro
function _begin()
-
- -- patch begin tag to the history: cmdlines
- history("local.history"):save("cmdlines", "__macro_begin__")
+ localcache.set("history", "cmdlines", "__macro_begin__")
+ localcache.save("history")
end
-- end to record macro
function _end(macroname)
-- load the history: cmdlines
- local cmdlines = history("local.history"):load("cmdlines")
+ local cmdlines = localcache.get("history", "cmdlines")
-- get the last macro block
local begin = false
@@ -258,7 +238,8 @@ function _end(macroname)
end
-- patch end tag to the history: cmdlines
- history("local.history"):save("cmdlines", "__macro_end__")
+ localcache.set("history", "cmdlines", "__macro_end__")
+ localcache.save("history")
-- open the macro file
local file = io.open(_wfile(macroname), "w")
@@ -293,7 +274,7 @@ function _run(macroname)
if macroname == ".." then
-- load the history: cmdlines
- local cmdlines = history("local.history"):load("cmdlines")
+ local cmdlines = localcache.get("history", "cmdlines")
-- get the last command
local lastcmd = nil
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index dd5ed48fe..4c78016c9 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -23,8 +23,8 @@ import("core.base.option")
import("core.base.semver")
import("core.base.hashset")
import("core.project.config")
-import("core.project.cache")
import("core.project.project")
+import("core.cache.configcache")
import("core.platform.platform")
import("core.tool.compiler")
import("core.tool.linker")
@@ -155,7 +155,6 @@ function _make_targetinfo(mode, arch, target)
if targetinfo.languages:find("c++17", 1, true) or targetinfo.languages:find("cxx17", 1, true) then
targetinfo.cxxlanguage = "stdcpp17"
end
- local configcache = cache("local.config")
local flags = {}
for k, v in pairs(configcache:get("options_" .. target:name())) do
if k ~= "plat" and k ~= "mode" and k ~= "arch" and k ~= "clean" and k ~= "buildir" then