开发者

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

开发者 https://www.devze.com 2023-03-06 23:49 出处:网络
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开发者

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
0

精彩评论

暂无评论...
验证码 换一张
取 消