Skip to content

Commit 91e5157

Browse files
authored
Merge pull request SCons#3956 from bdbaddog/fix_3955_extra_shlib_output
Fix 3955 extra shlib output due to _LIBDIRFLAGS content
2 parents a061ff8 + 91298e4 commit 91e5157

12 files changed

+92
-78
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2929
- Fix versioned shared library naming for MacOS platform. (Previously was libxyz.dylib.1.2.3,
3030
has been fixed to libxyz.1.2.3.dylib. Additionally the sonamed symlink had the same issue,
3131
that is now resolved as well)
32+
- Fix #3955 - _LIBDIRFLAGS leaving $( and $) in *COMSTR output. Added affect_signature flag to
33+
_concat function. If set to False, it will prepend and append $( and $). That way the various
34+
Environment variables can use that rather than "$( _concat(...) $)".
3235

3336
From David H:
3437
- Fix Issue #3906 - `IMPLICIT_COMMAND_DEPENDENCIES` was not properly disabled when

RELEASE.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ NEW FUNCTIONALITY
1414
Fixes #396
1515
- Added --experimental flag, to enable various experimental features/tools. You can specify
1616
'all', 'none', or any combination of available experimental features.
17+
- Added affect_signature flag to _concat function. If set to False, it will prepend and append $( and $).
18+
That way the various Environment variables can use that rather than "$( _concat(...) $)".
19+
1720

1821
DEPRECATED FUNCTIONALITY
1922
------------------------

SCons/Defaults.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
import SCons.CacheDir
4343
import SCons.Environment
4444
import SCons.PathList
45+
import SCons.Scanner.Dir
4546
import SCons.Subst
4647
import SCons.Tool
47-
import SCons.Scanner.Dir
4848

4949
# A placeholder for a default Environment (for fetching source files
5050
# from source code management systems and the like). This must be
@@ -94,13 +94,13 @@ def DefaultEnvironment(*args, **kw):
9494
def StaticObjectEmitter(target, source, env):
9595
for tgt in target:
9696
tgt.attributes.shared = None
97-
return (target, source)
97+
return target, source
9898

9999

100100
def SharedObjectEmitter(target, source, env):
101101
for tgt in target:
102102
tgt.attributes.shared = 1
103-
return (target, source)
103+
return target, source
104104

105105

106106
def SharedFlagChecker(source, target, env):
@@ -291,7 +291,7 @@ def delete_func(dest, must_exist=0):
291291
continue
292292
# os.path.isdir returns True when entry is a link to a dir
293293
if os.path.isdir(entry) and not os.path.islink(entry):
294-
shutil.rmtree(entry, 1)
294+
shutil.rmtree(entry, True)
295295
continue
296296
os.unlink(entry)
297297

@@ -312,7 +312,7 @@ def mkdir_func(dest):
312312

313313

314314
Mkdir = ActionFactory(mkdir_func,
315-
lambda dir: 'Mkdir(%s)' % get_paths_str(dir))
315+
lambda _dir: 'Mkdir(%s)' % get_paths_str(_dir))
316316

317317

318318
def move_func(dest, src):
@@ -347,27 +347,38 @@ def touch_func(dest):
347347

348348
# Internal utility functions
349349

350-
351-
def _concat(prefix, iter, suffix, env, f=lambda x: x, target=None, source=None):
350+
# pylint: disable-msg=too-many-arguments
351+
def _concat(prefix, items_iter, suffix, env, f=lambda x: x, target=None, source=None, affect_signature=True):
352352
"""
353-
Creates a new list from 'iter' by first interpolating each element
353+
Creates a new list from 'items_iter' by first interpolating each element
354354
in the list using the 'env' dictionary and then calling f on the
355355
list, and finally calling _concat_ixes to concatenate 'prefix' and
356356
'suffix' onto each element of the list.
357357
"""
358-
if not iter:
359-
return iter
360358

361-
l = f(SCons.PathList.PathList(iter).subst_path(env, target, source))
359+
if not items_iter:
360+
return items_iter
361+
362+
l = f(SCons.PathList.PathList(items_iter).subst_path(env, target, source))
362363
if l is not None:
363-
iter = l
364+
items_iter = l
364365

365-
return _concat_ixes(prefix, iter, suffix, env)
366+
if not affect_signature:
367+
value = ['$(']
368+
else:
369+
value = []
370+
value += _concat_ixes(prefix, items_iter, suffix, env)
366371

