Created
April 6, 2015 08:34
-
-
Save yuanqing/971a300333e567fb26da to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# File names. | |
SRC_FILE="$1.ml" | |
TEST_FILE="test.ml" | |
EXEC_FILE="test.out" | |
# Exit if no module name specified. | |
[ -z "$1" ] && echo "$0: $src: Need a module name" >&2 && exit 1 | |
# Resolve the $src and $test files. Exit if not found. | |
src="$1"/"$SRC_FILE" | |
[ ! -f "$src" ] && echo "$0: $src: No such file" >&2 && exit 1 | |
test="$1"/"$TEST_FILE" | |
[ ! -f "$test" ] && echo "$0: $test: No such file" >&2 && exit 1 | |
# The OCaml native-code compiler. | |
OO="ocamlfind ocamlopt -g" | |
# Generate the .mli (module interface) of $src. `-i` prints the interface of | |
# $src to `stdout`. | |
mli="$1"/"$1".mli | |
$OO -i "$src" > "$mli" | |
# Compile the .mli to .cmi (compiled module interface). Use `-c` to compile without linking. | |
$OO -c "$mli" | |
# Compile $src to .cmx (compiled object code). Instrument with bisect. Use `-c` to compile without linking. | |
$OO -c -I "$1" -package bisect -syntax camlp4o "$src" | |
# Compile $test to .cmx. Use `-c` to compile without linking. | |
$OO -c -I "$1" -package bisect,oUnit -syntax camlp4o "$test" | |
# Link the $src .cmx and $test .cmx into a.out (executable program). | |
exec="$1"/"$EXEC_FILE" | |
$OO -I "$1" -linkpkg -o "$exec" -package bisect,oUnit "$1"/*.cmx | |
# Run the a.out program. | |
./"$exec" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment