Skip to content

Commit

Permalink
Merge pull request #4485 from xmake-io/local
Browse files Browse the repository at this point in the history
Support package.install_locally
  • Loading branch information
waruqi committed Dec 17, 2023
2 parents c1948fb + c24eea4 commit ccbcebd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 26 additions & 1 deletion xmake/core/package/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions xmake/core/project/policy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Expand Down

0 comments on commit ccbcebd

Please sign in to comment.