[英]Makefile: assume file is up to date for a specific target?
I'm using GNU Make to build graphs for a paper.我正在使用 GNU Make 为论文构建图表。 I have two targets:
我有两个目标:
data
which rebuilds the data/*.csv folder. data
以重新生成数据/ *。CSV文件夹。 This is very computationally expensive.plot
which rebuilds the plots from the data/ folder plot
从数据/文件夹重建图Now, because of how expensive data
is to compute, I committed the resulting files in git.现在,由于计算
data
成本很高,我将生成的文件提交到 git 中。 I'd like to avoid changing them whenever possible.我想尽可能避免更改它们。 But when someone clones the git repository, it messes the mtime of the files, so
make plot
wants to rebuild data
, even though they're already there.但是当有人克隆 git 存储库时,它会弄乱文件的 mtime,所以
make plot
想要重建data
,即使它们已经存在。
That said, I don't want to remove the target dependency!也就是说,我不想删除目标依赖项! If, for some reason, I recompute something in
data
, I want the plots to see that and to be able to rebuild themselves.如果出于某种原因,我重新计算了
data
某些内容,我希望这些图能够看到并能够自行重建。 Also, if one csv is missing, I want it to be computed.另外,如果缺少一个 csv,我希望它被计算出来。
I think ideally, what I want is to have a way to say "if these files are present, assume that they are up to date".我认为理想情况下,我想要的是有一种方法可以说“如果这些文件存在,则假设它们是最新的”。 Is there a way to do that in GNU Make?
有没有办法在 GNU Make 中做到这一点?
Thanks to the comment of Renaud Pacalet, I used order-only dependencies to rewrite my rule like this:感谢 Renaud Pacalet 的评论,我使用了order-only 依赖来重写我的规则,如下所示:
data/%.csv: | source/%.py
...
Using this |
使用这个
|
allows make
to never rebuild a CSV file already present.允许
make
永远不会重建已经存在的 CSV 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.