Skip to content

Commit

Permalink
Avoid building runtime/gen/basis-ffi.{h,sml} with clean sources
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MatthewFluet committed Jan 16, 2020
1 parent a8b30a8 commit 76da64c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,23 @@ gen/gen-types$(EXE): util.o
basis-ffi.h: gen/basis-ffi.h
cp $< $@

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)
gen/basis-ffi.h: gen/gen-basis-ffi.sml gen/basis-ffi.def
touch gen/basis-ffi.h
else
gen/basis-ffi.h: gen/gen-basis-ffi$(EXE) gen/basis-ffi.def
./gen/gen-basis-ffi$(EXE) basis-ffi.h < gen/basis-ffi.def > gen/basis-ffi.h
cat gen/gen-basis-ffi.sml gen/basis-ffi.def gen/basis-ffi.h | shasum > gen/basis-ffi.h.chk
endif

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)
gen/basis-ffi.sml: gen/gen-basis-ffi.sml gen/basis-ffi.def
touch gen/basis-ffi.sml
else
gen/basis-ffi.sml: gen/gen-basis-ffi$(EXE) gen/basis-ffi.def
./gen/gen-basis-ffi$(EXE) basis-ffi.sml < gen/basis-ffi.def > gen/basis-ffi.sml
cat gen/gen-basis-ffi.sml gen/basis-ffi.def gen/basis-ffi.sml | shasum > gen/basis-ffi.sml.chk
endif

gen/gen-basis-ffi$(EXE): gen/gen-basis-ffi.sml
$(RUN_MLTON) -output gen/gen-basis-ffi$(EXE) gen/gen-basis-ffi.sml
Expand Down
1 change: 1 addition & 0 deletions runtime/gen/basis-ffi.h.chk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4a233057e4e638a47178eea4fcc111399e9c81a4 -
1 change: 1 addition & 0 deletions runtime/gen/basis-ffi.sml.chk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b17c34fc7d34d4a6b96f29017ba52173b1b1af65 -

0 comments on commit 76da64c

Please sign in to comment.