summaryrefslogtreecommitdiff
path: root/xmake/modules/core
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
parente3b3ffbc6230e9dee45a38356095705f9705966f (diff)
add build.warning policy
Diffstat (limited to 'xmake/modules/core')
-rw-r--r--xmake/modules/core/tools/cl.lua18
-rw-r--r--xmake/modules/core/tools/gcc.lua18
2 files changed, 34 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index d736c0ad2..703250c8b 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -366,6 +366,22 @@ function _compargv_pch(self, pcheaderfile, pcoutputfile, flags)
return self:program(), table.join("-c", "-Yc", pchflags, "-Fp" .. pcoutputfile, "-Fo" .. pcoutputfile .. ".obj", pcheaderfile)
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 /sourceDependencies xxx.json @see https://github.com/xmake-io/xmake/issues/868?
function _has_source_dependencies(self)
local has_source_dependencies = _g._HAS_SOURCE_DEPENDENCIES
@@ -616,7 +632,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
function (ok, outdata, errdata)
-- show warnings?
- if ok and (option.get("diagnosis") or option.get("warning") or global.get("build_warning")) then
+ if ok and _has_warnings() then
local output = outdata or ""
if #output:trim() == 0 then
output = errdata or ""
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