gpt4 book ai didi

SCons:获取原始文件的绝对路径(就好像我没有设置variant_dir一样)

转载 作者:行者123 更新时间:2023-12-02 01:35:26 26 4
gpt4 key购买 nike

我可以使用File('foo.bar').abspath获取文件的位置,但如果我设置了variant_dir,则返回的路径将位于variant_dir而不是原始位置。如果我有duplicate=0设置,那么返回的文件实际上并不存在。

显然 SCons 知道原始文件在哪里,因为它是在文件实际构建时作为参数传递的(例如 gcc -c -o variant/foo.o orig/foo.c )。

是否有某种File('foo.bar').origpath我可以用吗?

如果需要的话我可以使用 os.path.join(Dir('#').abspath, 'orig')但这需要 SConscript 知道它位于哪个目录,这很困惑。

最佳答案

您可以使用srcnode() 。引用man page :

The srcnode() method returns another File or Dir object representing the source path of the given File or Dir.

这将为您提供源目录中的绝对路径:

File('foo.bar').srcnode().abspath

关于SCons:获取原始文件的绝对路径(就好像我没有设置variant_dir一样),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6066545/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com