summaryrefslogtreecommitdiff
path: root/xmake/core/package
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core/package')
-rw-r--r--xmake/core/package/addon.lua13
-rw-r--r--xmake/core/package/package.lua20
2 files changed, 27 insertions, 6 deletions
diff --git a/xmake/core/package/addon.lua b/xmake/core/package/addon.lua
index e35a58317..d6798f56f 100644
--- a/xmake/core/package/addon.lua
+++ b/xmake/core/package/addon.lua
@@ -168,12 +168,19 @@ function addon._check_conflicts(dirname, addoninfo)
end
-- the global modules can also conflict with the builtin and the user modules
+ --
+ -- @note the `core.*` modules are in the core directory of the sandbox,
+ -- they are not in `<programdir>/modules`,
+ -- @see core/sandbox/modules/import/core/sandbox/module.lua
+ local moduledirs = {path.join(os.programdir(), "modules"),
+ path.join(os.programdir(), "core", "sandbox", "modules", "import"),
+ path.join(global.directory(), "modules")}
for _, name in ipairs(addoninfo.globalmodules or {}) do
local modulepath = (name:gsub("%.", "/")) .. ".lua"
- for _, moduledir in ipairs({os.programdir(), global.directory()}) do
- if os.isfile(path.join(moduledir, "modules", modulepath)) then
+ for _, moduledir in ipairs(moduledirs) do
+ if os.isfile(path.join(moduledir, modulepath)) then
return string.format("global module(%s) conflicts, it has been provided by %s!\nplease rename it in the addon manifest.",
- name, moduledir == os.programdir() and "xmake" or path.join(moduledir, "modules"))
+ name, moduledir:startswith(os.programdir()) and "xmake" or moduledir)
end
end
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 2d2720fba..3d98a3743 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -2117,11 +2117,17 @@ function _instance:fetch(opt)
-- always install to the local project directory?
-- @see https://github.com/xmake-io/xmake/pull/4376
+ --
+ -- @note the host packages are the tools which build the other packages, e.g. the toolchains,
+ -- they do not depend on the project configuration and they are shared between the projects,
+ -- so they are only installed locally with their own policy
+ -- @see https://github.com/xmake-io/xmake/issues/7716
+ local policyname = self:is_host() and "package.host.install_locally" or "package.install_locally"
local install_locally
- if project and project.policy("package.install_locally") then
+ if project and project.policy(policyname) then
install_locally = true
end
- if install_locally == nil and self:policy("package.install_locally") then
+ if install_locally == nil and self:policy(policyname) then
install_locally = true
end
if not self:is_local() and install_locally and system ~= true then
@@ -3110,12 +3116,20 @@ end
--
-- @param opt the options, e.g. {localdir = true}
-- - localdir: return the local project packages directory (build/.packages)
--- instead of the global directory (~/.xmake/packages)
+-- instead of the global directory (~/.xmake/packages),
+-- it can be overridden with `XMAKE_PKG_LOCALDIR`
--
-- @return the install directory path
--
function package.installdir(opt)
if opt and opt.localdir then
+ -- the parent process passes its local directory to the sub-process which builds
+ -- a package, so the packages it installs locally land in the same place and are
+ -- not installed twice, @see https://github.com/xmake-io/xmake/issues/7716
+ local localdir = os.getenv("XMAKE_PKG_LOCALDIR")
+ if localdir then
+ return path.normalize(path.absolute(localdir))
+ end
return path.join(config.builddir({absolute = true}), ".packages")
end
local installdir = package._INSTALLDIR