summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-17 23:27:42 +0800
committerruki <[email protected]>2018-09-17 14:46:14 +0800
commitb39865ce22ec806099bd022f47fcb90a4ac42034 (patch)
treeb8f87745eff3541b5691941dc69d03b9060a4971
parenteceee6a9d0f2f76e1b8cae374dbfbc1bacbc7389 (diff)
add env to modify tmpdir and globaldir
-rw-r--r--xmake/core/base/global.lua5
-rw-r--r--xmake/core/base/os.lua8
2 files changed, 11 insertions, 2 deletions
diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua
index f041c759d..9f8f5c08d 100644
--- a/xmake/core/base/global.lua
+++ b/xmake/core/base/global.lua
@@ -103,7 +103,10 @@ end
-- get the global configure directory
function global.directory()
- return path.translate("~/.xmake")
+ if global._ROOTDIR == nil then
+ global._ROOTDIR = os.getenv("XMAKE_GLOBALDIR") or path.translate("~/.xmake")
+ end
+ return global._ROOTDIR
end
-- load the global configure
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 3a134f7ed..3ea8badc7 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -483,11 +483,17 @@ function os.tmpdir()
end
end
+ -- get root tmpdir
+ if os._ROOT_TMPDIR == nil then
+ os._ROOT_TMPDIR = os.getenv("XMAKE_TMPDIR") or os._tmpdir()
+ end
+ local tmpdir_root = os._ROOT_TMPDIR
+
-- make sub-directory name
local subdir = (os._FAKEROOT and ".xmakefake" or ".xmake") .. (os.uid().euid or "")
-- get a temporary directory for each user
- local tmpdir = path.join(os._tmpdir(), subdir, os.date("%y%m%d"))
+ local tmpdir = path.join(tmpdir_root, subdir, os.date("%y%m%d"))
-- ensure this directory exist and remove the previous directory
if not os.isdir(tmpdir) then