Browse Source

SCons: Enable -Werror and -Wextra in 'dev' build option

We're close to being able to compile all platforms with -Werror -Wextra,
so it's best if developers use those options when compiling their code
as those checks are also done on CI.

Also enabled -Wduplicated-branches on GCC.
Rémi Verschelde 6 years ago
parent
commit
beb34a0458
1 changed files with 5 additions and 4 deletions
  1. 5 4
      SConstruct

+ 5 - 4
SConstruct

@@ -125,7 +125,7 @@ opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", Fa
 opts.Add(BoolVariable('progress', "Show a progress indicator during compilation", True))
 opts.Add(BoolVariable('progress', "Show a progress indicator during compilation", True))
 opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'all', ('extra', 'all', 'moderate', 'no')))
 opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'all', ('extra', 'all', 'moderate', 'no')))
 opts.Add(BoolVariable('werror', "Treat compiler warnings as errors. Depends on the level of warnings set with 'warnings'", False))
 opts.Add(BoolVariable('werror', "Treat compiler warnings as errors. Depends on the level of warnings set with 'warnings'", False))
-opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False))
+opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=extra werror=yes", False))
 opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
 opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
 opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False))
 opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False))
 opts.Add(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel')))
 opts.Add(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel')))
@@ -254,8 +254,9 @@ if selected_platform in platform_list:
         env = env_base.Clone()
         env = env_base.Clone()
 
 
     if env['dev']:
     if env['dev']:
-        env["warnings"] = "all"
         env['verbose'] = True
         env['verbose'] = True
+        env['warnings'] = "extra"
+        env['werror'] = True
 
 
     if env['vsproj']:
     if env['vsproj']:
         env.vs_incs = []
         env.vs_incs = []
@@ -337,7 +338,6 @@ if selected_platform in platform_list:
 
 
         if (env["warnings"] == 'extra'):
         if (env["warnings"] == 'extra'):
             # FIXME: enable -Wclobbered once #26351 is fixed
             # FIXME: enable -Wclobbered once #26351 is fixed
-            # FIXME: enable -Wduplicated-branches once #27594 is merged
             # Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC)
             # Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC)
             # once we switch to C++11 or later (necessary for our FALLTHROUGH macro).
             # once we switch to C++11 or later (necessary for our FALLTHROUGH macro).
             env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter']
             env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter']
@@ -345,7 +345,8 @@ if selected_platform in platform_list:
             env.Append(CXXFLAGS=['-Wctor-dtor-privacy', '-Wnon-virtual-dtor'])
             env.Append(CXXFLAGS=['-Wctor-dtor-privacy', '-Wnon-virtual-dtor'])
             if methods.using_gcc(env):
             if methods.using_gcc(env):
                 env.Append(CCFLAGS=['-Wno-clobbered', '-Walloc-zero',
                 env.Append(CCFLAGS=['-Wno-clobbered', '-Walloc-zero',
-                    '-Wduplicated-cond', '-Wstringop-overflow=4', '-Wlogical-op'])
+                    '-Wduplicated-branches', '-Wduplicated-cond',
+                    '-Wstringop-overflow=4', '-Wlogical-op'])
                 env.Append(CXXFLAGS=['-Wnoexcept', '-Wplacement-new=1'])
                 env.Append(CXXFLAGS=['-Wnoexcept', '-Wplacement-new=1'])
                 version = methods.get_compiler_version(env)
                 version = methods.get_compiler_version(env)
                 if version != None and version[0] >= '9':
                 if version != None and version[0] >= '9':