I can use File('foo.bar').abspath
to get the location of a file, but if I've got variant_dir set then the returned path will be in variant_dir rather than it's original location. If I have du开发者_如何学运维plicate=0
set, then the file returned won't actually exist.
Obviously SCons knows where the original file is, as it's passed as an argument when the file's actually built (eg gcc -c -o variant/foo.o orig/foo.c
).
Is there some sort of File('foo.bar').origpath
that I can use?
If it came to it I could use os.path.join(Dir('#').abspath, 'orig')
but that requires the SConscript to know which directory it's in, which is messy.
You can use srcnode()
. To quote the man page:
The srcnode() method returns another File or Dir object representing the source path of the given File or Dir.
This will give you the absolute path in the source directory:
File('foo.bar').srcnode().abspath
精彩评论