From ae26a6f41f2160383c11cf6c67a0612a44246af4 Mon Sep 17 00:00:00 2001 From: Ethan Wallace Date: Fri, 15 May 2020 15:01:29 -0400 Subject: [PATCH 1/3] Added /Wall to possible warning levels for Visual Studio The 'warnings' keyword now accepts a value of 'High' to generate the /W4 MSVC compiler flag as well as 'Extra' to generate the /Wall flag. --- modules/vstudio/vs2010_vcxproj.lua | 4 ++-- src/tools/msc.lua | 2 +- tests/tools/test_msc.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 52143eb0ae..6f73f12fa5 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2714,13 +2714,13 @@ function m.warningLevel(cfg) - local map = { Off = "TurnOffAllWarnings", Extra = "Level4" } + local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "EnableAllWarnings" } m.element("WarningLevel", nil, map[cfg.warnings] or "Level3") end function m.warningLevelFile(cfg, condition) - local map = { Off = "TurnOffAllWarnings", Extra = "Level4" } + local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "EnableAllWarnings" } if cfg.warnings then m.element("WarningLevel", condition, map[cfg.warnings] or "Level3") end diff --git a/src/tools/msc.lua b/src/tools/msc.lua index 83a14f9af1..8b5b7f02f0 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -80,7 +80,7 @@ ["SSE4.1"] = "/arch:SSE2", }, warnings = { - Extra = "/W4", + Extra = "/Wall", High = "/W4", Off = "/W0", }, diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 341e0afb0e..9e519a9939 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -221,7 +221,7 @@ function suite.cflags_OnExtraWarnings() warnings "Extra" prepare() - test.contains("/W4", msc.getcflags(cfg)) + test.contains("/Wall", msc.getcflags(cfg)) end function suite.cflags_OnFatalWarnings() From 1453c7c5fd313e135edf633f76eb5212d5d774b6 Mon Sep 17 00:00:00 2001 From: Ethan Wallace Date: Sat, 16 May 2020 20:29:32 -0400 Subject: [PATCH 2/3] Updated tests to reflect new flag Test suite now properly checks the new "High" and "Extra" warning options --- .../vstudio/tests/vc2010/test_compile_settings.lua | 14 +++++++++++++- modules/vstudio/tests/vc2010/test_files.lua | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/vstudio/tests/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua index 2eb2322bf7..79d00c9029 100644 --- a/modules/vstudio/tests/vc2010/test_compile_settings.lua +++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua @@ -76,6 +76,18 @@ ]] end +-- +-- Ensure that high warnings lead to the level 4 debug option +-- + function suite.warningLevel_onHighWarnings() + warnings "High" + prepare() + test.capture [[ + + NotUsing + Level4 + ]] + end -- -- If extra warnings is specified, pump up the volume. @@ -87,7 +99,7 @@ test.capture [[ NotUsing - Level4 + EnableAllWarnings ]] end diff --git a/modules/vstudio/tests/vc2010/test_files.lua b/modules/vstudio/tests/vc2010/test_files.lua index acd8d0e2a5..82242b28a6 100644 --- a/modules/vstudio/tests/vc2010/test_files.lua +++ b/modules/vstudio/tests/vc2010/test_files.lua @@ -897,7 +897,7 @@ test.capture [[ - Level4 + EnableAllWarnings From acda348b4b093deb33e583cf8baa6cf1d285bc6d Mon Sep 17 00:00:00 2001 From: Ethan Wallace Date: Fri, 19 Jun 2020 14:09:14 -0400 Subject: [PATCH 3/3] Added new 'warning' levels Added new warning level "Everything" which turns on all available compiler warnings. Updated "High" and "Extra" to reflect actual differences in emitted compiler flags. --- modules/d/tools/dmd.lua | 1 + modules/d/tools/gdc.lua | 1 + modules/d/tools/ldc.lua | 1 + .../tests/vc200x/test_compiler_block.lua | 17 +++++ .../tests/vc2010/test_compile_settings.lua | 28 +++++++ modules/vstudio/tests/vc2010/test_files.lua | 2 +- modules/vstudio/vs200x_vcproj.lua | 2 + modules/vstudio/vs2010_vcxproj.lua | 4 +- modules/xcode/tests/test_xcode_project.lua | 75 +++++++++++++++++++ modules/xcode/xcode_common.lua | 8 +- src/_premake_init.lua | 1 + src/tools/gcc.lua | 5 +- src/tools/msc.lua | 5 +- tests/tools/test_gcc.lua | 26 ++++--- tests/tools/test_msc.lua | 6 ++ 15 files changed, 164 insertions(+), 18 deletions(-) diff --git a/modules/d/tools/dmd.lua b/modules/d/tools/dmd.lua index d957ec7608..3401a5c662 100644 --- a/modules/d/tools/dmd.lua +++ b/modules/d/tools/dmd.lua @@ -305,6 +305,7 @@ Default = "-wi", High = "-wi", Extra = "-wi", + Everything = "-wi", }, } diff --git a/modules/d/tools/gdc.lua b/modules/d/tools/gdc.lua index 727d03ef45..5ecb74e07b 100644 --- a/modules/d/tools/gdc.lua +++ b/modules/d/tools/gdc.lua @@ -85,6 +85,7 @@ -- Default = "-w", -- TODO: check this... High = "-Wall", Extra = "-Wall -Wextra", + Everything = "-Weverything", }, symbols = { On = "-g", diff --git a/modules/d/tools/ldc.lua b/modules/d/tools/ldc.lua index ef881a9214..0900cf4ff2 100644 --- a/modules/d/tools/ldc.lua +++ b/modules/d/tools/ldc.lua @@ -121,6 +121,7 @@ Default = "-wi", High = "-wi", Extra = "-wi", -- TODO: is there a way to get extra warnings? + Everything = "-wi", }, symbols = { On = "-g", diff --git a/modules/vstudio/tests/vc200x/test_compiler_block.lua b/modules/vstudio/tests/vc200x/test_compiler_block.lua index 9fd3c56b54..30c4a3ddce 100644 --- a/modules/vstudio/tests/vc200x/test_compiler_block.lua +++ b/modules/vstudio/tests/vc200x/test_compiler_block.lua @@ -332,6 +332,23 @@ ]] end + function suite.runtimeLibraryIsDebug_onHighWarnings() + warnings "High" + prepare() + test.capture [[ + + ]] + end + -- -- Verify the correct warnings settings are used when FatalWarnings are enabled. diff --git a/modules/vstudio/tests/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua index d07d94bdf1..9273c2c6b2 100644 --- a/modules/vstudio/tests/vc2010/test_compile_settings.lua +++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua @@ -97,6 +97,20 @@ warnings "Extra" prepare() test.capture [[ + + NotUsing + Level4 + ]] + end + +-- +-- If Everything is wanted, turn it ALL on +-- + + function suite.warningLevel_onEverythingWarnings() + warnings "Everything" + prepare() + test.capture [[ NotUsing EnableAllWarnings @@ -117,6 +131,20 @@ ]] end +-- +-- Check default warning level. +-- + + function suite.warningLevel_onDefaultWarnings() + warnings "Default" + prepare() + test.capture [[ + + NotUsing + Level3 + ]] + end + -- -- If warnings are turned off, the fatal warnings flags should -- not be generated. diff --git a/modules/vstudio/tests/vc2010/test_files.lua b/modules/vstudio/tests/vc2010/test_files.lua index 82242b28a6..acd8d0e2a5 100644 --- a/modules/vstudio/tests/vc2010/test_files.lua +++ b/modules/vstudio/tests/vc2010/test_files.lua @@ -897,7 +897,7 @@ test.capture [[ - EnableAllWarnings + Level4 diff --git a/modules/vstudio/vs200x_vcproj.lua b/modules/vstudio/vs200x_vcproj.lua index 735b66ddfb..81a3f9922f 100644 --- a/modules/vstudio/vs200x_vcproj.lua +++ b/modules/vstudio/vs200x_vcproj.lua @@ -1594,6 +1594,8 @@ local level if cfg.warnings == p.OFF then level = "0" + elseif cfg.warnings == "High" then + level = "4" elseif cfg.warnings == "Extra" then level = "4" elseif not filecfg then diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 713bab31d2..8d25b90492 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2727,13 +2727,13 @@ function m.warningLevel(cfg) - local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "EnableAllWarnings" } + local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "Level4", Everything = "EnableAllWarnings" } m.element("WarningLevel", nil, map[cfg.warnings] or "Level3") end function m.warningLevelFile(cfg, condition) - local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "EnableAllWarnings" } + local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "Level4", Everything = "EnableAllWarnings" } if cfg.warnings then m.element("WarningLevel", condition, map[cfg.warnings] or "Level3") end diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index 858b0249e8..a1358f6cf2 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -2332,6 +2332,55 @@ ]] end + function suite.XCBuildConfigurationProject_OnNoWarnings() + warnings "Off" + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + A14350AC4595EE5E57CE36EC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + WARNING_CFLAGS = "-w"; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationProject_OnHighWarnings() + warnings "High" + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + A14350AC4595EE5E57CE36EC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + WARNING_CFLAGS = "-Wall"; + }; + name = Debug; + }; + ]] + end function suite.XCBuildConfigurationProject_OnExtraWarnings() warnings "Extra" @@ -2359,6 +2408,32 @@ end + function suite.XCBuildConfigurationProject_OnEverythingWarnings() + warnings "Everything" + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + A14350AC4595EE5E57CE36EC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + WARNING_CFLAGS = "-Weverything"; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationProject_OnFatalWarnings() flags { "FatalWarnings" } prepare() diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index ef4e38fae8..481afb32a4 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -1450,8 +1450,14 @@ settings['SYMROOT'] = path.getrelative(tr.project.location, targetdir) end - if cfg.warnings == "Extra" then + if cfg.warnings == "Off" then + settings['WARNING_CFLAGS'] = '-w' + elseif cfg.warnings == "High" then + settings['WARNING_CFLAGS'] = '-Wall' + elseif cfg.warnings == "Extra" then settings['WARNING_CFLAGS'] = '-Wall -Wextra' + elseif cfg.warnings == "Everything" then + settings['WARNING_CFLAGS'] = '-Weverything' end overrideSettings(settings, cfg.xcodebuildsettings) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index a731f426f8..37496e60b9 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -1309,6 +1309,7 @@ "Default", "High", "Extra", + "Everything", } } diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 2087edd135..0cf7243b73 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -101,9 +101,10 @@ RDRND = "-mrdrnd", }, warnings = { - Extra = {"-Wall", "-Wextra"}, - High = "-Wall", Off = "-w", + High = "-Wall", + Extra = {"-Wall", "-Wextra"}, + Everything = "-Weverything", }, symbols = function(cfg, mappings) local values = gcc.getdebugformat(cfg) diff --git a/src/tools/msc.lua b/src/tools/msc.lua index 8b5b7f02f0..f0cf85b533 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -80,9 +80,10 @@ ["SSE4.1"] = "/arch:SSE2", }, warnings = { - Extra = "/Wall", - High = "/W4", Off = "/W0", + High = "/W4", + Extra = "/W4", + Everything = "/Wall", }, staticruntime = { -- this option must always be emit (does it??) diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index 15146cd76a..bef18b01a8 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -74,18 +74,30 @@ -- Check the translation of CFLAGS. -- - function suite.cflags_onExtraWarnings() - warnings "extra" + function suite.cflags_onNoWarnings() + warnings "Off" prepare() - test.contains({ "-Wall", "-Wextra" }, gcc.getcflags(cfg)) + test.contains({ "-w" }, gcc.getcflags(cfg)) end function suite.cflags_onHighWarnings() - warnings "high" + warnings "High" prepare() test.contains({ "-Wall" }, gcc.getcflags(cfg)) end + function suite.cflags_onExtraWarnings() + warnings "Extra" + prepare() + test.contains({ "-Wall", "-Wextra" }, gcc.getcflags(cfg)) + end + + function suite.cflags_onEverythingWarnings() + warnings "Everything" + prepare() + test.contains({ "-Weverything" }, gcc.getcflags(cfg)) + end + function suite.cflags_onFatalWarnings() flags { "FatalWarnings" } prepare() @@ -112,12 +124,6 @@ test.contains({ "-ffloat-store" }, gcc.getcflags(cfg)) end - function suite.cflags_onNoWarnings() - warnings "Off" - prepare() - test.contains({ "-w" }, gcc.getcflags(cfg)) - end - function suite.cflags_onSSE() vectorextensions "SSE" prepare() diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 9e519a9939..1c245e97cb 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -221,6 +221,12 @@ function suite.cflags_OnExtraWarnings() warnings "Extra" prepare() + test.contains("/W4", msc.getcflags(cfg)) + end + + function suite.cflags_OnEverythingWarnings() + warnings "Everything" + prepare() test.contains("/Wall", msc.getcflags(cfg)) end