372+
if not affect_signature:
373+
value += ["$)"]
367374

368-
def _concat_ixes(prefix, iter, suffix, env):
375+
return value
376+
# pylint: enable-msg=too-many-arguments
377+
378+
379+
def _concat_ixes(prefix, items_iter, suffix, env):
369380
"""
370-
Creates a new list from 'iter' by concatenating the 'prefix' and
381+
Creates a new list from 'items_iter' by concatenating the 'prefix' and
371382
'suffix' arguments onto each element of the list. A trailing space
372383
on 'prefix' or leading space on 'suffix' will cause them to be put
373384
into separate list elements rather than being concatenated.
@@ -379,7 +390,7 @@ def _concat_ixes(prefix, iter, suffix, env):
379390
prefix = str(env.subst(prefix, SCons.Subst.SUBST_RAW))
380391
suffix = str(env.subst(suffix, SCons.Subst.SUBST_RAW))
381392

382-
for x in SCons.Util.flatten(iter):
393+
for x in SCons.Util.flatten(items_iter):
383394
if isinstance(x, SCons.Node.FS.File):
384395
result.append(x)
385396
continue
@@ -606,8 +617,10 @@ def __lib_either_version_flag(env, version_var1, version_var2, flags_var):
606617
'_defines': _defines,
607618
'_stripixes': _stripixes,
608619
'_LIBFLAGS': '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}',
609-
'_LIBDIRFLAGS': '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)',
610-
'_CPPINCFLAGS': '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)',
620+
621+
'_LIBDIRFLAGS': '${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}',
622+
'_CPPINCFLAGS': '${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}',
623+
611624
'_CPPDEFFLAGS': '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__, TARGET, SOURCE)}',
612625

613626
'__libversionflags': __libversionflags,

SCons/Defaults.xml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,23 @@ See its __doc__ string for a discussion of the format.
2525

2626
<cvar name ="_concat">
2727
<summary>
28-
<para>
29-
A function used to produce variables like &cv-link-_CPPINCFLAGS;. It takes
30-
four or five
31-
arguments: a prefix to concatenate onto each element, a list of
32-
elements, a suffix to concatenate onto each element, an environment
33-
for variable interpolation, and an optional function that will be
34-
called to transform the list before concatenation.
35-
</para>
36-
37-
<example_commands>
38-
env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)',
39-
</example_commands>
28+
<para>
29+
A function used to produce variables like &cv-link-_CPPINCFLAGS;. It takes
30+
four mandatory arguments, and up to 4 additional optional arguments:
31+
1) a prefix to concatenate onto each element,
32+
2) a list of elements,
33+
3) a suffix to concatenate onto each element,
34+
4) an environment for variable interpolation,
35+
5) an optional function that will be called to transform the list before concatenation,
36+
6) an optionally specified target (Can use TARGET),
37+
7) an optionally specified source (Can use SOURCE),
38+
8) optional <parameter>affect_signature</parameter> flag which will wrap non-empty returned value with $( and $) to indicate the contents
39+
should not affect the signature of the generated command line.
40+
</para>
41+
42+
<example_commands>
43+
env['_CPPINCFLAGS'] = '${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}'
44+
</example_commands>
4045
</summary>
4146
</cvar>
4247

SCons/EnvironmentTests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_subst_proxy(self):
143143
return self
144144

145145
def test_tool( env ):
146-
env['_F77INCFLAGS'] = '$( ${_concat(INCPREFIX, F77PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
146+
env['_F77INCFLAGS'] = '${_concat(INCPREFIX, F77PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}'
147147

148148
class TestEnvironmentFixture:
149149
def TestEnvironment(self, *args, **kw):
@@ -1488,6 +1488,9 @@ def test_concat(self):
14881488
assert x == 'prea bsuf', x
14891489
x = s("${_concat(PRE, LIST, SUF, __env__)}")
14901490
assert x == 'preasuf prebsuf', x
1491+
x = s("${_concat(PRE, LIST, SUF, __env__,affect_signature=False)}", raw=True)
1492+
assert x == '$( preasuf prebsuf $)', x
1493+
14911494

14921495
def test_concat_nested(self):
14931496
"""Test _concat() on a nested substitution strings."""

SCons/Tool/FortranCommon.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
"""SCons.Tool.FortranCommon
2-
3-
Stuff for processing Fortran, common to all fortran dialects.
4-
5-
"""
6-
71
# MIT License
82
#
93
# Copyright The SCons Foundation
@@ -25,7 +19,12 @@
2519
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2620
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2721
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
"""SCons.Tool.FortranCommon
24+
25+
Stuff for processing Fortran, common to all fortran dialects.
26+
27+
"""
2928

3029
import re
3130
import os.path
@@ -35,6 +34,7 @@
3534
import SCons.Tool
3635
import SCons.Util
3736

37+
3838
def isfortran(env, source):
3939
"""Return 1 if any of code in source has fortran files in it, 0
4040
otherwise."""
@@ -147,7 +147,7 @@ def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0):
147147
if 'INC%sSUFFIX' % dialect not in env:
148148
env['INC%sSUFFIX' % dialect] = '$INCSUFFIX'
149149

150-
env['_%sINCFLAGS' % dialect] = '$( ${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' % (dialect, dialect, dialect)
150+
env['_%sINCFLAGS' % dialect] = '${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}' % (dialect, dialect, dialect)
151151

152152
if support_module == 1:
153153
env['%sCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)

SCons/Tool/linkCommon/SharedLibrary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ def setup_shared_lib_logic(env):
208208
env["SHLIBEMITTER"] = [lib_emitter, shlib_symlink_emitter]
209209

210210
# If it's already set, then don't overwrite.
211-
env["SHLIBPREFIX"] = env.get('SHLIBPREFIX',"lib")
211+
env["SHLIBPREFIX"] = env.get('SHLIBPREFIX', "lib")
212212
env["_SHLIBSUFFIX"] = "${SHLIBSUFFIX}${_SHLIBVERSION}"
213213

214214
env["SHLINKFLAGS"] = CLVar("$LINKFLAGS -shared")
215215

216216
env["SHLINKCOM"] = "$SHLINK -o $TARGET $SHLINKFLAGS $__SHLIBVERSIONFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS"
217-
env["SHLINKCOMSTR"] = "$SHLINKCOM"
217+
218218
env["SHLINK"] = "$LINK"

SCons/Tool/mingw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def generate(env):
180180
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
181181
env['RC'] = 'windres'
182182
env['RCFLAGS'] = SCons.Util.CLVar('')
183-
env['RCINCFLAGS'] = '$( ${_concat(RCINCPREFIX, CPPPATH, RCINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
183+
env['RCINCFLAGS'] = '${_concat(RCINCPREFIX, CPPPATH, RCINCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}'
184184
env['RCINCPREFIX'] = '--include-dir '
185185
env['RCINCSUFFIX'] = ''
186186
env['RCCOM'] = '$RC $_CPPDEFFLAGS $RCINCFLAGS ${RCINCPREFIX} ${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'

SCons/Tool/swig.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
"""
3030

