Skip to content

Commit 76da64c

Browse files
committed
Avoid building runtime/gen/basis-ffi.{h,sml} with clean sources
6a466d9 was a previous attempt to avoid building `runtime/gen/basis-ffi.{h,sml}` when building from clean sources. This avoids the need for a working `mlton` when building the runtime, which is convenient for cross-compiling and porting. It typically worked, because a fresh `git clone` or `tar x` would create the `runtime/gen/basis-ffi.{h,sml}` and `runtime/gen/gen-basis-ffi.{sml,stamp}` files with sufficiently close timestamps that `make` wouldn't consider anything to be out of date. However, this is not guaranteed. This commit removes `runtime/gen/gen-basis-ffi.stamp` and adds `runtime/gen/basis-ffi.{h,sml}.chk` files, which are SHA checksums of the inputs and outputs of `runtime/gen/basis-ffi.{h,sml}`. If the checksum of the current sources matches the saved checksum, then the targets can be brought up to date with a simple `touch`. If an input has changed, then the targets (and the checksum) are updated by building and running the `runtime/gen/gen-basis-ffi` tool.
1 parent a8b30a8 commit 76da64c

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

runtime/Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,23 @@ gen/gen-types$(EXE): util.o
160160
basis-ffi.h: gen/basis-ffi.h
161161
cp $< $@
162162

163+
ifeq ($(shell cat gen/gen-basis-ffi.sml gen/basis-ffi.def gen/basis-ffi.h | shasum -c -s gen/basis-ffi.h.chk && echo true),true)
164+
gen/basis-ffi.h: gen/gen-basis-ffi.sml gen/basis-ffi.def
165+
touch gen/basis-ffi.h
166+
else
163167
gen/basis-ffi.h: gen/gen-basis-ffi$(EXE) gen/basis-ffi.def
164168
./gen/gen-basis-ffi$(EXE) basis-ffi.h < gen/basis-ffi.def > gen/basis-ffi.h
169+
cat gen/gen-basis-ffi.sml gen/basis-ffi.def gen/basis-ffi.h | shasum > gen/basis-ffi.h.chk
170+
endif
171+
172+
ifeq ($(shell cat gen/gen-basis-ffi.sml gen/basis-ffi.def gen/basis-ffi.sml | shasum -c -s gen/basis-ffi.sml.chk && echo true),true)
173+
gen/basis-ffi.sml: gen/gen-basis-ffi.sml gen/basis-ffi.def
174+
touch gen/basis-ffi.sml
175+
else
165176
gen/basis-ffi.sml: gen/gen-basis-ffi$(EXE) gen/basis-ffi.def
166177
./gen/gen-basis-ffi$(EXE) basis-ffi.sml < gen/basis-ffi.def > gen/basis-ffi.sml
178+
cat gen/gen-basis-ffi.sml gen/basis-ffi.def gen/basis-ffi.sml | shasum > gen/basis-ffi.sml.chk
179+
endif
167180

168181
gen/gen-basis-ffi$(EXE): gen/gen-basis-ffi.sml
169182
$(RUN_MLTON) -output gen/gen-basis-ffi$(EXE) gen/gen-basis-ffi.sml

runtime/gen/basis-ffi.h.chk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4a233057e4e638a47178eea4fcc111399e9c81a4 -

runtime/gen/basis-ffi.sml.chk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b17c34fc7d34d4a6b96f29017ba52173b1b1af65 -

0 commit comments

Comments
 (0)