Skip to content

Commit a1fe016

Browse files
On the PR-8 branch: Catch up with trunk r1926940
git-svn-id: https://svn.apache.org/repos/asf/serf/branches/PR-8@1926941 13f79535-47bb-0310-9956-ffa450edef68
2 parents 85456f7 + 9b68009 commit a1fe016

File tree

6 files changed

+71
-32
lines changed

6 files changed

+71
-32
lines changed

CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,20 @@ install(FILES ${HEADERS} DESTINATION "${SERF_INSTALL_HEADERS}")
470470

471471
# Generate the pkg-config module file.
472472
if(NOT SERF_WINDOWS)
473+
set(SERF_PC_FILE "serf-${SERF_MAJOR_VERSION}.pc")
474+
473475
# Use a separate variable scope for the substitutions in serf.pc.in.
474476
function(make_pkgconfig)
475-
set(PREFIX ${CMAKE_INSTALL_PREFIX})
477+
# Use a relative prefix to create a relocatable PC file.
478+
file(RELATIVE_PATH relfragment "/${SERF_INSTALL_PKGCONFIG}" "/")
479+
file(TO_CMAKE_PATH "\${pcfiledir}/${relfragment}" relprefix)
480+
481+
set(PREFIX ${relprefix})
476482
set(INCLUDE_SUBDIR ${SERF_INCLUDE_SUBDIR})
477483
set(LIBDIR \${prefix}/${SERF_INSTALL_LIBRARIES})
478484
set(VERSION ${SERF_VERSION})
479485
set(MAJOR ${SERF_MAJOR_VERSION})
480-
set(SERF_INTERFACE_LIBS
486+
set(LIBS
481487
${APR_LDFLAGS}
482488
${APR_LIBRARIES}
483489
${APR_EXTRALIBS}
@@ -487,16 +493,13 @@ if(NOT SERF_WINDOWS)
487493
${GSSAPI_LIBRARIES}
488494
${ZLIB_LIBRARIES}
489495
)
490-
list(REMOVE_DUPLICATES SERF_INTERFACE_LIBS)
491-
unset(LIBS)
492-
foreach(DEPLIB ${SERF_INTERFACE_LIBS})
493-
string(APPEND LIBS " ${DEPLIB}")
494-
endforeach()
495-
configure_file("build/serf.pc.in" "serf-${SERF_MAJOR_VERSION}.pc" @ONLY)
496+
list(REMOVE_DUPLICATES LIBS)
497+
list(JOIN LIBS " " LIBS)
498+
configure_file("build/serf.pc.in" "${SERF_PC_FILE}" @ONLY)
496499
endfunction()
497500

498501
make_pkgconfig()
499-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/serf-${SERF_MAJOR_VERSION}.pc"
502+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${SERF_PC_FILE}"
500503
DESTINATION "${SERF_INSTALL_PKGCONFIG}")
501504
endif()
502505

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ to apu-1-config in $APU or $APU/bin/apu-1-config.
6868
OPENSSL should specify the root of the install (e.g., /opt/local). The
6969
includes will be found $OPENSSL/include/openssl and libraries at $OPENSSL/lib.
7070

71-
OPENSSL should specify the root of the install. The includes will be found
71+
ZLIB should specify the root of the install. The includes will be found
7272
$ZLIB/include and libraries at $ZLIB/lib.
7373

7474
The BROTLI and GSSAPI dependencies are optional.

SConstruct

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ def createPathIsDirCreateWithTarget(target):
9696
return PathVariable.PathAccept(key, val, env)
9797
return my_validator
9898

99+
def filter_cflags(env, cmd, unique=0):
100+
'''Filter all debugging, optimization and warning flags from 'cmd'.'''
101+
cmd = re.sub(r'(^|\s)-[gOW]\S*', '', cmd)
102+
return env.MergeFlags(cmd, unique)
103+
104+
def unsubstable(string):
105+
'''There are things that SCons just shouldn't Subst.'''
106+
return string.replace('$', '$$')
107+
99108
# default directories
100109
if sys.platform == 'win32':
101110
default_incdir='..'
@@ -538,11 +547,13 @@ else:
538547
### we should use --cc, but that is giving some scons error about an implicit
539548
### dependency upon gcc. probably ParseConfig doesn't know what to do with
540549
### the apr-1-config output
541-
env.ParseConfig('$APR --cflags --cppflags --ldflags --includes'
542-
' --link-ld --libs', unique=0)
550+
551+
env.ParseConfig('$APR --cflags --cppflags --includes'
552+
' --ldflags --link-ld --libs',
553+
filter_cflags)
543554
if apr_major < 2:
544-
env.ParseConfig('$APU --ldflags --includes --link-ld --libs',
545-
unique=0)
555+
env.ParseConfig('$APU --includes --ldflags --link-ld --libs',
556+
filter_cflags)
546557

547558
### there is probably a better way to run/capture output.
548559
### env.ParseConfig() may be handy for getting this stuff into the build
@@ -667,12 +678,14 @@ for d in env['LIBPATH']:
667678
env.Append(RPATH=[':'+d])
668679

