我如何告诉 SCons 忽略命令操作的隐式依赖关系? [英] How do I tell SCons to ignore implicit dependencies from command actions?

查看:29
本文介绍了我如何告诉 SCons 忽略命令操作的隐式依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,SCons 似乎查看用于构建程序的配方"并从中提取隐式依赖项.例如假设我的 SConstruct 包含:

By default, SCons seems to look at the 'recipe' used to build a program and extracts implicit dependencies from it. For example suppose my SConstruct contains:

Command('foo', 'foocreator.py', '/usr/bin/python foocreator.py > foo')

而且我已经构建了 'foo'('foo' 是最新的).现在我更改了 SConstruct(或者更现实地说,传递不同的选项),以便 'foo' 的命令变为:

And I've already built 'foo' ('foo' is up to date). Now I change SConstruct (or more realistically, pass different options) so that the command for 'foo' becomes:

Command('foo', 'foocreator.py', '/usr/bin/qrsh -V -cwd /usr/bin/python foocreator.py > foo')

(换句话说,通过 SGE 运行 foocreator.py 脚本)现在 SCons 尝试重建 foo,--debug=explain 告诉我这是因为对/usr/bin/qrsh 的新依赖"和对/usr/bin/python 的依赖下降").

(In other words, run the foocreator.py script through SGE) Now SCons tries to rebuild foo, --debug=explain tells me that this is because of a "new dependency on /usr/bin/qrsh" and a "dropped dependency on /usr/bin/python").

我怎样才能防止这种从配方中推断出的依赖关系,最好是全局的?到目前为止,我什至无法找到这种行为的规范.我不想说明foo"并不真正依赖于 python 或 qrsh 的事实,因为我必须为每个目标和这些程序的每个可能位置都这样做.必须有正确"的方式.

How can I prevent this inference of dependencies from the recipe, preferably globally? So far I haven't even been able to find a specification of this behaviour. I don't want to have to spell out the fact that 'foo' doesn't really depend on python or qrsh, because I would have to do that for every target and for every possible location of those programs. There must be a "right" way.

编辑:我现在还尝试为每个目标明确添加忽略,如:

EDIT: I have also now tried explicitly adding Ignores for each target, as in:

Ignore('foo', '/usr/bin/python')
Ignore('foo', '/usr/bin/qrsh')

即使这样也行不通!每当我在运行 qrsh 和不运行之间切换时,SCons 仍然希望重建所有内容.

and even this doesn't work! SCons still wants to rebuild everything whenever I switch between running through qrsh and not.

推荐答案

我找到了文档化的解决方案:有一个构造变量 IMPLICIT_COMMAND_DEPENDENCIES 可以精确控制这种行为.它记录在 http://www.scons.org/doc/HTML/scons-man.html(但我是通过搜索 scons 源代码发现的!)

I found the documented solution: there is a construction variable IMPLICIT_COMMAND_DEPENDENCIES which controls exactly this behaviour. It is documented on http://www.scons.org/doc/HTML/scons-man.html (but I discovered it by searching through the scons source code!)

因此,根据我的原始示例,这给出了我想要的行为.

So this gives the behaviour I want based on my original example.

env = Environment(IMPLICIT_COMMAND_DEPENDENCIES =0, ... )
Command('foo', 'foocreator.py', '/usr/bin/python foocreator.py > foo')

(或)

env = Environment(IMPLICIT_COMMAND_DEPENDENCIES =0, ... )
Command('foo', 'foocreator.py', '/usr/bin/python foocreator.py > foo')

我可以在目标 'foo' 的两个定义之间切换,scons 不会认为 foo 已过时.

I can switch between the two definitions for target 'foo' and scons will not think foo is out of date.

这篇关于我如何告诉 SCons 忽略命令操作的隐式依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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