summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-28 23:07:44 +0800
committerruki <[email protected]>2022-05-28 23:07:44 +0800
commit5d70ef54c67908120159570254d2c194bb6c6f75 (patch)
treeef8b0e9d50a5435d5b2e0f653ae8619452062605
parent5eeeca1a1b2f3a0ca5b4a7e5372398cb758af43f (diff)
add package policy
-rw-r--r--xmake/core/package/package.lua10
-rw-r--r--xmake/core/project/policy.lua4
2 files changed, 14 insertions, 0 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 6862d320b..7126a2619 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -485,6 +485,10 @@ end
-- is fetch only?
function _instance:is_fetchonly()
+ local project = package._project()
+ if project and project.policy("package.fetch_only") then
+ return true
+ end
return self:get("fetch") and not self:get("install")
end
@@ -1466,6 +1470,12 @@ function _instance:fetch(opt)
return fetchinfo
end
+ -- install only?
+ local project = package._project()
+ if project and project.policy("package.install_only") then
+ return
+ end
+
-- fetch the require version
local require_ver = opt.version or self:requireinfo().version
if not self:is_thirdparty() and not require_ver:find('.', 1, true) then
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index 775ecef63..e8921cefb 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -53,6 +53,10 @@ function policy.policies()
["package.requires_lock"] = {description = "Enable xmake-requires.lock to lock required packages.", default = false, type = "boolean"},
-- enable the precompiled packages, it will be enabled by default
["package.precompiled"] = {description = "Enable precompiled packages.", default = true, type = "boolean"},
+ -- only fetch packages on system
+ ["package.fetch_only"] = {description = "Only fetch packages on system.", type = "boolean"},
+ -- only install packages from remote
+ ["package.install_only"] = {description = "Only install packages from remote.", type = "boolean"},
-- inherit the configs from the external command arguments, e.g. toolchains, `xmake f --toolchain=`
["package.inherit_external_configs"] = {description = "Inherit the configs from the external command arguments.", default = true, type = "boolean"}
}