[Scons-users] Using $SOURCE files with _concat and Command String Parsing

Dirk Bächle tshortik at gmx.de
Tue Aug 27 16:33:37 EDT 2013


Hi William,

thanks a lot for the detailed description of your current problem. I was
able to derive a short SConstruct from it, and could reproduce the
failing concatenation on my side.
Searching through the sources, I found an alternative to patching SCons
(as suggested by Christopher Murray).
The method "_concat" takes a fifth argument, which is sort of a wrapper
that gets applied before it tries to add prefix and suffix to each item
of the given list:

def _concat(prefix, list, suffix, env, f=lambda x: x, target=None,
source=None):

By installing your own method "f", you can ensure that the internally
created Node instances get converted to simple strings. This prevents
the File Nodes from getting skipped in SCons.Defaults, as you stated
correctly.

Please find a simple SConstruct attached, which uses the approach above.
I hope it works for you, and that we can add a WATCOM Tool to our Wiki
index soon. ;)


Best regards,

Dirk

On 25.08.2013 07:08, William D. Jones wrote:

> Hello all,

>

> [...]

> Assume I have 4 source files, called a.obj, b.obj, c.obj, and d.obj,

> and want to create a target e.exe. The correct way to link a file such

> as this is either of the following:

> wlink name e.exe option quiet file a.obj file b.obj file c.obj file d.obj

> wlink name e.exe option quiet file a.obj, b.obj, c.obj, d.obj

> [...]

> According to the SCons source code, SCons.Defaults, line 295 in

> _concat_ixes(), file nodes (of which $SOURCES is part) are

> deliberately skipped during _concatenation. I assume there is a

> logical reason for this, but without this, I cannot seem to create a

> command line which SCons will accept. That said, is there a means to

> prefix each source file with the appropriate 'file ' directive without

> modifying SCons.

> [...]


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20130827/10babbc9/attachment.htm
-------------- next part --------------
def mystr(x):
res = []
for f in x:
res.append(str(f))
return tuple(res)

env = Environment()

env['mystr'] = mystr
env['LINK'] = 'wlink'
env['_LINKSOURCES'] = '${_concat("file ", SOURCES, LINKSUFFIX, __env__, mystr)}'
env['LINKSUFFIX'] = ''
env['LINKCOM'] = "$LINK name '$TARGET' $LINKFLAGS $_LIBDIRFLAGS $_LIBFLAGS $_LINKSOURCES"

env.Program('test.exe', ['x.c','d.c','k.c','o.c'])



More information about the Scons-users mailing list