diff options
Diffstat (limited to 'xmake/core')
| -rw-r--r-- | xmake/core/base/global.lua | 5 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/global.lua | 60 |
3 files changed, 16 insertions, 51 deletions
diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua index d493235d1..61d9d9e3b 100644 --- a/xmake/core/base/global.lua +++ b/xmake/core/base/global.lua @@ -110,6 +110,11 @@ function global.directory() return global._DIRECTORY end +-- get the global cache directory +function global.cachedir() + return global.get("cachedir") or path.join(global.directory(), "cache") +end + -- load the global configuration function global.load() diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index cdc0dfcef..135329d10 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1344,7 +1344,7 @@ end -- the cache directory function package.cachedir() - return path.join(global.directory(), "cache", "packages", os.date("%y%m")) + return path.join(global.cachedir(), "packages", os.date("%y%m")) end -- the install directory diff --git a/xmake/core/sandbox/modules/import/core/base/global.lua b/xmake/core/sandbox/modules/import/core/base/global.lua index 24cc441df..5b66142fc 100644 --- a/xmake/core/sandbox/modules/import/core/base/global.lua +++ b/xmake/core/sandbox/modules/import/core/base/global.lua @@ -28,64 +28,24 @@ local global = require("base/global") local platform = require("platform/platform") local raise = require("sandbox/modules/raise") --- get the configure -function sandbox_core_base_global.get(name) - return global.get(name) -end - --- set the configure --- --- @param name the name --- @param value the value --- @param opt the argument options, e.g. {readonly = false, force = false} --- -function sandbox_core_base_global.set(name, value, opt) - global.set(name, value, opt) -end - --- this config name is readonly? -function sandbox_core_base_global.readonly(name) - return config.readonly(name) -end - --- dump the configure -function sandbox_core_base_global.dump() - global.dump() -end +-- export some readonly interfaces +sandbox_core_base_global.get = global.get +sandbox_core_base_global.set = global.set +sandbox_core_base_global.readonly = global.readonly +sandbox_core_base_global.dump = global.dump +sandbox_core_base_global.clear = global.clear +sandbox_core_base_global.options = global.options +sandbox_core_base_global.filepath = global.filepath +sandbox_core_base_global.directory = global.directory +sandbox_core_base_global.cachedir = global.cachedir -- save the configure function sandbox_core_base_global.save() - - -- save it local ok, errors = global.save() if not ok then raise(errors) end end --- clear the configure -function sandbox_core_base_global.clear() - return global.clear() -end - --- get all options -function sandbox_core_base_global.options() - return global.options() -end - --- get the configure file path -function sandbox_core_base_global.filepath() - local filepath = global.filepath() - assert(filepath) - return filepath -end - --- get the configure directory -function sandbox_core_base_global.directory() - local dir = global.directory() - assert(dir) - return dir -end - -- return module return sandbox_core_base_global |
