summaryrefslogtreecommitdiff
path: root/xmake/core/package/addon.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-15 00:25:51 +0800
committerruki <[email protected]>2026-08-15 00:25:51 +0800
commitea1af59107ffd962ad8e063577e7546908d5a731 (patch)
tree3701cf47d747065271d4ca0747b2853dbdcfe313 /xmake/core/package/addon.lua
parentca9239022e1cba0faf054e8fe2f178a466149b04 (diff)
add addon workdir
Diffstat (limited to 'xmake/core/package/addon.lua')
-rw-r--r--xmake/core/package/addon.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/xmake/core/package/addon.lua b/xmake/core/package/addon.lua
index 731c673ab..4a4c8f50a 100644
--- a/xmake/core/package/addon.lua
+++ b/xmake/core/package/addon.lua
@@ -294,6 +294,26 @@ function addon.manifest(sourcedir)
return manifest
end
+-- get a working directory which has no project
+--
+-- we need it to run the sub-processes of the addons, e.g. `xrepo install --addon`,
+-- otherwise they would load the project of the current directory again
+--
+-- @note we cannot use `os.tmpdir()` directly, it is shared by all the commands,
+-- e.g. a stray `xmake.lua` in it would break the isolation
+--
+-- @note we can share it between the processes, we only use it as the working directory
+-- and never write anything into it, @see private/action/addon/impl/xrepo.lua
+--
+function addon.workdir()
+ local workdir = path.join(os.tmpdir(), "addons", "working")
+ if not os.isdir(workdir) then
+ -- it may be created by the other processes at the same time, we can ignore it
+ os.mkdir(workdir)
+ end
+ return workdir
+end
+
-- the install directory of addons, e.g. ~/.xmake/addons
function addon.installdir()
return path.join(global.directory(), "addons")