[Scons-users] How can I manipulate $SOURCE and $TARGET

Tom Tanner (BLOOMBERG/ LONDON) ttanner2 at bloomberg.net
Thu Feb 13 04:07:24 EST 2014

You could use something like $(TARGET.file} to get purely the filename, but I think you might have to provide your own function to get just the lowest level directory, somewhat like this (from 'variable substitution' in the man page)

def foo(target, source, env, for_signature):
tgt = str(target[0])
return os.path.join(os.path.basename(os.path.dirname(tgt)), os.path.basename(tgt))

env['FOO'] = foo

then in your LINKCOMSTR use $FOO rather than $TARGET

Warning: This is untested

----- Original Message -----
From: scons-users at scons.org
To: scons-users at scons.org
At: Feb 13 2014 00:41:39

Using one of LINKCOMSTR or its variants to control the output of a build, I would like to strip some of the leading directories from the $SOURCE and $TARGET strings. For example, if $TARGET is


I would like to print just


and ignore the boilerplate root directories as just adding noise to the output.

I am a novice at this, so hopefully I just missed the obvious.


Dr. James J. Russell
Stanford Linear Accelerator Center
russell at slac.stanford.edu

Scons-users mailing list
Scons-users at scons.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140213/25343347/attachment.html

More information about the Scons-users mailing list