From 55e6f6992aa23a1ae1f5529aeb83021e40e4198b Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 26 Aug 2019 23:18:07 +0800 Subject: improve config and global directory --- xmake/core/base/global.lua | 7 ++++--- xmake/core/project/cache.lua | 6 ------ xmake/core/project/config.lua | 9 +++++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua index 5a4132b1f..1ec21315c 100644 --- a/xmake/core/base/global.lua +++ b/xmake/core/base/global.lua @@ -93,10 +93,11 @@ end -- get the global configure directory function global.directory() - if global._ROOTDIR == nil then - global._ROOTDIR = os.getenv("XMAKE_GLOBALDIR") or path.translate("~/.xmake") + if global._DIRECTORY == nil then + local rootdir = os.getenv("XMAKE_GLOBALDIR") or path.translate("~") + global._DIRECTORY = path.join(rootdir, ".xmake") end - return global._ROOTDIR + return global._DIRECTORY end -- load the global configuration diff --git a/xmake/core/project/cache.lua b/xmake/core/project/cache.lua index 4275fbeb8..9d72eaa3d 100644 --- a/xmake/core/project/cache.lua +++ b/xmake/core/project/cache.lua @@ -88,22 +88,16 @@ end -- get the value function cache:get(name) - - -- get it return self._CACHEDATA[name] end -- set the value function cache:set(name, value) - - -- set it self._CACHEDATA[name] = value end -- clear all function cache:clear() - - -- clear it self._CACHEDATA = {__version = xmake._VERSION_SHORT} end diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 6c914de01..efb9867d0 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -145,12 +145,13 @@ function config.buildir() return buildir end --- get the configure directory +-- get the configure directory on the current host/arch platform function config.directory() - if config._ROOTDIR == nil then - config._ROOTDIR = os.getenv("XMAKE_CONFIGDIR") or path.join(os.projectdir(), ".xmake", os.host(), os.arch()) + if config._DIRECTORY == nil then + local rootdir = os.getenv("XMAKE_CONFIGDIR") or path.join(os.projectdir(), ".xmake") + config._DIRECTORY = path.join(rootdir, os.host(), os.arch()) end - return config._ROOTDIR + return config._DIRECTORY end -- load the project configure -- cgit v1.3.1