669680
# Set up the construction of serf-*.pc
681+
pkgprefix = os.path.relpath(env.subst('$PREFIX'), env.subst('$LIBDIR/pkgconfig'))
682+
pkglibdir = os.path.relpath(env.subst('$LIBDIR'), env.subst('$PREFIX'))
670683
pkgconfig = env.Textfile('serf-%d.pc' % (MAJOR,),
671684
env.File('build/serf.pc.in'),
672685
SUBST_DICT = {
673686
'@MAJOR@': str(MAJOR),
674-
'@PREFIX@': re.escape(str(env['PREFIX'])),
675-
'@LIBDIR@': re.escape(str(env['LIBDIR'])),
687+
'@PREFIX@': unsubstable('${pcfiledir}/' + pkgprefix),
688+
'@LIBDIR@': unsubstable('${prefix}/' + pkglibdir),
676689
'@INCLUDE_SUBDIR@': 'serf-%d' % (MAJOR,),
677690
'@VERSION@': '%d.%d.%d' % (MAJOR, MINOR, PATCH),
678691
'@LIBS@': '%s %s %s %s -lz' % (apu_libs, apr_libs,
@@ -741,7 +754,10 @@ test_app = ("%s %s %s %s") % (sys.executable, check_script, test_dir, 'test')
741754
test_env = {'PATH' : os.environ['PATH'],
742755
'srcdir' : src_dir}
743756
if sys.platform != 'win32':
744-
test_env['LD_LIBRARY_PATH'] = ':'.join(tenv.get('LIBPATH', []))
757+
os_library_path = os.environ.get('LD_LIBRARY_PATH')
758+
os_library_path = [os_library_path] if os_library_path else []
759+
ld_library_path = [tenv.subst(p) for p in tenv.get('LIBPATH', [])]
760+
test_env['LD_LIBRARY_PATH'] = ':'.join(ld_library_path + os_library_path)
745761
env.AlwaysBuild(env.Alias('check', TEST_EXES, test_app, ENV=test_env))
746762

747763
testall_files = [

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)

build/check.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# to you under the Apache License, Version 2.0 (the
1111
# "License"); you may not use this file except in compliance
1212
# with the License. You may obtain a copy of the License at
13-
#
13+
#
1414
# http://www.apache.org/licenses/LICENSE-2.0
15-
#
15+
#
1616
# Unless required by applicable law or agreed to in writing,
1717
# software distributed under the License is distributed on an
1818
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -60,8 +60,25 @@
6060
sys.exit(1)
6161

6262
print("== Running the unit tests ==")
63+
64+
fails = 0
65+
def print_exception(x):
66+
global fails
67+
print("ERROR: test(s) failed in '%s', exit code=%d"
68+
% (' '.join(x.cmd), x.returncode))
69+
fails += 1
70+
6371
try:
64-
subprocess.check_call(TEST_ALL_EXE)
72+
suites = subprocess.check_output([TEST_ALL_EXE, '-L']).decode()
73+
for suite in suites.splitlines():
74+
testcase = (TEST_ALL_EXE, suite.strip())
75+
print("==== %s %s" % testcase)
76+
try:
77+
subprocess.check_call(testcase)
78+
except subprocess.CalledProcessError as x:
79+
print_exception(x)
6580
except subprocess.CalledProcessError as x:
66-
print("ERROR: test(s) failed in '%s', exit code=%d" % (x.cmd, x.returncode))
81+
print_exception(x)
82+
83+
if fails > 0:
6784
sys.exit(1)

test/test_all.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
* ====================================================================
1919
*/
2020

21-
#include "apr.h"
22-
#include "apr_pools.h"
21+
#include <stdlib.h>
22+
23+
#include <apr.h>
2324
#include <apr_signal.h>
2425

2526
#include "test_serf.h"
26-
#include <stdlib.h>
2727

2828
static const struct testlist {
2929
const char *testname;
@@ -62,19 +62,22 @@ int main(int argc, char *argv[])
6262
if (!strcmp(argv[i], "-v")) {
6363
continue;
6464
}
65-
if (!strcmp(argv[i], "-l")) {
65+
if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "-L")) {
66+
const int details = !strcmp(argv[i], "-l");
6667
for (i = 0; tests[i].func != NULL; i++) {
6768
CuSuite *suite;
68-
int j = 0;
6969

7070
printf("%s\n", tests[i].testname);
71-
suite = tests[i].func();
71+
if (details) {
72+
int j;
7273

73-
for (j = 0; j < suite->count; j++) {
74-
printf(" %3d - %s\n", j+1, suite->list[j]->name);
75-
}
74+
suite = tests[i].func();
75+
for (j = 0; j < suite->count; j++) {
76+
printf(" %3d - %s\n", j+1, suite->list[j]->name);
77+
}
7678

77-
printf("\n");
79+
printf("\n");
80+
}
7881
}
7982
exit(0);
8083
}

0 commit comments

Comments
 (0)