diff options
| author | ruki <[email protected]> | 2017-04-01 13:59:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-04-01 13:59:49 +0800 |
| commit | 16b5b77af09b348398fe46b2dcde0b5c0574abb5 (patch) | |
| tree | eec7205a3cc1261e0f4f45985802ba2ec8b46b77 | |
| parent | cb5af728adf9d0d2f125c3054d1b6670d3debb9a (diff) | |
fix cache dir bug
| -rw-r--r-- | xmake/core/project/history.lua | 23 | ||||
| -rw-r--r-- | xmake/core/project/option.lua | 25 |
2 files changed, 39 insertions, 9 deletions
diff --git a/xmake/core/project/history.lua b/xmake/core/project/history.lua index 86cb41410..a6ed24cb3 100644 --- a/xmake/core/project/history.lua +++ b/xmake/core/project/history.lua @@ -31,7 +31,22 @@ 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.history") +local cache = require("project/cache") + +-- get cache +function history._cache() + + -- get it from cache first if exists + if history._CACHE then + return history._CACHE + end + + -- init cache + history._CACHE = cache("local.history") + + -- ok + return history._CACHE +end -- save history function history.save(key, value) @@ -51,15 +66,15 @@ function history.save(key, value) table.insert(values, value) -- save history - cache:set(key, values) - cache:flush() + history._cache():set(key, values) + history._cache():flush() end -- load history function history.load(key) -- load it - return cache:get(key) + return history._cache():get(key) end -- return module: history diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua index 5d0b6466d..23f0772ad 100644 --- a/xmake/core/project/option.lua +++ b/xmake/core/project/option.lua @@ -33,12 +33,27 @@ local table = require("base/table") local utils = require("base/utils") local option_ = require("base/option") local config = require("project/config") -local cache = require("project/cache")("local.option") +local cache = require("project/cache") local linker = require("tool/linker") local compiler = require("tool/compiler") local sandbox = require("sandbox/sandbox") local language = require("language/language") +-- 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 +end + -- check link function option:_check_link(sourcefile, objectfile, targetfile) @@ -512,15 +527,15 @@ end function option:save() -- save it - cache:set(self:name(), self._INFO) - cache:flush() + option._cache():set(self:name(), self._INFO) + option._cache():flush() end -- clear the option info for cache function option:clear() -- clear it - cache:set(self:name(), nil) + option._cache():set(self:name(), nil) end -- get the option name @@ -537,7 +552,7 @@ function option.load(name) assert(name) -- get info - local info = cache:get(name) + local info = option._cache():get(name) if info == nil then return end |
