summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-20 22:29:59 +0800
committerruki <[email protected]>2022-07-20 22:29:59 +0800
commit5dd962d1b0e51b839f88b580c5586ef8cfca3c60 (patch)
treecf54dc42393ab414e31ad94c3dc6a2940e7c51c8
parented3952947afe5ca5b24bf8dff7ead73d037bee2b (diff)
add package:use_external_includes
-rw-r--r--xmake/core/package/package.lua23
-rw-r--r--xmake/modules/package/tools/xmake.lua9
-rw-r--r--xmake/modules/private/action/require/impl/package.lua7
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua22
4 files changed, 38 insertions, 23 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 9dad30ab1..08a6846a7 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -547,6 +547,24 @@ function _instance:is_local()
return self:is_embed() or self:is_thirdparty()
end
+-- use external includes?
+function _instance:use_external_includes()
+ local external = self:requireinfo().external
+ if external == nil then
+ local project = package._project()
+ if project then
+ external = project.policy("package.include_external_headers")
+ end
+ end
+ if external == nil then
+ external = self:policy("package.include_external_headers")
+ end
+ if external == nil then
+ external = true
+ end
+ return external
+end
+
-- is debug package? (deprecated)
function _instance:debug()
return self:is_debug()
@@ -1509,10 +1527,7 @@ function _instance:fetch(opt)
if opt.external ~= nil then
external = opt.external
else
- external = self:requireinfo().external
- end
- if external == nil then
- external = true
+ external = self:use_external_includes()
end
-- fetch binary tool?
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index 8d9b2f0c4..cfb22f6dd 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -99,13 +99,20 @@ function _get_configs(package, configs)
end
end
local policies = get_config("policies")
- if package:config("lto") then
+ if package:config("lto") and (not policies or not policies:find("build.optimization.lto", 1, true)) then
if policies then
policies = policies .. ",build.optimization.lto"
else
policies = "build.optimization.lto"
end
end
+ if not package:use_external_includes() and (not policies or not policies:find("package.include_external_headers", 1, true)) then
+ if policies then
+ policies = policies .. ",package.include_external_headers:n"
+ else
+ policies = "package.include_external_headers:n"
+ end
+ end
if policies then
table.insert(configs, "--policies=" .. policies)
end
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 174c67148..aa7fc9b96 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -492,13 +492,6 @@ function _finish_requireinfo(requireinfo, package)
requireinfo.configs.vs_runtime = "MT"
end
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
-- we need ensure readonly configs
for _, name in ipairs(table.keys(requireinfo.configs)) do
if package:extraconf("configs", name, "readonly") then
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
index cf91115b4..452292abc 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
@@ -498,7 +498,7 @@ function _make_resource_options_cl(vcxprojfile, flags)
-- get flags string
local flagstr = os.args(flags)
-
+
-- make PreprocessorDefinitions
local defstr = ""
for _, flag in ipairs(flags) do
@@ -644,7 +644,7 @@ function _make_source_options_cuda(vcxprojfile, flags, opt)
end
if not (opt and opt.link) then
-
+
-- make CudaRuntime
local cudart
local cudaruntime = {
@@ -658,7 +658,7 @@ function _make_source_options_cuda(vcxprojfile, flags, opt)
if cudart and cudaruntime[cudart] then
vcxprojfile:print("<CudaRuntime%s>%s</CudaRuntime>", condition, cudaruntime[cudart])
end
-
+
-- handle GPU debug info
if flagstr:find("%-G") then
vcxprojfile:print("<GPUDebugInfo%s>true</GPUDebugInfo>", condition)
@@ -668,7 +668,7 @@ function _make_source_options_cuda(vcxprojfile, flags, opt)
if flagstr:find("%-use_fast_math") then
vcxprojfile:print("<FastMath%s>true</FastMath>", condition)
end
-
+
-- handle relocatable device code
local rdc
for _, flag in ipairs(flags) do
@@ -906,13 +906,13 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo)
end
vcxprojfile:leave("</ClCompile>")
-
+
vcxprojfile:enter("<ResourceCompile>")
-- make resource options
_make_resource_options_cl(vcxprojfile, targetinfo.commonflags.cl)
-
+
vcxprojfile:leave("</ResourceCompile>")
-
+
local cuda = _check_cuda(target)
if cuda then
-- for CUDA linker?
@@ -1080,8 +1080,8 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
-- enter it
local nodename
- if sourcekind == "as" then nodename = "CustomBuild"
- elseif sourcekind == "mrc" then nodename = "ResourceCompile"
+ if sourcekind == "as" then nodename = "CustomBuild"
+ elseif sourcekind == "mrc" then nodename = "ResourceCompile"
elseif sourcekind == "cu" then nodename = "CudaCompile"
elseif sourcekind == "cc" or sourcekind == "cxx" then nodename = "ClCompile"
end
@@ -1219,8 +1219,8 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
-- enter it
local nodename
- if info.sourcekind == "as" then nodename = "CustomBuild"
- elseif info.sourcekind == "mrc" then nodename = "ResourceCompile"
+ if info.sourcekind == "as" then nodename = "CustomBuild"
+ elseif info.sourcekind == "mrc" then nodename = "ResourceCompile"
elseif info.sourcekind == "cu" then nodename = "CudaCompile"
elseif info.sourcekind == "cc" or info.sourcekind == "cxx" then nodename = "ClCompile"
end