Skip to content

Commit

Permalink
Use better runtime/Makefile rules for gen/basis-ffi.{h,sml}
Browse files Browse the repository at this point in the history
Avoid using `.stamp` files.
  • Loading branch information
MatthewFluet committed Jan 16, 2020
1 parent ac1651a commit 6a37cc3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
16 changes: 8 additions & 8 deletions runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ gen/gen-types$(EXE): util.o

basis-ffi.h: gen/basis-ffi.h
cp $< $@
gen/basis-ffi.h gen/basis-ffi.sml: gen/gen-basis-ffi.stamp
@touch $@
gen/gen-basis-ffi.stamp: gen/gen-basis-ffi.sml gen/basis-ffi.def
$(RUN_MLTON) -output gen/gen-basis-ffi gen/gen-basis-ffi.sml
rm -f gen/basis-ffi.h gen/basis-ffi.sml gen/gen-basis-ffi.stamp
cd gen && ./gen-basis-ffi
rm -f gen/gen-basis-ffi
touch $@

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
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

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

### libgdtoa ###

Expand Down
3 changes: 0 additions & 3 deletions runtime/basis-ffi.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* This file is automatically generated. Do not edit. */


#ifndef _MLTON_BASIS_FFI_H_

#define _MLTON_BASIS_FFI_H_

PRIVATE extern C_Int_t CommandLine_argc;
PRIVATE extern C_StringArray_t CommandLine_argv;
PRIVATE extern C_String_t CommandLine_commandName;
Expand Down
3 changes: 0 additions & 3 deletions runtime/gen/basis-ffi.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* This file is automatically generated. Do not edit. */


#ifndef _MLTON_BASIS_FFI_H_

#define _MLTON_BASIS_FFI_H_

PRIVATE extern C_Int_t CommandLine_argc;
PRIVATE extern C_StringArray_t CommandLine_argv;
PRIVATE extern C_String_t CommandLine_commandName;
Expand Down
27 changes: 14 additions & 13 deletions runtime/gen/gen-basis-ffi.sml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(* Copyright (C) 2019 Matthew Fluet.
(* Copyright (C) 2019-2020 Matthew Fluet.
* Copyright (C) 2004-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
Expand Down Expand Up @@ -320,7 +320,7 @@ structure Entry =

val entries =
let
val f = TextIO.openIn "basis-ffi.def"
val f = TextIO.stdIn
fun loop entries =
case TextIO.inputLine f of
NONE => List.rev entries
Expand All @@ -341,24 +341,19 @@ val entries =

fun outputC entries =
let
val f = TextIO.openOut "basis-ffi.h"
fun print s = TextIO.output (f, s)
fun println s = if s <> "" then (print s; print "\n") else ()

val () = println "/* This file is automatically generated. Do not edit. */\n\n"
val () = println "#ifndef _MLTON_BASIS_FFI_H_\n"
val () = println "#define _MLTON_BASIS_FFI_H_\n"
val () = println "/* This file is automatically generated. Do not edit. */\n"
val () = println "#ifndef _MLTON_BASIS_FFI_H_"
val () = println "#define _MLTON_BASIS_FFI_H_"
val () = List.app (fn entry => println (Entry.toC entry)) entries
val () = println "#endif /* _MLTON_BASIS_FFI_H_ */"
val () = TextIO.closeOut f
in
()
end

fun outputML entries =
let
val f = TextIO.openOut "basis-ffi.sml"
fun print s = TextIO.output (f, s)
fun println s = if s <> "" then (print s; print "\n") else ()

val primStrs =
Expand Down Expand Up @@ -405,10 +400,16 @@ fun outputML entries =
val () = List.app (fn _ => println "end") cur
val () = println "end"
val () = println "end"
val () = TextIO.closeOut f
in
()
end

val () = outputC entries
val () = outputML entries
val () =
case CommandLine.arguments () of
["basis-ffi.h"] => outputC entries
| ["basis-ffi.sml"] => outputML entries
| _ => (TextIO.output (TextIO.stdErr,
concat ["usage: ",
CommandLine.name (),
" basis-ffi.h|basis-ffi.sml\n"])
; OS.Process.exit OS.Process.failure)
Empty file removed runtime/gen/gen-basis-ffi.stamp
Empty file.

0 comments on commit 6a37cc3

Please sign in to comment.