问题
First, I've got SConstruct file like this:
Object('a.s')
Program('mya','a.o')
I run scons, it generates 'mya'. OK. Then I change my SConstruct to be:
Object('a.s',CCFLAGS='-DHello')
Program('mya','a.o')
Run scons again. Nothing is done:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
This is quite weird to me. When I used make or msbuild systems, whenever there's argumenet change in project configuration file, there'll be a rebuild. This is a default rule.
But seems scons's rule is different, is this by design? Only when source file change will trigger rebuild? If this is the design, I think there's a flaw that when compilation/linker option changes, target file should be different and thus, should trigger rebuild, right?
Is my understanding incorrect, or there's some special points in scons that I still need to know about? Thanks a lot.
回答1:
Refering directly to your last paragraph, and based on your last three questions (Using 'LIBS' in scons 'Program' command failed to find static library, why? and When changing the comment of a .c file, scons still re-compile it? and this one) and the depth of them, yes there seem to be a lot of things that you don't know about SCons.
So please take the next steps in reading its 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).
When you are calling a "scons -c
" followed by a "scons
" you should see that the "-DHello
" doesn't appear in the command-line, even though "a.o
" gets rebuilt. The variable $CCFLAGS
isn't used to compile assembler files, but $ASFLAGS
is...and when setting it instead, you should indeed see a rebuild immediately, without editing the source file.
来源:https://stackoverflow.com/questions/39831937/when-i-change-sconstruct-file-scons-doesnt-trigger-rebuild