3131
import os.path
32-
import sys
3332
import re
3433
import subprocess
34+
import sys
3535

3636
import SCons.Action
3737
import SCons.Defaults
38+
import SCons.Node
3839
import SCons.Tool
3940
import SCons.Util
40-
import SCons.Node
4141
import SCons.Warnings
4242

4343
verbose = False
@@ -194,17 +194,19 @@ def generate(env):
194194

195195
if 'SWIG' not in env:
196196
env['SWIG'] = env.Detect(swigs) or swigs[0]
197-
env['SWIGVERSION'] = _get_swig_version(env, env['SWIG'])
198-
env['SWIGFLAGS'] = SCons.Util.CLVar('')
197+
198+
env['SWIGVERSION'] = _get_swig_version(env, env['SWIG'])
199+
env['SWIGFLAGS'] = SCons.Util.CLVar('')
199200
env['SWIGDIRECTORSUFFIX'] = '_wrap.h'
200-
env['SWIGCFILESUFFIX'] = '_wrap$CFILESUFFIX'
201+
env['SWIGCFILESUFFIX'] = '_wrap$CFILESUFFIX'
201202
env['SWIGCXXFILESUFFIX'] = '_wrap$CXXFILESUFFIX'
202-
env['_SWIGOUTDIR'] = r'${"-outdir \"%s\"" % SWIGOUTDIR}'
203-
env['SWIGPATH'] = []
204-
env['SWIGINCPREFIX'] = '-I'
205-
env['SWIGINCSUFFIX'] = ''
206-
env['_SWIGINCFLAGS'] = '$( ${_concat(SWIGINCPREFIX, SWIGPATH, SWIGINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
207-
env['SWIGCOM'] = '$SWIG -o $TARGET ${_SWIGOUTDIR} ${_SWIGINCFLAGS} $SWIGFLAGS $SOURCES'
203+
env['_SWIGOUTDIR'] = r'${"-outdir \"%s\"" % SWIGOUTDIR}'
204+
env['SWIGPATH'] = []
205+
env['SWIGINCPREFIX'] = '-I'
206+
env['SWIGINCSUFFIX'] = ''
207+
env['_SWIGINCFLAGS'] = '${_concat(SWIGINCPREFIX, SWIGPATH, SWIGINCSUFFIX,' \
208+
'__env__, RDirs, TARGET, SOURCE, affect_signature=False)}'
209+
env['SWIGCOM'] = '$SWIG -o $TARGET ${_SWIGOUTDIR} ${_SWIGINCFLAGS} $SWIGFLAGS $SOURCES'
208210

