English 中文(简体)
在 Makefile 中禁止未来时间的“ cock skew” 警告
原标题:Suppress "Clock skew" warning for future-times in Makefile

我有一个 Make 文件, 如果它没有在最后一小时发生, 就可以执行任务。 它是这样做的:


HOUR_FROM_NOW = $(shell perl -e  ($$s,$$m,$$h,$$d,$$M)=localtime(time()+3600); printf("%02d%02d%02d%02d
",$$M+1,$$d,$$h,$$m); )
NOW_FILE      = $(shell mkdir -p .make; touch .make/now; echo .make/now )

.PHONY: externals
externals: $(PROJECTS:%=.make/proj_%)
.make/proj_%: $(NOW_FILE)
     $(MAKE) -s $(*F)
     touch -t $(HOUR_FROM_NOW) $@

.PHONY: $(PROJECTS)
$(PROJECTS): 
     # do stuff, specifically, clone git-repo if not exists, else pull latest

那部分的功过功过功,我只得听到警告:

make: Warning: File `.make/proj  has modification time 3.5e+03 s in the future
make: Nothing to be done for `externals .
make: warning:  Clock skew detected.  Your build may be incomplete.

有人知道如何制止这些警告吗?

最佳回答

我所碰到的大多数触摸版本都可以做一些约会时间数学, 从而可以通过 < code>- date 选项直接设定文件的时间戳 。

并且指定给 :\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\可以\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

HOUR_AGO := .make/hour_ago
__UGLY := $(shell mkdir -p .make && touch --date= 1hour ago  $(HOUR_AGO))
# The preceding line will be executed once

.make/proj_%: .make/hour_ago | .make
    $(MAKE) -s $(*F)
    @touch $@

.make:
    mkdir -p $@

我使用非常相似的东西 定期刷新登录标记。

如果不是因为戴夫的回答 就不会想到它了


创建该目录的方法是指定该目录为",http://www.gnu.org/ software/ make/manual/make.html#prerequisite-Types" rel=“nofollown noreferrer” >单序-prequisite

问题回答

我怀疑+3600是错的 如果你删除它会怎么样?

我想和想, 然后愚蠢的 显而易见的解决方案打我...

我使用实时时间, 与小时比较, 而不是设置未来 HOUR_ FROM_ NOW的时间戳...

HOUR_AGO      = $(shell perl -e  ($$s,$$m,$$h,$$d,$$M)=localtime(time()-3600); printf("%02d%02d%02d%02d
",$$M+1,$$d,$$h,$$m); )
HOUR_AGO_FILE      = $(shell mkdir -p .make; touch -t $(HOUR_AGO) .make/hour_ago; echo .make/hour_ago )

.PHONY: externals
externals: $(PROJECTS:%=.make/proj_%)
.make/proj_%: $(HOUR_AGO_FILE)
     $(MAKE) -s $(*F)
     @touch $@




相关问题
How to store only time; not date and time?

In one field I need to store not a datetime pair, i.e. a standard Oracle date. 01/10/2009 22:10:39 But time only 22:10:39 I think that save disk space (I have 2 million rows) or provide faster ...

Auto Fill the Time in infopath

I would like to know if there is a way that I can have the time be auto filled when the user enters 10 I then want it to show 10:00. how can I do this?

Regex for timestamps in php

I m trying to take timestamps in this format: 2009-11-16T14:05:22-08:00 and make turn them into something like 2009-11-16 How do I remove everything after the "T"?

Segmentation fault on time(0);

I m rewriting an old program to do some new stuff, and suddenly I get a segmentation fault error on the following line of code: time_t seconds_since_time_begun = time(0); Why, oh why? Update: I ...

Run a PHP script every second using CLI

I have a dedicated server running Cent OS with a Parallel PLESK panel. I need to run a PHP script every second to update my database. These is no alternative way time-wise, it needs to be updated ...