@@ -130,16 +130,35 @@ EXTRACT := --extract '* $(EXTRACT_NS)'
130130# file in the cwd named like a file in ulib/, F* may prefer the former.
131131ROOTS := $(shell find $(SRC ) -name '* .fst' -o -name '* .fsti')
132132
133- $(CACHE_DIR ) /.depend$(TAG ) :
133+ DEPSTEM := $(CACHE_DIR ) /.depend$(TAG )
134+ # We always run this to compute a full list of fst/fsti files in the
135+ # $(SRC) (ignoring the roots, it's a bit conservative). The list is
136+ # saved in $(DEPSTEM).touch.chk, and compared to the one we generated
137+ # before in $(DEPSTEM).touch. If there's a change (or the 'previous')
138+ # does not exist, the timestamp of $(DEPSTEM0.touch will be updated
139+ # triggering an actual dependency run.
140+ .PHONY : .force
141+ $(DEPSTEM ) .touch : .force
142+ mkdir -p $(dir $@ )
143+ find $(SRC ) -name ' *.fst*' > $@ .chk
144+ diff -q $@ $@ .chk 2> /dev/null || cp $@ .chk $@
145+
146+ $(DEPSTEM ) : $(DEPSTEM ) .touch
134147 $(call msg, "DEPEND", $(SRC ) )
135148 $(FSTAR ) --dep full $(ROOTS ) $(EXTRACT ) $(DEPFLAGS ) --output_deps_to $@
136- mkdir -p $(CACHE_DIR )
137149
138- depend : $(CACHE_DIR ) /.depend $( TAG )
139- include $(CACHE_DIR ) /.depend $( TAG )
150+ depend : $(DEPSTEM )
151+ include $(DEPSTEM )
140152
141153all-checked : $(ALL_CHECKED_FILES )
142154# These targets imply verification of every file too, regardless
143155# of extraction.
144156all-ml : all-checked $(ALL_ML_FILES )
157+ @# Remove extraneous .ml files, which can linger after
158+ @# module renamings. The realpath is necessary to prevent
159+ @# discrepancies between absolute and relative paths, double
160+ @# slashes, etc.
161+ rm -vf $(filter-out $(realpath $(ALL_ML_FILES ) ) , $(realpath $(wildcard $(OUTPUT_DIR ) /* .ml) ) )
162+
145163all-fs : all-checked $(ALL_FS_FILES )
164+ rm -vf $(filter-out $(realpath $(ALL_FS_FILES ) ) , $(realpath $(wildcard $(OUTPUT_DIR ) /* .fs) ) )
0 commit comments