209211
def exists(env):
210212
swig = env.get('SWIG') or env.Detect(['swig'])

test/SWIG/SWIGOUTDIR.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
2+
# MIT License
23
#
3-
# __COPYRIGHT__
4+
# Copyright The SCons Foundation
45
#
56
# Permission is hereby granted, free of charge, to any person obtaining
67
# a copy of this software and associated documentation files (the
@@ -20,9 +21,6 @@
2021
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2122
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2223
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
2624

2725
"""
2826
Verify that use of the $SWIGOUTDIR variable causes SCons to recognize

test/SWIG/generated_swigfile.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
2+
# MIT License
23
#
3-
# __COPYRIGHT__
4+
# Copyright The SCons Foundation
45
#
56
# Permission is hereby granted, free of charge, to any person obtaining
67
# a copy of this software and associated documentation files (the
@@ -20,9 +21,6 @@
2021
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2122
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2223
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
2624

2725
"""
2826
Verify that SCons realizes the -noproxy option means no .py file will
@@ -38,14 +36,8 @@
3836
if sys.platform == 'win32':
3937
_dll = '.dll'
4038
else:
41-
_dll = '.so'
39+
_dll = '.so'
4240

43-
# swig-python expects specific filenames.
44-
# the platform specific suffix won't necessarily work.
45-
if sys.platform == 'win32':
46-
_dll = '.dll'
47-
else:
48-
_dll = '.so'
4941

5042
test = TestSCons.TestSCons()
5143

@@ -54,12 +46,11 @@
5446
test.skip_test('Can not find installed "swig", skipping test.\n')
5547

5648
python, python_include, python_libpath, python_lib = \
57-
test.get_platform_python_info(python_h_required=True)
49+
test.get_platform_python_info(python_h_required=True)
5850

5951
# handle testing on other platforms:
6052
ldmodule_prefix = '_'
6153

62-
6354
test.write('SConstruct', """
6455
foo = Environment(CPPPATH=[r'%(python_include)s'],
6556
SWIG=[r'%(swig)s'],
@@ -69,7 +60,6 @@
6960
python_c_file = foo.CFile( target='python_swig_test',source=python_interface, SWIGFLAGS = '-python -c++' )
7061
java_interface = foo.Command( 'test_java_swig.i', Value(1),'echo %%module test_java_swig > test_java_swig.i' )
7162
java_c_file = foo.CFile( target='java_swig_test' ,source=java_interface, SWIGFLAGS = '-java -c++' )
72-
7363
""" % locals())
7464

7565
expected_stdout = """\
@@ -78,12 +68,11 @@
7868
echo %%module test_py_swig > test_py_swig.i
7969
%(swig)s -o python_swig_test_wrap.cc -python -c++ test_py_swig.i
8070
""" % locals()
81-
test.run(arguments = '.',stdout=test.wrap_stdout(expected_stdout))
82-
71+
test.run(arguments='.', stdout=test.wrap_stdout(expected_stdout))
8372

8473
# If we mistakenly depend on the .py file that SWIG didn't create
8574
# (suppressed by the -noproxy option) then the build won't be up-to-date.
86-
test.up_to_date(arguments = '.')
75+
test.up_to_date(arguments='.')
8776

8877
test.pass_test()
8978

0 commit comments

Comments
 (0)