Skip to content

Commit 1538edc

Browse files
committed
BLD: clean up library and test build configuration.
Use separate scons environment for linking libdiffpy with extra libraries. Simplify setup of header search path and library dependencies when building the alltests test program.
1 parent 1bfd8f8 commit 1538edc

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/SConscript

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ Import('env')
88
flagnames = 'CFLAGS CXXFLAGS LDFLAGS'.split()
99
env.MergeFlags([os.environ.get(n, '') for n in flagnames])
1010

11-
# The directory of this SConscript should be searched first for any headers.
12-
env.PrependUnique(CPPPATH=Dir('.'))
13-
1411
# Insert LIBRARY_PATH explicitly because some compilers
1512
# ignore it in the system environment.
1613
env.PrependUnique(LIBPATH=env['ENV'].get('LIBRARY_PATH', '').split(':'))
@@ -24,11 +21,6 @@ if env['tool'] == 'intelc':
2421
Exit(1)
2522
env.Tool('intelc', topdir=icpc[:icpc.rfind('/bin')])
2623

27-
# Declare external libraries.
28-
env.ParseConfig("gsl-config --cflags --libs")
29-
# dladdr in runtimepath.cpp requires the dl library.
30-
env.AppendUnique(LIBS=['dl'])
31-
3224
fast_linkflags = ['-s']
3325

3426
# Platform specific intricacies.
@@ -90,6 +82,10 @@ if build_tests and env['test_installed']:
9082
SConscript('tests/SConscript')
9183
Return()
9284

85+
# Here we do not test the installed library. Any diffpy headers
86+
# should thus be looked up from our source tree.
87+
env.PrependUnique(CPPPATH=Dir('.'))
88+
9389
# Load the version script first to resolve the majorminor tuple
9490
SConscript('diffpy/SConscript.version')
9591

@@ -110,7 +106,15 @@ if 'sdist' in COMMAND_LINE_TARGETS:
110106
# Top Level Targets ----------------------------------------------------------
111107

112108
# lib -- shared library object
113-
libdiffpy = env.SharedLibrary('diffpy', env['lib_sources'])
109+
110+
# use new environment with extra libraries needed for libdiffpy.
111+
env_lib = env.Clone()
112+
# Setup GSL, the GNU Scientific library.
113+
env_lib.ParseConfig("gsl-config --cflags --libs")
114+
# The dladdr call in runtimepath.cpp requires the dl library.
115+
env_lib.AppendUnique(LIBS=['dl'])
116+
117+
libdiffpy = env_lib.SharedLibrary('diffpy', env['lib_sources'])
114118
Export('libdiffpy')
115119
lib = Alias('lib', [libdiffpy, env['lib_includes']])
116120
Default(lib)

src/tests/SConscript

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ env_test.Tool('cxxtest')
99

1010
if env['test_installed']:
1111
# build unit tests for the installed library
12-
env_test['CPPPATH'].remove(Dir('..'))
1312
env_test.PrependUnique(CPPPATH=env['includedir'], delete_existing=1)
1413
lib_dir = env['libdir']
1514
else:
@@ -21,11 +20,6 @@ use_our_library = not env['test_installed']
2120
env_test.PrependUnique(LIBS='diffpy', LIBPATH=lib_dir, delete_existing=1)
2221
env_test.PrependUnique(LINKFLAGS="-Wl,-rpath,%r" % lib_dir)
2322

24-
# Use only libraries needed for building the unit tests.
25-
pat = 'diffpy|boost_serialization|ObjCryst'
26-
keeplibs = lambda s: re.search(pat, str(s))
27-
env_test.Replace(LIBS=filter(keeplibs, env_test['LIBS']))
28-
2923
# Targets --------------------------------------------------------------------
3024

3125
def srcsupported(f):

0 commit comments

Comments
 (0)