From f358360be5afca83877628ff457131171db1e1b5 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 20 May 2019 19:01:11 +0800 Subject: support more warnings --- xmake/modules/core/tools/cl.lua | 14 +++++++++----- xmake/modules/core/tools/clang.lua | 33 +++++++++++++++++++++++++++++++++ xmake/modules/core/tools/gcc.lua | 13 ++++++++----- xmake/modules/core/tools/ml.lua | 18 ++++++++++++------ 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index fac42e377..3c8699c7e 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -43,6 +43,8 @@ function init(self) , ["-fvisibility=.*"] = "" -- warnings + , ["-Weverything"] = "-Wall" + , ["-Wextra"] = "-W4" , ["-Wall"] = "-W3" -- = "-Wall" will enable too more warnings , ["-W1"] = "-W1" , ["-W2"] = "-W2" @@ -119,11 +121,13 @@ function nf_warning(self, level) -- the maps local maps = { - none = "-W0" - , less = "-W1" - , more = "-W3" - , all = "-W3" -- = "-Wall" will enable too more warnings - , error = "-WX" + none = "-W0" + , less = "-W1" + , more = "-W3" + , all = "-W3" -- = "-Wall" will enable too more warnings + , extra = "-W4" + , everything = "-Wall" + , error = "-WX" } -- make it diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 5cfe55b5d..32524ea55 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -31,6 +31,20 @@ function init(self) self:add("cxflags", "-Qunused-arguments") self:add("mxflags", "-Qunused-arguments") self:add("asflags", "-Qunused-arguments") + + -- init flags map + self:set("mapflags", + { + -- warnings + ["-W1"] = "-Wall" + , ["-W2"] = "-Wall" + , ["-W3"] = "-Wall" + + -- strip + , ["-s"] = "-s" + , ["-S"] = "-S" + }) + end -- make the optimize flag @@ -50,3 +64,22 @@ function nf_optimize(self, level) -- make it return maps[level] end + +-- make the warning flag +function nf_warning(self, level) + + -- the maps + local maps = + { + none = "-w" + , less = "-Wall" + , more = "-Wall" + , all = "-Wall" + , extra = "-Wextra" + , everything = "-Weverything" + , error = "-Werror" + } + + -- make it + return maps[level] +end diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 9253bf75c..f31f4f876 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -52,6 +52,7 @@ function init(self) ["-W1"] = "-Wall" , ["-W2"] = "-Wall" , ["-W3"] = "-Wall" + , ["-Weverything"] = "-Wall -Wextra -Weffc++" -- strip , ["-s"] = "-s" @@ -115,11 +116,13 @@ function nf_warning(self, level) -- the maps local maps = { - none = "-w" - , less = "-Wall" - , more = "-Wall" - , all = "-Wall" - , error = "-Werror" + none = "-w" + , less = "-Wall" + , more = "-Wall" + , all = "-Wall" + , extra = "-Wextra" + , everything = "-Wall -Wextra -Weffc++" + , error = "-Werror" } -- make it diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index bfdacba20..4f186a58d 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -18,6 +18,8 @@ -- @file ml.lua -- +-- https://docs.microsoft.com/en-us/cpp/assembler/masm/ml-and-ml64-command-line-reference + -- init it function init(self) @@ -36,10 +38,12 @@ function init(self) , ["-fvisibility=.*"] = "" -- warnings - , ["-Wall"] = "-W3" -- = "-Wall" will enable too more warnings , ["-W1"] = "-W1" , ["-W2"] = "-W2" , ["-W3"] = "-W3" + , ["-Wall"] = "-W3" -- /W level Sets the warning level, where level = 0, 1, 2, or 3. + , ["-Wextra"] = "-W3" + , ["-Weverything"] = "-W3" , ["-Werror"] = "-WX" , ["%-Wno%-error=.*"] = "" @@ -61,11 +65,13 @@ function nf_warning(self, level) -- the maps local maps = { - none = "-w" - , less = "-W1" - , more = "-W3" - , all = "-W3" - , error = "-WX" + none = "-w" + , less = "-W1" + , more = "-W3" + , all = "-W3" + , extra = "-W3" + , everything = "-W3" + , error = "-WX" } -- make it -- cgit v1.3.1 From 814b8c684bbd367c9cf0643309983d27aa665840 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 20 May 2019 19:01:11 +0800 Subject: support more warnings --- xmake/modules/core/tools/cl.lua | 14 +++++++++----- xmake/modules/core/tools/clang.lua | 33 +++++++++++++++++++++++++++++++++ xmake/modules/core/tools/gcc.lua | 13 ++++++++----- xmake/modules/core/tools/ml.lua | 18 ++++++++++++------ 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index fac42e377..3c8699c7e 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -43,6 +43,8 @@ function init(self) , ["-fvisibility=.*"] = "" -- warnings + , ["-Weverything"] = "-Wall" + , ["-Wextra"] = "-W4" , ["-Wall"] = "-W3" -- = "-Wall" will enable too more warnings , ["-W1"] = "-W1" , ["-W2"] = "-W2" @@ -119,11 +121,13 @@ function nf_warning(self, level) -- the maps local maps = { - none = "-W0" - , less = "-W1" - , more = "-W3" - , all = "-W3" -- = "-Wall" will enable too more warnings - , error = "-WX" + none = "-W0" + , less = "-W1" + , more = "-W3" + , all = "-W3" -- = "-Wall" will enable too more warnings + , extra = "-W4" + , everything = "-Wall" + , error = "-WX" } -- make it diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 5cfe55b5d..32524ea55 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -31,6 +31,20 @@ function init(self) self:add("cxflags", "-Qunused-arguments") self:add("mxflags", "-Qunused-arguments") self:add("asflags", "-Qunused-arguments") + + -- init flags map + self:set("mapflags", + { + -- warnings + ["-W1"] = "-Wall" + , ["-W2"] = "-Wall" + , ["-W3"] = "-Wall" + + -- strip + , ["-s"] = "-s" + , ["-S"] = "-S" + }) + end -- make the optimize flag @@ -50,3 +64,22 @@ function nf_optimize(self, level) -- make it return maps[level] end + +-- make the warning flag +function nf_warning(self, level) + + -- the maps + local maps = + { + none = "-w" + , less = "-Wall" + , more = "-Wall" + , all = "-Wall" + , extra = "-Wextra" + , everything = "-Weverything" + , error = "-Werror" + } + + -- make it + return maps[level] +end diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 9253bf75c..f31f4f876 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -52,6 +52,7 @@ function init(self) ["-W1"] = "-Wall" , ["-W2"] = "-Wall" , ["-W3"] = "-Wall" + , ["-Weverything"] = "-Wall -Wextra -Weffc++" -- strip , ["-s"] = "-s" @@ -115,11 +116,13 @@ function nf_warning(self, level) -- the maps local maps = { - none = "-w" - , less = "-Wall" - , more = "-Wall" - , all = "-Wall" - , error = "-Werror" + none = "-w" + , less = "-Wall" + , more = "-Wall" + , all = "-Wall" + , extra = "-Wextra" + , everything = "-Wall -Wextra -Weffc++" + , error = "-Werror" } -- make it diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index bfdacba20..4f186a58d 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -18,6 +18,8 @@ -- @file ml.lua -- +-- https://docs.microsoft.com/en-us/cpp/assembler/masm/ml-and-ml64-command-line-reference + -- init it function init(self) @@ -36,10 +38,12 @@ function init(self) , ["-fvisibility=.*"] = "" -- warnings - , ["-Wall"] = "-W3" -- = "-Wall" will enable too more warnings , ["-W1"] = "-W1" , ["-W2"] = "-W2" , ["-W3"] = "-W3" + , ["-Wall"] = "-W3" -- /W level Sets the warning level, where level = 0, 1, 2, or 3. + , ["-Wextra"] = "-W3" + , ["-Weverything"] = "-W3" , ["-Werror"] = "-WX" , ["%-Wno%-error=.*"] = "" @@ -61,11 +65,13 @@ function nf_warning(self, level) -- the maps local maps = { - none = "-w" - , less = "-W1" - , more = "-W3" - , all = "-W3" - , error = "-WX" + none = "-w" + , less = "-W1" + , more = "-W3" + , all = "-W3" + , extra = "-W3" + , everything = "-W3" + , error = "-WX" } -- make it -- cgit v1.3.1 From 9f0d35366cfbbe8c49cf645be0e430c469a77b3e Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 20 May 2019 19:41:34 +0800 Subject: tool --- xmake/modules/core/tools/nvcc.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index b14ec8829..05afaf1b9 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.tool.tool") import("core.project.config") import("core.project.project") import("core.language.language") @@ -78,8 +79,17 @@ function nf_warning(self, level) , error = "-Werror" } + local cu_cxx = config.get("cu-cxx") + local cu_cxx_tool = nil tool.load("cxx") + if is_plat("windows") or not cu_cxx then + cu_cxx_tool = tool.load("cxx") + elseif cu_cxx then + cu_cxx_tool = tool.load("cxx", cu_cxx) + end + + local cu_cxx_tool_warning = cu_cxx_tool.nf_warning(level) -- make it - return maps[level] + return maps[level] .. ' -Xcompiler "' .. cu_cxx_tool_warning .. '" -Xlinker "' .. cu_cxx_tool_warning ..'"' end -- make the optimize flag -- cgit v1.3.1 From 9ef48cab2e2ea42faa115ea2c472a70f2095d6b5 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 20 May 2019 19:56:33 +0800 Subject: nvcc warning map --- xmake/modules/core/tools/nvcc.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 05afaf1b9..4048929b8 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -20,7 +20,7 @@ -- imports import("core.base.option") -import("core.tool.tool") +import("core.tool.compiler") import("core.project.config") import("core.project.project") import("core.language.language") @@ -72,15 +72,17 @@ function nf_warning(self, level) -- the maps local maps = { - none = "-w" - , less = "-W1" - , more = "-W3" - , all = "-Wall" - , error = "-Werror" + none = "-w" + , less = "" + , more = "" + , all = "" + , extra = "-Wreorder" + , everything = "-Wreorder" + , error = "-Werror" } local cu_cxx = config.get("cu-cxx") - local cu_cxx_tool = nil tool.load("cxx") + local cu_cxx_tool = nil if is_plat("windows") or not cu_cxx then cu_cxx_tool = tool.load("cxx") elseif cu_cxx then -- cgit v1.3.1