Skip to content

Commit

Permalink
Merge pull request #42634 from akien-mga/scons-warnings-gcc-Wsuggest-…
Browse files Browse the repository at this point in the history
…override

SCons: Refactor and cleanup warnings definition
  • Loading branch information
akien-mga authored Oct 8, 2020
2 parents 104cfae + 97f116d commit 8be6db9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
23 changes: 10 additions & 13 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ if selected_platform in platform_list:
Exit(255)

# Configure compiler warnings
if env.msvc:
if env.msvc: # MSVC
# Truncations, narrowing conversions, signed/unsigned comparisons...
disable_nonessential_warnings = ["/wd4267", "/wd4244", "/wd4305", "/wd4018", "/wd4800"]
if env["warnings"] == "extra":
Expand All @@ -427,21 +427,17 @@ 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"])
# Force to use Unicode encoding
env.Append(MSVC_FLAGS=["/utf8"])
else: # Rest of the world
shadow_local_warning = []
all_plus_warnings = ["-Wwrite-strings"]
else: # GCC, Clang
gcc_common_warnings = []

if methods.using_gcc(env):
env.Append(CCFLAGS=["-Wno-misleading-indentation"])
if cc_version_major >= 7:
shadow_local_warning = ["-Wshadow-local"]
gcc_common_warnings += ["-Wshadow-local", "-Wno-misleading-indentation"]

if env["warnings"] == "extra":
env.Append(CCFLAGS=["-Wall", "-Wextra", "-Wno-unused-parameter"] + all_plus_warnings + shadow_local_warning)
env.Append(CCFLAGS=["-Wall", "-Wextra", "-Wwrite-strings", "-Wno-unused-parameter"] + gcc_common_warnings)
env.Append(CXXFLAGS=["-Wctor-dtor-privacy", "-Wnon-virtual-dtor"])
if methods.using_gcc(env):
env.Append(
Expand All @@ -457,14 +453,15 @@ if selected_platform in platform_list:
env.Append(CXXFLAGS=["-Wplacement-new=1"])
if cc_version_major >= 9:
env.Append(CCFLAGS=["-Wattribute-alias=2"])
if methods.using_clang(env):
elif methods.using_clang(env):
env.Append(CCFLAGS=["-Wimplicit-fallthrough"])
elif env["warnings"] == "all":
env.Append(CCFLAGS=["-Wall"] + shadow_local_warning)
env.Append(CCFLAGS=["-Wall"] + gcc_common_warnings)
elif env["warnings"] == "moderate":
env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + shadow_local_warning)
env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + gcc_common_warnings)
else: # 'no'
env.Append(CCFLAGS=["-w"])

if env["werror"]:
env.Append(CCFLAGS=["-Werror"])
# FIXME: Temporary workaround after the Vulkan merge, remove once warnings are fixed.
Expand Down
3 changes: 3 additions & 0 deletions platform/uwp/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def configure(env):
env["ENV"] = os.environ
vc_base_path = os.environ["VCTOOLSINSTALLDIR"] if "VCTOOLSINSTALLDIR" in os.environ else os.environ["VCINSTALLDIR"]

# Force to use Unicode encoding
env.Append(MSVC_FLAGS=["/utf-8"])

# ANGLE
angle_root = os.getenv("ANGLE_SRC_PATH")
env.Prepend(CPPPATH=[angle_root + "/include"])
Expand Down
4 changes: 2 additions & 2 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def configure_msvc(env, manual_msvc_config):
## Compile/link flags

env.AppendUnique(CCFLAGS=["/MT", "/Gd", "/GR", "/nologo"])
if int(env["MSVC_VERSION"].split(".")[0]) >= 14: # vs2015 and later
env.AppendUnique(CCFLAGS=["/utf-8"])
# Force to use Unicode encoding
env.Append(MSVC_FLAGS=["/utf-8"])
env.AppendUnique(CXXFLAGS=["/TP"]) # assume all sources are C++
if manual_msvc_config: # should be automatic if SCons found it
if os.getenv("WindowsSdkDir") is not None:
Expand Down

0 comments on commit 8be6db9

Please sign in to comment.