summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/gcc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-06-19 21:38:58 +0800
committerruki <[email protected]>2022-06-19 21:38:58 +0800
commitd43525ea44aeebe87068817549b2b9dbdb43c47b (patch)
treee74d4a8645ce147b09a97f0e1bc8ef5c9b0a7c43 /xmake/modules/core/tools/gcc.lua
parente3b3ffbc6230e9dee45a38356095705f9705966f (diff)
add build.warning policy
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
-rw-r--r--xmake/modules/core/tools/gcc.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index cf8fad4db..93674a702 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -368,6 +368,22 @@ function link(self, objectfiles, targetkind, targetfile, flags)
os.runv(program, argv, {envs = self:runenvs()})
end
+-- has warnings output?
+function _has_warnings()
+ local warnings = _g.warnings
+ if warnings == nil then
+ warnings = option.get("diagnosis") or option.get("warning")
+ if warnings == nil and os.isfile(os.projectfile()) and project.policy("build.warning") ~= nil then
+ warnings = project.policy("build.warning")
+ end
+ if warnings == nil then
+ warnings = global.get("build_warning")
+ end
+ _g.warnings = warnings or false
+ end
+ return warnings
+end
+
-- has color diagnostics?
function _has_color_diagnostics(self)
local colors_diagnostics = _g._HAS_COLOR_DIAGNOSTICS
@@ -657,7 +673,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
{
function (ok, outdata, errdata)
-- show warnings?
- if ok and errdata and #errdata > 0 and (option.get("diagnosis") or option.get("warning") or global.get("build_warning")) then
+ if ok and errdata and #errdata > 0 and _has_warnings() then
local lines = errdata:split('\n', {plain = true})
if #lines > 0 then
if not option.get("diagnosis") then