[Scons-users] Builder
Dirk Bächle
tshortik at gmx.de
Wed Nov 27 12:41:22 EST 2013
Hi Andreas,
On 27.11.2013 09:46, andreas.ames at de.transport.bombardier.com wrote:
> Hi all,
>
> sorry for hijacking this thread.
>
> scons-users-bounces at scons.org schrieb am 27.11.2013 05:13:58:
>
>> As Dirk mentioned in the email on the dev list the .name parameter
>> should not be used for this (or in general for anything.. I've never
>> used it and I've been using SCons a long time).
> I'm also using the 'name' attribute of file system nodes frequently,
> though always with doubts because I don't like to break the encapsulation
> of Node objects. Unfortunately I didn't find any method to access the
> 'basename' of a file system node.
>
> What is the recommended way to access the basename of a file system node?
this depends on what exactly you call a "basename". When you have an
SCons File/Dir Node n, the expression "str(n)" should give you the full
path of the node, starting at the top-level SConstruct.
This is the key, that SCons uses behind the curtains to identify and
reference sources and targets within your current build.
If you need the absolute path in your OS-specific filesystem for some
reason, there is the "abspath" attribute.
You can access it either directly, or reference it within an Action
command string like this:
a = SCons.Action.Action("my_parse ${TARGET.abspath} $SOURCE")
Check out the MAN page for the complete list of node path/file
attributes, that can be used similar to the example above.
Best regards,
Dirk
More information about the Scons-users
mailing list