Skip to content

Commit 3fbf69b

Browse files
committed
SERF-206: Filter out all optimization, debugging and warning options from
the output of apr-{1,2}-config and apu-1-condig. CMake was almost there, leaving only the warning options; SCons did no filtering at all. * SConstruct: Filter the flags before sending them to env.ParseConfig. (readconfig): New, does the filtering. * build/FindAPR.cmake: Also filter -Wfoo from --cppflags and --cflags. git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1926930 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9af4b8a commit 3fbf69b

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

SConstruct

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,17 +538,26 @@ else:
538538
### we should use --cc, but that is giving some scons error about an implicit
539539
### dependency upon gcc. probably ParseConfig doesn't know what to do with
540540
### the apr-1-config output
541-
env.ParseConfig('$APR --cflags --cppflags --ldflags --includes'
542-
' --link-ld --libs', unique=0)
541+
542+
def readconfig(cmdline):
543+
'''Run the given command, read its output and filter out all
544+
debugging, optimization and warning flags.'''
545+
output = os.popen(env.subst(cmdline)).read().strip()
546+
return re.sub(r'(^| )-[gOW][^ ]*', '', output)
547+
548+
flags = readconfig('$APR --cflags --cppflags --includes'
549+
' --ldflags --link-ld --libs')
543550
if apr_major < 2:
544-
env.ParseConfig('$APU --ldflags --includes --link-ld --libs',
545-
unique=0)
551+
flags += ' ' + readconfig('$APU --includes --ldflags --link-ld --libs')
552+
553+
# Now, finally, read this into the environment. It's a pity that
554+
env.ParseConfig('echo "%s"' % flags, unique=0)
546555

547556
### there is probably a better way to run/capture output.
548557
### env.ParseConfig() may be handy for getting this stuff into the build
549-
apr_libs = os.popen(env.subst('$APR --link-libtool --libs')).read().strip()
558+
apr_libs = readconfig('$APR --link-libtool --libs')
550559
if apr_major < 2:
551-
apu_libs = os.popen(env.subst('$APU --link-libtool --libs')).read().strip()
560+
apu_libs = readconfig('$APU --link-libtool --libs')
552561
else:
553562
apu_libs = ''
554563
else:

build/FindAPR.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ if(NOT _apru_include_only_utilities)
229229
_apru_config(${APR_CONFIG_EXECUTABLE} ${_varname} "${_regexp}" "${ARGN}")
230230
endmacro(_apr_invoke)
231231

232-
_apr_invoke(APR_CFLAGS "(^| )-(g|O)[^ ]*" --cppflags --cflags)
232+
_apr_invoke(APR_CFLAGS "(^| )-[gOW][^ ]*" --cppflags --cflags)
233233
_apr_invoke(APR_INCLUDES "(^| )-I" --includes)
234234
_apr_invoke(APR_LDFLAGS "" --ldflags)
235235
_apr_invoke(APR_LIBRARIES "" --link-ld)

0 commit comments

Comments
 (0)