summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-03-20 00:39:40 +0800
committerruki <[email protected]>2020-03-19 21:58:00 +0800
commitb01bc45cfb6a2a2c8da72f3b6467605e4d4f259c (patch)
treee29712b65dc7942ad26169d924df0737c9ac2cb3
parentce3f5dcee88458f46c97fffec3bca2d8bbea7e7e (diff)
improve global directory
-rw-r--r--xmake/core/base/global.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua
index d777d1243..b70e139fd 100644
--- a/xmake/core/base/global.lua
+++ b/xmake/core/base/global.lua
@@ -94,7 +94,16 @@ end
-- get the global configure directory
function global.directory()
if global._DIRECTORY == nil then
- local rootdir = os.getenv("XMAKE_GLOBALDIR") or path.translate("~")
+ local rootdir = os.getenv("XMAKE_GLOBALDIR")
+ if not rootdir then
+ -- compatible with the old `%appdata%/.xmake` directory if it exists
+ local appdata = (os.host() == "windows") and os.getenv("APPDATA")
+ if appdata and os.isdir(path.join(appdata, ".xmake")) then
+ rootdir = appdata
+ else
+ rootdir = path.translate("~")
+ end
+ end
global._DIRECTORY = path.join(rootdir, ".xmake")
end
return global._DIRECTORY