我如何运行一些code后每scons的建设? [英] How do I run some code after every build in scons?

查看:190
本文介绍了我如何运行一些code后每scons的建设?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式来登记财产以后就像scons的最终构建回调。例如,我在做这样的事情现在:

I'm looking for a way to register somthing like an end-build callback in scons. For example, I'm doing something like this right now:

def print_build_summary():
    failures = SCons.Script.GetBuildFailures()
    notifyExe = 'notify-send '
    if len(failures) > 0:
        notifyExe = notifyExe + ' --urgency=critical Build Failed'
    else:
        notifyExe = notifyExe + ' --urgency=normal Build Succeed'

    os.system(notifyExe)

atexit.register(print_build_summary)

这仅适用于非交互式模式。我希望能弹出这样的事情在每个版本的结尾,具体而言,运行多个版本命令时,在交互式会话scons的。

This only works in non-interactive mode. I'd like to be able to pop up something like this at the end of every build, specifically, when running multiple 'build' commands in an interactive scons session.

唯一的建议,我已经找到了,东张西望,似乎是使用依赖系统或 AddPostAction 来电据为己有此上。它似乎没有对我很权利这样做的,因为它不是一个真正的依赖关系(它甚至不是真正的构建的一部分,严格的说) - 这是code的只是一个静态的位需要被在每一个构建结束时运行。

The only suggestions I've found, looking around, seem to be to use the dependency system or the AddPostAction call to glom this on. It doesn't seem quite right to me to do it that way, since it's not really a dependency (it's not even really a part of the build, strictly speaking) - it's just a static bit of code that needs to be run at the end of every build.

谢谢!

推荐答案

我不认为有什么错误使用依赖系统来解决这个问题。这是我常做的:

I don't think there's anything wrong with using the dependency system to resolve this. This is how I normally do it:

def finish( target, source, env ):
    raise Exception( 'DO IT' )

finish_command = Command( 'finish', [], finish )
Depends( finish_command, DEFAULT_TARGETS )
Default( finish_command )

这将创建一个依赖于默认的目标是执行一个命令(所以你知道它会永远跑过去 - 看到scons的手动DEFAULT_TARGETS)。希望这有助于。

This creates a command that depends on the default targets for it's execution (so you know it'll always run last - see DEFAULT_TARGETS in scons manual). Hope this helps.

这篇关于我如何运行一些code后每scons的建设?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