From d8f32637be9f9eae9fddfe4d664e369cbf3b65c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 25 Mar 2017 08:36:00 +0100 Subject: SCons: Add option to toggle warnings (on by default) All the warnings are factored out of the platform-specific files and moved to SConstruct. Will have to check that it does not introduce regressions on some platforms/compilers. (cherry picked from commit 31107daa1a41fe9ab3c7c1868479e78e16848333) --- SConstruct | 14 +++++++++++++- modules/freetype/SCsub | 1 - platform/android/detect.py | 4 +--- platform/haiku/detect.py | 2 +- platform/iphone/detect.py | 12 ++++++------ platform/javascript/detect.py | 2 +- platform/osx/detect.py | 2 +- platform/server/detect.py | 2 +- platform/windows/detect.py | 2 +- platform/x11/detect.py | 4 ++-- 10 files changed, 27 insertions(+), 18 deletions(-) diff --git a/SConstruct b/SConstruct index 35401194ef..85075c6c79 100644 --- a/SConstruct +++ b/SConstruct @@ -145,6 +145,7 @@ opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '') opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'yes') opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no') +opts.Add('warnings', "Enable showing warnings during the compilation (yes/no)", 'yes') # Thirdparty libraries opts.Add('builtin_enet', "Use the builtin enet library (yes/no)", 'yes') @@ -271,6 +272,18 @@ 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) + # TODO: Add support to specify different levels of warning, e.g. only critical/significant, instead of on/off + if (env["warnings"] == "yes"): + if (os.name == "nt" and os.getenv("VSINSTALLDIR")): # MSVC, needs to stand out of course + env.Append(CCFLAGS=['/W4']) + else: # Rest of the world + env.Append(CCFLAGS=['-Wall']) + else: + if (os.name == "nt" and os.getenv("VSINSTALLDIR")): # MSVC + env.Append(CCFLAGS=['/w']) + else: # Rest of the world + env.Append(CCFLAGS=['-w']) + #env['platform_libsuffix'] = env['LIBSUFFIX'] suffix = "." + selected_platform @@ -280,7 +293,6 @@ if selected_platform in platform_list: print("Tools can only be built with targets 'debug' and 'release_debug'.") sys.exit(255) suffix += ".opt" - env.Append(CCFLAGS=['-DNDEBUG']) elif (env["target"] == "release_debug"): diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 5b1e1c189f..8401c36b54 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -70,7 +70,6 @@ if (env['builtin_freetype'] != 'no'): # LIBS contains first SCons Library objects ("SCons.Node.FS.File object") # and then plain strings for system library. We insert between the two. inserted = False - print(env["LIBS"]) for idx, linklib in enumerate(env["LIBS"]): if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object env["LIBS"].insert(idx, lib) diff --git a/platform/android/detect.py b/platform/android/detect.py index d1b33fe649..0e78a4618d 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -168,9 +168,7 @@ def configure(env): env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"]) env.Append(CPPFLAGS=string.split( - '-Wno-invalid-command-line-argument -Wno-unused-command-line-argument')) - env.Append(CPPFLAGS=string.split( - '-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing -Wa,--noexecstack')) + '-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing')) env.Append(CPPFLAGS=string.split('-DANDROID -DNO_STATVFS -DGLES2_ENABLED')) env['neon_enabled'] = False diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 71202a9a49..54e227cd19 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -53,7 +53,7 @@ def configure(env): elif (env["target"] == "release_debug"): env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED']) elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) # env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index fa6082a5a7..248c73982b 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -58,16 +58,16 @@ def configure(env): if (env["ios_sim"] == "yes" or env["arch"] == "x86"): # i386, simulator env["arch"] = "x86" env["bits"] = "32" - env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') + env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') elif (env["arch"] == "arm64"): # arm64 env["bits"] = "64" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=7.0 -isysroot $IPHONESDK') + env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=7.0 -isysroot $IPHONESDK') env.Append(CPPFLAGS=['-DNEED_LONG_INT']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) else: # armv7 env["arch"] = "arm" env["bits"] = "32" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot $IPHONESDK -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=7.0 -MMD -MT dependencies -isysroot $IPHONESDK') + env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=7.0 -MMD -MT dependencies -isysroot $IPHONESDK') if (env["arch"] == "x86"): env['IPHONEPLATFORM'] = 'iPhoneSimulator' @@ -145,17 +145,17 @@ def configure(env): if (env["target"] == "release"): - env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-gdwarf-2']) # removed -ffast-math + env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1', '-gdwarf-2']) # removed -ffast-math env.Append(LINKFLAGS=['-O3']) elif env["target"] == "release_debug": - env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1', '-DDEBUG_ENABLED']) env.Append(LINKFLAGS=['-Os']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) elif (env["target"] == "profile"): diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index f82eae9ff2..307e47e816 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -77,7 +77,7 @@ def configure(env): # retain function names at the cost of file size, for backtraces and profiling env.Append(LINKFLAGS=['--profiling-funcs']) elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-O1', '-D_DEBUG', '-Wall', '-g', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-O1', '-D_DEBUG', '-g', '-DDEBUG_ENABLED']) env.Append(LINKFLAGS=['-O1', '-g']) # TODO: Move that to opus module's config diff --git a/platform/osx/detect.py b/platform/osx/detect.py index b59dfe1afb..39ee33ae82 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -51,7 +51,7 @@ def configure(env): elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-g3', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) if (not os.environ.has_key("OSXCROSS_ROOT")): # regular native build diff --git a/platform/server/detect.py b/platform/server/detect.py index 8bc85f342d..32f3c55135 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -64,7 +64,7 @@ def configure(env): elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) # Shared libraries, when requested diff --git a/platform/windows/detect.py b/platform/windows/detect.py index a3e410ec64..6080c6f1dc 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -361,7 +361,7 @@ def configure(env): elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-g', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) env["CC"] = mingw_prefix + "gcc" env['AS'] = mingw_prefix + "as" diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 89cf639114..34306c8d0f 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -133,7 +133,7 @@ def configure(env): elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Prepend(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) env.ParseConfig('pkg-config x11 --cflags --libs') env.ParseConfig('pkg-config xinerama --cflags --libs') @@ -227,7 +227,7 @@ def configure(env): env.Append(LIBS=['dl']) # env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) -# host compiler is default.. + # host compiler is default.. if (is64 and env["bits"] == "32"): env.Append(CPPFLAGS=['-m32']) -- cgit v1.2.3