summaryrefslogtreecommitdiff
path: root/xmake/core/package/package.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-04-13 23:12:08 +0800
committerruki <[email protected]>2021-04-13 23:12:08 +0800
commitb00f05dd421c8fd8aab0cc6716ecedf185fe32e4 (patch)
tree06a8262ee98c34f9c56e9e46c17c8970809947fa /xmake/core/package/package.lua
parent05f8db002c1fc6078c561e1d3b3329b7fc2aff5e (diff)
add package directory envs
Diffstat (limited to 'xmake/core/package/package.lua')
-rw-r--r--xmake/core/package/package.lua20
1 files changed, 17 insertions, 3 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index c4db97454..8370961eb 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -1641,13 +1641,27 @@ function package.apis()
end
-- the cache directory
-function package.cachedir()
- return path.join(global.cachedir(), "packages", os.date("%y%m"))
+function package.cachedir(opt)
+ opt = opt or {}
+ local cachedir = package._CACHEDIR
+ if not cachedir then
+ cachedir = os.getenv("XMAKE_PKG_CACHEDIR") or path.join(global.cachedir(), "packages")
+ package._CACHEDIR = cachedir
+ end
+ if opt.rootonly then
+ return cachedir
+ end
+ return path.join(cachedir, os.date("%y%m"))
end
-- the install directory
function package.installdir()
- return global.get("pkg_installdir") or path.join(global.directory(), "packages")
+ local installdir = package._INSTALLDIR
+ if not installdir then
+ installdir = os.getenv("XMAKE_PKG_INSTALLDIR") or global.get("pkg_installdir") or path.join(global.directory(), "packages")
+ package._INSTALLDIR = installdir
+ end
+ return installdir
end
-- the search directories