当更改.c文件的注释时,scons仍然重新编译它? [英] When changing the comment of a .c file, scons still re-compile it?

查看:813
本文介绍了当更改.c文件的注释时,scons仍然重新编译它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,scons使用MD5签名作为默认决策器来改变源文件是否需要重新编译。例如。我有SConstruct如下:

 库('o.c')

我的oc是:

  $ cat oc 
/ * commented * /
#include< stdio.h>
int f(){
printf(hello\\\
);
return 2;
}

运行scons并删除注释行,再次运行scons。我希望这个scons不应该再编译,但实际上它是:

  gcc -o oo -c oc 
scons :完成建筑目标。

如果我将SConstruct文件更改为添加一行:

 决定('MD5')。 

仍然相同的结果。



我的问题是:如何确保对于scons,更改源文件评论时,他们不会重新构建?



谢谢!


正如你所说的那样,SCons使用源文件的MD5 hashsum来决定是否改变(基于内容),并重新构建目标似乎是必需的(因为它的一个依赖关系改变了)。
通过添加或更改注释,文件的MD5总和将更改...因此触发器触发。



如果您不喜欢此行为,你可以写和使用你自己的Decider功能,这将省略你的喜好的评论变化。请参阅 UserGuide 中的第6.1.4节编写自己的自定义决定功能 a>看看如何做到这一点。


It's said that scons uses MD5 signature as default decider to dertermine whether a source file needs re-compilation. E.g. I've got SConstruct as below:

Library('o.c')

And my o.c is:

$ cat o.c
    /*commented*/
    #include<stdio.h>
    int f(){
      printf("hello\n");
      return 2;
    }

Run scons and remove the comment line, run scons again. I expect that scons should not compile it again, but actually it's:

gcc -o o.o -c o.c
scons: done building targets.

If I change SConstruct file to add one line:

Decider('MD5').

Still same result.

My question is: how to make sure that for scons, when changing source file comments, they don't get re-built?

Thanks!

解决方案

As you correctly stated, SCons uses the MD5 hashsum of a source file to decide whether it has changed or not (content-based), and a rebuild of the target seems to be required (since one of its dependencies changed). By adding or changing a comment, the MD5 sum of the file changes...so the trigger fires.

If you don't like this behaviour, you can write and use your own Decider function which will omit comment changes to your likings. Please check section 6.1.4 "Writing Your Own Custom Decider Function" in the UserGuide to see how this can be done.

这篇关于当更改.c文件的注释时,scons仍然重新编译它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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