From b01bc45cfb6a2a2c8da72f3b6467605e4d4f259c Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 20 Mar 2020 00:39:40 +0800 Subject: improve global directory --- xmake/core/base/global.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- cgit v1.3.1