[英]GNU make: How to modify a file without re-executing rules?
Suppose I want to make an extremely minor (ie commenting, whitespace cleanup, etc) change to a file but I don't want Make to go through the time-consuming (>24hrs) rebuild process. 假设我想对文件做一个非常小的(即评论,空格清理等)更改但我不希望Make经历耗时(> 24小时)的重建过程。 Is there a way to do this?
有没有办法做到这一点?
I know you can do the opposite (ie rebuild without editing a file) using "touch", but that doesn't really help here. 我知道你可以使用“触摸”来做相反的事情(即重建而不编辑文件),但这并没有真正帮助。
You can also do the opposite with touch
as well. 你也可以用
touch
来做相反的事情。 One way I do it that's pretty easy is: 我这样做的一种方式很简单:
$ cp -a foo.c foo.c.bak
$ <fix up foo.c>
$ touch foo.c -r foo.c.bak
Since cp -a
should preserve the modification timestamp. 因为
cp -a
应该保留修改时间戳。 Another way something similar can be done is to note the modification timestamp (eg stat -c "%y" foo.c
or something like that) and use the -m
and -t
arguments to touch
instead of copying the file. 类似的另一种方法是注意修改时间戳(例如
stat -c "%y" foo.c
或类似的东西)并使用-m
和-t
参数来touch
而不是复制文件。
After editing the file, you can change the "modification time" to whatever you want with 编辑文件后,您可以将“修改时间”更改为您想要的任何内容
touch -m -r filename
Where filename
is the name of a file with the time you want to copy (another untouched file from the build). 其中
filename
是具有您要复制时间的文件的名称(来自构建的另一个未触摸的文件)。 See http://www.computerhope.com/unix/utouch.htm 见http://www.computerhope.com/unix/utouch.htm
touch is still the answer you just need to use it backwards. 触摸仍然是您只需要向后使用它的答案。
-p
). -p
)。 That should be enough to do what you want. 这应该足以做你想要的。
And remember you can always ask make -q
to see whether it thinks it will have any work to do to make sure you got it right. 并且记得你总是可以让make
-q
看看它是否认为它有任何工作要做,以确保你做对了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.