Skip to content

Commit 93ebd48

Browse files
committed
It says on the tin to use the DEBUG configure flag to "Enable debugging
info and strict compile warnings". Make it so. * CMakeLists.txt: If DEBUG is set, also set SERF_MAINTAINER_MODE. * SConstruct: If DEBUG is set, also enable additional warnings; and, by default, silence all warings from the MockHTTP build. (SHOW_MOCKHTTP_WARNINGS): New constant; set to True to show warnings from MockHTTP anyway. git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1926951 13f79535-47bb-0310-9956-ffa450edef68
1 parent 42d5adb commit 93ebd48

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ endif()
7676
if(NOT CMAKE_BUILD_TYPE)
7777
if(DEBUG)
7878
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Default to debug build." FORCE)
79+
set(SERF_MAINTAINER_MODE TRUE)
7980
else()
8081
set(CMAKE_BUILD_TYPE Release CACHE STRING "Default to release build." FORCE)
8182
endif()

SConstruct

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ except TypeError:
5959
custom_tests['CheckFunc'] = build.scons_extras.CheckFunc
6060
print('warning: replaced Conftest.CheckFunc() for SCons version < 4.7.')
6161

62+
# By default, we silence all warnings when compiling MockHTTP.
63+
# Set this to True to show them instead.
64+
SHOW_MOCKHTTP_WARNINGS = False
6265

6366
HEADER_FILES = ['serf.h',
6467
'serf_bucket_types.h',
@@ -364,6 +367,13 @@ if sys.platform != 'win32':
364367
# env.Append(CCFLAGS=['-g'])
365368
env.SerfAppendIf(['CFLAGS', 'CCFLAGS'], r'-g\S*', CCFLAGS=['-g'])
366369
env.Append(CPPDEFINES=['DEBUG', '_DEBUG'])
370+
env.Append(CCFLAGS=['-Wimplicit-function-declaration',
371+
'-Wmissing-variable-declarations',
372+
'-Wunreachable-code',
373+
'-Wshorten-64-to-32',
374+
'-Wno-system-headers',
375+
'-Wextra-tokens',
376+
'-Wnewline-eof'])
367377
else:
368378
# env.Append(CCFLAGS=['-O2'])
369379
env.SerfAppendIf(['CFLAGS', 'CCFLAGS'], r'-O\S*', CCFLAGS=['-O2'])
@@ -733,10 +743,20 @@ tenv = env.Clone()
733743
tenv.Append(CPPDEFINES=['MOCKHTTP_OPENSSL'])
734744

735745
# Build the MockHTTP static library. MockHTTP needs C99 and OpenSSL's
736-
# deprecated APIs.
746+
# deprecated APIs. Also silence all warnings from MockHTTP.
737747
mockenv = tenv.Clone()
738748
mockenv.Replace(CFLAGS = [f.replace('-std=c89', '-std=c99')
739749
for f in mockenv['CFLAGS']])
750+
mockenv.Replace(CCFLAGS = list(
751+
filter(lambda f: (SHOW_MOCKHTTP_WARNINGS
752+
or (# GCC-like warning flags
753+
not re.match(r'^\s*-W[a-z][a-z-]+', f)
754+
# MSVC-like warning flags
755+
and not re.match(r'^\s*/(W|w[de])\d+', f))),
756+
mockenv['CCFLAGS'])
757+
))
758+
if not SHOW_MOCKHTTP_WARNINGS:
759+
mockenv.Append(CCFLAGS = ['-w' if sys.platform != 'win32' else '/w'])
740760
mockenv.Replace(CPPDEFINES = list(filter(lambda d: d != 'OPENSSL_NO_DEPRECATED',
741761
mockenv['CPPDEFINES'])))
742762

0 commit comments

Comments
 (0)