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 duplicate=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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With