forked from erkkah/tigr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
596 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.exe | ||
*~ | ||
MLB | ||
libtigr.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
structure CommandLineArgs : | ||
sig | ||
(* each takes a key K and a default value D, looks for -K V in the | ||
* command-line arguments, and returns V if it finds it, or D otherwise. *) | ||
val parseString : string -> string -> string | ||
val parseInt : string -> int -> int | ||
val parseBool : string -> bool -> bool | ||
|
||
(* parseFlag K returns true if --K given on command-line *) | ||
val parseFlag : string -> bool | ||
|
||
val positional : unit -> string list | ||
end = | ||
struct | ||
|
||
fun die msg = | ||
( TextIO.output (TextIO.stdErr, msg ^ "\n") | ||
; TextIO.flushOut TextIO.stdErr | ||
; OS.Process.exit OS.Process.failure | ||
) | ||
|
||
fun positional () = | ||
List.filter (not o String.isPrefix "-") (CommandLine.arguments ()) | ||
|
||
fun search key args = | ||
case args of | ||
[] => NONE | ||
| x :: args' => | ||
if key = x | ||
then SOME args' | ||
else search key args' | ||
|
||
fun parseString key default = | ||
case search ("-" ^ key) (CommandLine.arguments ()) of | ||
NONE => default | ||
| SOME [] => die ("Missing argument of \"-" ^ key ^ "\" ") | ||
| SOME (s :: _) => s | ||
|
||
fun parseInt key default = | ||
case search ("-" ^ key) (CommandLine.arguments ()) of | ||
NONE => default | ||
| SOME [] => die ("Missing argument of \"-" ^ key ^ "\" ") | ||
| SOME (s :: _) => | ||
case Int.fromString s of | ||
NONE => die ("Cannot parse integer from \"-" ^ key ^ " " ^ s ^ "\"") | ||
| SOME x => x | ||
|
||
fun parseBool key default = | ||
case search ("-" ^ key) (CommandLine.arguments ()) of | ||
NONE => default | ||
| SOME [] => die ("Missing argument of \"-" ^ key ^ "\" ") | ||
| SOME ("true" :: _) => true | ||
| SOME ("false" :: _) => false | ||
| SOME (s :: _) => die ("Cannot parse bool from \"-" ^ key ^ " " ^ s ^ "\"") | ||
|
||
fun parseFlag key = | ||
case search ("--" ^ key) (CommandLine.arguments ()) of | ||
NONE => false | ||
| SOME _ => true | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
PROGNAME=ray | ||
MLKIT=mlkit | ||
LIBS= | ||
ifeq ($(OS),Windows_NT) | ||
LDFLAGS += -s -lopengl32 -lgdi32 | ||
else | ||
UNAME_S := $(shell uname -s) | ||
ifeq ($(UNAME_S),Darwin) | ||
LDFLAGS += -arch x86_64 -framework OpenGL -framework Cocoa -L. -ltigr | ||
else ifeq ($(UNAME_S),Linux) | ||
LDFLAGS += -L. | ||
LIBS += -libs 'm,c,dl,GLU,GL,X11,tigr' | ||
endif | ||
endif | ||
|
||
.PHONY: all | ||
all: $(PROGNAME).exe | ||
|
||
$(PROGNAME).exe: $(PROGNAME).mlb $(PROGNAME).sml libtigr.so | ||
MLCOMP=mlkit $(MLKIT) -ldexe '$(CC) $(LDFLAGS)' $(LIBS) -o $@ $< | ||
|
||
libtigr.so: ../../lib/github.com/diku-dk/sml-tigr/clib/libtigr.so | ||
cp $< $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf *~ *.exe MLB libtigr.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local | ||
$(SML_LIB)/basis/basis.mlb | ||
../../lib/github.com/diku-dk/sml-tigr/tigr.mlb | ||
CommandLineArgs.sml | ||
in | ||
ray.sml | ||
end |
Oops, something went wrong.