-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.sh
executable file
·53 lines (42 loc) · 998 Bytes
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Path to the LLVM compiler
LLC=llc
CC="cc"
FLAG="-relocation-model=pic"
LLC_WITH_FLAG="$LLC $FLAG"
make_dir() {
if [ ! -d $1 ]
then
echo -e "\nCreating dir:\n" $1
mkdir $1
fi
}
BASE_DIR="tests"
GRAPHITE="./toplevel.native"
eval $(opam env)
make toplevel.native
# $1 FILENAME
# $2 OUTPUT_FILE_DIR
# $3 GOLD_STANDARD_DIR
diff() {
PARENT_DIR=${2%%.*}
if cmp $2 $3;
then echo $1 "PASSED"
else echo $1 "FAILED"
fi
}
COMPILE_DIR="$BASE_DIR/compile"
make_dir $COMPILE_DIR
INTERMED_DIR="$COMPILE_DIR/intermediary_files"
make_dir $INTERMED_DIR
if [ ! -f $1 ];
then
echo "$1 is must be a file."
else
FILE_WITH_EXT=$(basename $1)
FILENAME=${FILE_WITH_EXT%%.*}
$GRAPHITE < $1 > $INTERMED_DIR/$FILENAME.ll
# Runs the LLVM interpreter with the previously generated LLVM code
$LLC_WITH_FLAG < $INTERMED_DIR/$FILENAME.ll > $INTERMED_DIR/$FILENAME.s
cc -o $COMPILE_DIR/$FILENAME.exe $INTERMED_DIR/$FILENAME.s
fi