summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-06 00:01:01 +0800
committerruki <[email protected]>2022-03-06 00:01:01 +0800
commit9b9bb7c44e9db06f0ca33c6b276b29f85ab699f9 (patch)
treedf283d76242c4b2fcd5390d290fbe7f65a3de83a
parent967769fd1463912ff301b468d333adfab67c0c26 (diff)
add package.inherit_external_configs policy
-rw-r--r--xmake/core/project/policy.lua4
-rw-r--r--xmake/modules/private/action/require/impl/package.lua10
2 files changed, 11 insertions, 3 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index 0841f25b0..f95918283 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -50,7 +50,9 @@ function policy.policies()
-- lock required packages
["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"}
+ ["package.precompiled"] = {description = "Enable precompiled packages.", default = true, 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"}
}
policy._POLICIES = policies
end
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 057b56a99..172e31823 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -461,9 +461,15 @@ function _init_requireinfo(requireinfo, package, opt)
requireinfo.is_toplevel = true
if not package:is_headeronly() then
if package:is_library() then
- requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") or get_config("toolchain")
+ requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains")
+ if package:policy("package.inherit_external_configs") then
+ requireinfo.configs.toolchains = requireinfo.configs.toolchains or get_config("toolchain")
+ end
+ end
+ requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes")
+ if package:policy("package.inherit_external_configs") then
+ requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime")
end
- requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes") or get_config("vs_runtime")
end
end
end