Overriding SCons Cache Copy Function

元气小坏坏 提交于 2019-12-08 05:26:43

问题


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.

My current try

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

has no effect on subsequent usage of env. The function link_or_copy_file is never called. What is wrong?

Isn't it possible to override a Python class member function in this way.

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.


回答1:


We finally figured out that

import SCons.Environment
SCons.Environment.Environment._copy_from_cache = link_or_copy_file
SCons.Environment.Environment._copy2_from_cache = link_or_copy_file

worked.



来源:https://stackoverflow.com/questions/27866811/overriding-scons-cache-copy-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!