【发布时间】:2015-01-09 23:24:25
【问题描述】:
我正在迁移构建一个相当大的系统以使用 SCons。我想添加自定义构建报告功能,以更新有关构建状态的网站。它将向服务器发布一条自定义消息,指示作业的开始,并在作业完成后发布类似的消息。但我正在努力寻找合适的地方来拨打这些电话。
我实现的构建系统应该是通用的,即无论构建操作是什么,它都应该这样做。它可能正在执行命令或运行自定义函数。
在源代码中,我发现在 _ActionAction() 的 _ _call__ 方法中添加自定义函数会起作用。但是我想在不修改 SCons 的源代码的情况下做到这一点。
if execute:
if chdir:
os.chdir(chdir)
try:
# add custome before execution report function
stat = self.execute(target, source, env, executor=executor)
# add custome after execution report function
if isinstance(stat, SCons.Errors.BuildError):
s = exitstatfunc(stat.status)
if s:
stat.status = s
else:
stat = s
else:
stat = exitstatfunc(stat)
finally:
if save_cwd:
os.chdir(save_cwd)
我大概可以在 PRINT_CMD_LINE_FUNC 中做预编译动作报告,但我没有找到任何类似的编译后动作报告。
AddPreAction 和 AddAfterAction 也可以做我想做的事,但是为了让我为所有操作添加报告功能,我需要知道操作对象是什么,然后才能调用 add pre-action 和 after -他们每个人的行动。
感谢您的帮助!
【问题讨论】:
标签: scons