Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCons: Get abspath of original file (as though I hadn't set variant_dir)

Tags:

scons

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.

like image 360
mcccclean Avatar asked May 20 '11 01:05

mcccclean


1 Answers

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
like image 131
richq Avatar answered Sep 24 '22 18:09

richq