覆盖SCons缓存复制功能 [英] Overriding SCons Cache Copy Function
问题描述
我试图弄清楚当SCons将工件从缓存目录(由CacheDir提供)复制到使用的硬链接时,如何覆盖行为.
I'm trying to figure out how to override the behaviour when SCons copies artifacts from the cache directory (given by CacheDir) to used hard-links.
我目前的尝试
def link_or_copy_file(class_instance, src, dst):
# do hardlinking instead...
SCons.Defaults.DefaultEnvironment()._copy_from_cache = link_or_copy_file
SCons.Defaults.DefaultEnvironment()._copy2_from_cache = link_or_copy_file
env = Environment()
env._copy_from_cache = link_or_copy_file
env._copy2_from_cache = link_or_copy_file
对env
的后续使用没有影响.永远不会调用功能link_or_copy_file
.怎么了?
has no effect on subsequent usage of env
. The function link_or_copy_file
is never called. What is wrong?
不可能以这种方式覆盖Python类成员函数.
Isn't it possible to override a Python class member function in this way.
更新:另请注意,在调用env.Decider()
之后,我正在执行此操作,因为此函数可能会覆盖成员_copy_from_cache
和_copy2_from_cache
.
Update: Also note that I'm doing this after env.Decider()
has been called as this function possibly overrides the members _copy_from_cache
and _copy2_from_cache
.
推荐答案
我们终于弄清楚了
import SCons.Environment
SCons.Environment.Environment._copy_from_cache = link_or_copy_file
SCons.Environment.Environment._copy2_from_cache = link_or_copy_file
工作.
这篇关于覆盖SCons缓存复制功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!