Merge pull request #22620 from akien-mga/warnings-shall-not-pass
SCons: Set default warnings level to all (-Wall or /W3)
This commit is contained in:
commit
156c4eab02
2 changed files with 21 additions and 14 deletions
31
SConstruct
31
SConstruct
|
@ -159,15 +159,16 @@ opts.Add(BoolVariable('minizip', "Enable ZIP archive support using minizip", Tru
|
|||
opts.Add(BoolVariable('xaudio2', "Enable the XAudio2 audio driver", False))
|
||||
|
||||
# Advanced options
|
||||
opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", False))
|
||||
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(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('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(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel')))
|
||||
opts.Add(BoolVariable('disable_3d', "Disable 3D nodes for a smaller executable", False))
|
||||
opts.Add(BoolVariable('disable_advanced_gui', "Disable advanced 3D GUI nodes and behaviors", False))
|
||||
opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
|
||||
opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", False))
|
||||
opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False))
|
||||
opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'no', ('extra', 'all', 'moderate', 'no')))
|
||||
opts.Add(BoolVariable('progress', "Show a progress indicator during compilation", True))
|
||||
opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False))
|
||||
opts.Add(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel')))
|
||||
opts.Add(BoolVariable('no_editor_splash', "Don't use the custom splash screen for the editor", False))
|
||||
opts.Add('system_certs_path', "Use this path as SSL certificates default for editor (for package maintainers)", '')
|
||||
|
||||
|
@ -235,7 +236,6 @@ env_base.platform_apis = platform_apis
|
|||
|
||||
if (env_base['target'] == 'debug'):
|
||||
env_base.Append(CPPDEFINES=['DEBUG_MEMORY_ALLOC','DISABLE_FORCED_INLINE'])
|
||||
|
||||
|
||||
if (env_base['no_editor_splash']):
|
||||
env_base.Append(CPPDEFINES=['NO_EDITOR_SPLASH'])
|
||||
|
@ -318,15 +318,13 @@ if selected_platform in platform_list:
|
|||
# must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
|
||||
detect.configure(env)
|
||||
|
||||
if (env["warnings"] == 'yes'):
|
||||
print("WARNING: warnings=yes is deprecated; assuming warnings=all")
|
||||
|
||||
# Configure compiler warnings
|
||||
if env.msvc:
|
||||
# Truncations, narrowing conversions, signed/unsigned comparisons...
|
||||
disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4018', '/wd4800']
|
||||
if (env["warnings"] == 'extra'):
|
||||
env.Append(CCFLAGS=['/Wall']) # Implies /W4
|
||||
elif (env["warnings"] == 'all' or env["warnings"] == 'yes'):
|
||||
elif (env["warnings"] == 'all'):
|
||||
env.Append(CCFLAGS=['/W3'] + disable_nonessential_warnings)
|
||||
elif (env["warnings"] == 'moderate'):
|
||||
env.Append(CCFLAGS=['/W2'] + disable_nonessential_warnings)
|
||||
|
@ -334,17 +332,22 @@ if selected_platform in platform_list:
|
|||
env.Append(CCFLAGS=['/w'])
|
||||
# Set exception handling model to avoid warnings caused by Windows system headers.
|
||||
env.Append(CCFLAGS=['/EHsc'])
|
||||
if (env["werror"]):
|
||||
env.Append(CCFLAGS=['/WX'])
|
||||
else: # Rest of the world
|
||||
disable_nonessential_warnings = ['-Wno-sign-compare']
|
||||
if (env["warnings"] == 'extra'):
|
||||
env.Append(CCFLAGS=['-Wall', '-Wextra'])
|
||||
elif (env["warnings"] == 'all' or env["warnings"] == 'yes'):
|
||||
elif (env["warnings"] == 'all'):
|
||||
env.Append(CCFLAGS=['-Wall'] + disable_nonessential_warnings)
|
||||
elif (env["warnings"] == 'moderate'):
|
||||
env.Append(CCFLAGS=['-Wall', '-Wno-unused'] + disable_nonessential_warnings)
|
||||
else: # 'no'
|
||||
env.Append(CCFLAGS=['-w'])
|
||||
env.Append(CCFLAGS=['-Werror=return-type'])
|
||||
if (env["werror"]):
|
||||
env.Append(CCFLAGS=['-Werror'])
|
||||
else: # always enable those errors
|
||||
env.Append(CCFLAGS=['-Werror=return-type'])
|
||||
|
||||
suffix = "." + selected_platform
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ def add_source_files(self, sources, filetype, lib_env=None, shared=False):
|
|||
def disable_warnings(self):
|
||||
# 'self' is the environment
|
||||
if self.msvc:
|
||||
# We have to remove existing warning level defines before appending /w,
|
||||
# otherwise we get: "warning D9025 : overriding '/W3' with '/w'"
|
||||
warn_flags = ['/Wall', '/W4', '/W3', '/W2', '/W1', '/WX']
|
||||
self['CCFLAGS'] = [x for x in self['CCFLAGS'] if not x in warn_flags]
|
||||
self.Append(CCFLAGS=['/w'])
|
||||
else:
|
||||
self.Append(CCFLAGS=['-w'])
|
||||
|
|
Loading…
Reference in a new issue