serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Branko ─îibej <br...@apache.org>
Subject [PATCH] Changes to SConstruct for Solaris
Date Thu, 10 Sep 2015 11:22:42 GMT
Hey.

I've set up a buildbot slave on a sparc64-solaris box, and had to make
some changes to the SConstruct file in order to get Serf to build and
the tests to run. There are three sets of changes in this patch:

 1. Build fixes: I got these from Philip's original patch to build Serf
    on the Solaris buildslave for Subversion tests, and I gather from
    googling around that they're standard workarounds for scons bugs; to
    whit: SHLIBVERSION must not be set, and PLATFORM must be explicitly
    set to 'posix' in order to make the build work.

 2. Test environment fixes: When using shared libraries from non-default
    locations (in this case, APR/Util and OpenSSL), the required loader
    paths were not forwarded to build/check.py. I changed SConstruct to
    construct LD_LIBRARY_PATH and add it to the test process
    environment. The equivalent DYLD_* for OSX is not needed because
    RPATH tags are always set by the linker.

 3. Cosmetic changes: I added GCC detection so that we don't send
    GCC-specific options to the SunPRO compiler.

[[[
Fix building and testing on the Solaris build slave.

* SConstruct:
  - On Solaris, do not set the SHLIBVERSION variable and
    explicitly set PLATFORM to 'posix', otherwise it's detected
    as 'sunos5' and tools detection fails.
  - Detect a GNU-compatible C compiler and only use GCC-specific
    compiler options if that's what we're using.
  - Construct LD_LIBRARY_PATH for the test environment, otherwise
    dependencies (e.g., APR) that are not in the default load
    path are not found. 
]]]


Index: SConstruct
===================================================================
--- SConstruct	(revision 1702053)
+++ SConstruct	(working copy)
@@ -222,7 +222,8 @@ incdir = '$PREFIX/include/serf-$MAJOR'
 # Unfortunately we can't set the .dylib compatibility_version option separately
 # from current_version, so don't use the PATCH level to avoid that build and
 # runtime patch levels have to be identical.
-env['SHLIBVERSION'] = '%d.%d.%d' % (MAJOR, MINOR, 0)
+if sys.platform != 'sunos5':
+  env['SHLIBVERSION'] = '%d.%d.%d' % (MAJOR, MINOR, 0)
 
 LIBNAME = 'libserf-%d' % (MAJOR,)
 if sys.platform != 'win32':
@@ -238,12 +239,23 @@ if sys.platform == 'darwin':
   env.Append(LINKFLAGS=['-Wl,-install_name,%s/%s.dylib' % (thisdir, LIBNAME,)])
 
 if sys.platform != 'win32':
-  ### gcc only. figure out appropriate test / better way to check these
-  ### flags, and check for gcc.
-  env.Append(CFLAGS=['-std=c89'])
+  def CheckGnuCC(context):
+    src = '''
+    #ifndef __GNUC__
+    oh noes!
+    #endif
+    '''
+    context.Message('Checking for GNU-compatible C compiler...')
+    result = context.TryCompile(src, '.c')
+    context.Result(result)
+    return result
 
-  ### These warnings are not available on Solaris
-  if sys.platform != 'sunos5': 
+  conf = Configure(env, custom_tests = dict(CheckGnuCC=CheckGnuCC))
+  have_gcc = conf.CheckGnuCC()
+  env = conf.Finish()
+
+  if have_gcc:
+    env.Append(CFLAGS=['-std=c89'])
     env.Append(CCFLAGS=['-Wdeclaration-after-statement',
                         '-Wmissing-prototypes',
                         '-Wall'])
@@ -260,6 +272,7 @@ if sys.platform != 'win32':
 
   if sys.platform == 'sunos5':
     env.Append(LIBS=['m'])
+    env.Append(PLATFORM='posix')
 else:
   # Warning level 4, no unused argument warnings
   env.Append(CCFLAGS=['/W4', '/wd4100'])
@@ -473,18 +486,22 @@ if sys.platform == 'win32':
 else:
   TEST_EXES = [ os.path.join('test', '%s' % (prog)) for prog in TEST_PROGRAMS ]
 
+# Find the (dynamic) library in this directory
+tenv.Replace(RPATH=thisdir)
+tenv.Prepend(LIBS=[LIBNAMESTATIC, ],
+             LIBPATH=[thisdir, ])
+
 check_script = env.File('build/check.py').rstr()
 test_dir = env.File('test/test_all.c').rfile().get_dir()
 src_dir = env.File('serf.h').rfile().get_dir()
 test_app = ("%s %s %s %s") % (sys.executable, check_script, test_dir, 'test')
-env.AlwaysBuild(env.Alias('check', TEST_EXES, test_app,
-                          ENV={'PATH' : os.environ['PATH'],
-                               'srcdir' : src_dir}))
 
-# Find the (dynamic) library in this directory
-tenv.Replace(RPATH=thisdir)
-tenv.Prepend(LIBS=[LIBNAMESTATIC, ],
-             LIBPATH=[thisdir, ])
+# Set the library search path for the test programs
+test_env = {'PATH' : os.environ['PATH'],
+            'srcdir' : src_dir}
+if sys.platform != 'win32':
+  test_env['LD_LIBRARY_PATH'] = ':'.join(tenv.get('LIBPATH', []))
+env.AlwaysBuild(env.Alias('check', TEST_EXES, test_app, ENV=test_env))
 
 testall_files = [
         'test/test_all.c',


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message