当我更改 SConstruct 文件时,scons 不会触发重建?

When I change SConstruct file, scons doesn't trigger rebuild?

首先,我有这样的 SConstruct 文件:

Object('a.s')
Program('mya','a.o')

我运行 scons,它生成'mya'。好的。然后我将我的 SConstruct 更改为:

Object('a.s',CCFLAGS='-DHello')
Program('mya','a.o')

运行 再来一次。什么都没做:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

这对我来说很奇怪。当我使用 make 或 msbuild 系统时,只要项目配置文件中有 argumenet 更改,就会进行重建。这是默认规则。

不过好像scons的规则不一样,这是设计的吗?只有当源文件更改时才会触发重建?如果这是设计,我认为存在一个缺陷,即当 compilation/linker 选项更改时,目标文件应该不同,因此应该触发重建,对吗?

是我的理解有误,还是scons有一些特殊的地方需要了解? 非常感谢。

直接参考你的最后一段,根据你的最后三个问题( and 和这个)和它们的深度,是的,似乎有很多事情你不知道关于 SCons.

所以请阅读它的后续步骤 MAN page and the UserGuide. You might also want to step your tone down a bit and instead of questioning its design or claiming that there seems to be a "flaw" doing your homework (see also How To Ask Questions The Smart Way)。

当您调用“scons -c”后跟“scons”时,您应该会看到“-DHello”没有出现在命令行中,即使尽管“a.o”得到了重建。变量 $CCFLAGS 不用于编译汇编程序文件,但 $ASFLAGS 是...并且当设置它时,您确实应该立即看到重建,而无需编辑源文件。