Skip to content

Commit a464430

Browse files
committed
BLD: setup only test targets when test_installed=1.
Also move the scons configure step after adding compiler-related flags.
1 parent 5d009c6 commit a464430

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/SConscript

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ if env['PLATFORM'] == 'darwin':
3030
env.AppendUnique(SHLINKFLAGS='-headerpad_max_install_names')
3131
fast_linkflags[:] = []
3232

33-
# configure version specific options.
34-
skip_configure = (GetOption('clean') or GetOption('help') or
35-
(['sdist'] == list(COMMAND_LINE_TARGETS)))
36-
if not skip_configure:
37-
SConscript('SConscript.configure')
38-
elif GetOption('clean'):
39-
# make sure ObjCryst files will be also cleaned
40-
env['has_objcryst'] = True
41-
4233
# Compiler specific options
4334
if icpc:
4435
# options for Intel C++ compiler on hpc dev-intel07
@@ -66,22 +57,37 @@ if env['coverage']:
6657
env.Append(CCFLAGS=['--coverage', '-O0'])
6758
env.Append(LINKFLAGS='--coverage')
6859

60+
# configure boost and ObjCryst libraries unless non-relevant.
61+
skip_configure = (GetOption('clean') or GetOption('help') or
62+
(['sdist'] == list(COMMAND_LINE_TARGETS)))
63+
if not skip_configure:
64+
SConscript('SConscript.configure')
65+
66+
# when cleaning make sure to also purge ObjCryst files
67+
if GetOption('clean'):
68+
env['has_objcryst'] = True
69+
6970
# Define lists for storing library source and include files.
7071
env['lib_includes'] = []
7172
env['lib_sources'] = []
7273
env['lib_datafiles'] = []
7374

7475
# Subsidiary SConscripts -----------------------------------------------------
7576

76-
# Determine if unit tests need to be built.
77-
build_tests = set(('test', 'alltests')).intersection(COMMAND_LINE_TARGETS)
77+
# The targets that concern unit tests.
78+
targets_that_test = set(('test', 'alltests'))
7879

7980
# Short circuit if we test an already installed library. Do not define
8081
# any further targets as they may conflict with the installed files.
81-
if build_tests and env['test_installed']:
82+
if env['test_installed']:
8283
SConscript('tests/SConscript')
84+
if not targets_that_test.issuperset(COMMAND_LINE_TARGETS):
85+
print('Warning: only test targets are available when '
86+
'"test_installed=True".')
8387
Return()
8488

89+
assert not env['test_installed']
90+
8591
# Here we do not test the installed library. Any diffpy headers
8692
# should thus be looked up from our source tree.
8793
env.PrependUnique(CPPPATH=Dir('.'))
@@ -121,8 +127,7 @@ Default(lib)
121127

122128
# Define targets related to testing. Do so only when testing is requested.
123129
# This enables library build on machines without cxxtest.
124-
if build_tests:
125-
assert not env['test_installed']
130+
if targets_that_test.intersection(COMMAND_LINE_TARGETS):
126131
SConscript('tests/SConscript')
127132

128133
# Installation targets.

0 commit comments

Comments
 (0)