summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-14 22:41:11 +0800
committerruki <[email protected]>2022-07-14 10:07:53 +0800
commit6569e547c050e311533d78c664f1f1b34ef3b5b5 (patch)
tree0aca36b379e300834a615860b523851be49cd82d
parentc7e36432d1c9100a5e9fb2c60d511c616daa5888 (diff)
#2566 add package.include_external_headers policy
-rw-r--r--xmake/core/project/policy.lua6
-rw-r--r--xmake/modules/private/action/require/impl/package.lua10
2 files changed, 13 insertions, 3 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index e73f67a83..ed2fd42de 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -47,9 +47,9 @@ function policy.policies()
["build.merge_archive"] = {description = "Enable merge archive intead of linking for all dependent targets.", default = false, type = "boolean"},
-- C/C++ build cache
["build.ccache"] = {description = "Enable C/C++ build cache.", type = "boolean"},
- -- Enable build warning output, it's disabled by default and we need `xmake -w/-vD` to look at it.
+ -- enable build warning output, it's disabled by default and we need `xmake -w/-vD` to look at it.
["build.warning"] = {description = "Enable build warning output.", type = "boolean"},
- -- Enable LTO linker-time optimization for c/c++ building.
+ -- enable LTO linker-time optimization for c/c++ building.
["build.optimization.lto"] = {description = "Enable LTO linker-time optimization for c/c++ building.", type = "boolean"},
-- preprocessor configuration for ccache/distcc, we can disable linemarkers to speed up preprocess
["preprocessor.linemarkers"] = {description = "Enable linemarkers for preprocessor.", default = true, type = "boolean"},
@@ -65,6 +65,8 @@ function policy.policies()
["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"},
+ -- use includes as external header files? e.g. -isystem ..
+ ["package.include_external_headers"] = {description = "Use includes as external headers.", 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"}
}
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 5c644be1c..15d642644 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -462,7 +462,7 @@ end
-- init requireinfo
function _init_requireinfo(requireinfo, package, opt)
- -- pass root toolchains to top library package
+ -- pass root configs to top library package
requireinfo.configs = requireinfo.configs or {}
if opt.is_toplevel then
requireinfo.is_toplevel = true
@@ -491,6 +491,13 @@ function _finish_requireinfo(requireinfo, package)
if requireinfo.configs.vs_runtime == nil and package:is_plat("windows") then
requireinfo.configs.vs_runtime = "MT"
end
+ local external = project.policy("package.include_external_headers")
+ if external == nil then
+ external = package:policy("package.include_external_headers")
+ end
+ if requireinfo.external == nil and external ~= nil then
+ requireinfo.external = external
+ end
end
-- we need ensure readonly configs
for _, name in ipairs(table.keys(requireinfo.configs)) do
@@ -620,6 +627,7 @@ function _inherit_parent_configs(requireinfo, package, parentinfo)
end
requireinfo_configs.toolchains = requireinfo_configs.toolchains or parentinfo_configs.toolchains
requireinfo_configs.vs_runtime = requireinfo_configs.vs_runtime or parentinfo_configs.vs_runtime
+ requireinfo_configs.lto = requireinfo_configs.lto or parentinfo_configs.lto
requireinfo.configs = requireinfo_configs
end
end