[Scons-users] Double backslashes in $SOURCE while using a TempFileMunge

Dirk Bächle tshortik at gmx.de
Mon Aug 26 18:06:54 EDT 2013

Hi Andreas,

I pondered a bit over this problem...please find my approach below.

On 23.08.2013 17:15, Andreas Schmidl wrote:

> Hello!


> Currently I'm integrating a crossplatform toolchain into scons. I

> would like to use it for building libraries and elf files for an

> embedded system. Because I have to many objects which should be packed

> in one library with the helb of ar, I would like to use the

> TempFileMunge method of scons. The temp file, which is generated by

> the TempFileMunge class of scons uses in the pathes to the objects

> only one \ (backslash). But ar expects that backslashes are escaped

> with two backslashes.


> [...]

> I tried to move the replace operation which is currently located in

> the TempFileMunge class to the env['ARCOM'] variable. It looks like this:

> "${TEMPFILE('$AR $ARFLAGS $TARGET [a.replace('\\', '\\\\') for a in

> $SOURCES]')}"


> But this is an invalid expression. (Reported by python). Is it

> possible to write such a replace statement into an scons environment

> variable?


Instead of doing everything at once, I'd try to split things up a
little. First, prepare the expanded list of sources:

def expand_sources(target, source, env, for_signature):
slist = [str(a).replace('\\','\\\\') for a in source]
return ' '.join(*slist)

env['EXPANDED_SOURCES'] = expand_sources

and then redefine the ARCOM variable to:


Note: The code above is completely untested, but I hope you get the idea
behind it.

Best regards,


More information about the Scons-users mailing list