summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-12-17 08:26:01 +0800
committerGitHub <[email protected]>2023-12-17 08:26:01 +0800
commitccbcebdd9e2cb187d1621188a6dff7006a2c8155 (patch)
tree94345b2548afe856d807116689dc3f66fb9c7876
parentc1948fb4fe3d9d9821195b3bc0e1270539882f97 (diff)
parentc24eea4f7322424be642842aa5840156460d1fbb (diff)
Merge pull request #4485 from xmake-io/local
Support package.install_locally
-rw-r--r--xmake/core/package/package.lua27
-rw-r--r--xmake/core/project/policy.lua2
2 files changed, 28 insertions, 1 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 1073c0a45..8704b3df1 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -642,7 +642,15 @@ end
-- is local package?
-- we will use local installdir and cachedir in current project
function _instance:is_local()
- return self:is_source_embed() or self:is_binary_embed() or self:is_thirdparty()
+ return self._IS_LOCAL or self:is_source_embed() or self:is_binary_embed() or self:is_thirdparty()
+end
+
+-- mark it as local package
+function _instance:_mark_as_local(is_local)
+ if self:is_local() ~= is_local then
+ self._INSTALLDIR = nil
+ self._IS_LOCAL = is_local
+ end
end
-- use external includes?
@@ -1807,6 +1815,23 @@ function _instance:fetch(opt)
external = self:use_external_includes()
end
+ -- always install to the local project directory?
+ -- @see https://github.com/xmake-io/xmake/pull/4376
+ local install_locally
+ if project and project.policy("package.install_locally") then
+ install_locally = true
+ end
+ if install_locally == nil and self:policy("package.install_locally") then
+ install_locally = true
+ end
+ if not self:is_local() and install_locally and system ~= true then
+ local has_global = os.isfile(self:manifest_file())
+ self:_mark_as_local(true)
+ if has_global and not os.isfile(self:manifest_file()) then
+ self:_mark_as_local(false)
+ end
+ end
+
-- fetch binary tool?
fetchinfo = nil
local is_system = nil
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index 5d1e47c53..84f29dd06 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -100,6 +100,8 @@ function policy.policies()
["package.install_only"] = {description = "Only install packages from remote.", type = "boolean"},
-- Always install packages every time
["package.install_always"] = {description = "Always install packages every time.", type = "boolean"},
+ -- Install packages in the local project folder
+ ["package.install_locally"] = {description = "Install packages in the local project folder.", default = false, type = "boolean"},
-- Set custom headers when downloading package
["package.download.http_headers"] = {description = "Set the custom http headers when downloading package."},
-- Use includes as external header files? e.g. -isystem ..