-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompile_swamp.sh
executable file
·44 lines (32 loc) · 1.18 KB
/
compile_swamp.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
#!/bin/sh
# Regression testing script for Swamp
# Step through a list of files
# Compile, run, and check the output of each expected-to-work test
# Compile and check the error of each expected-to-fail test
# Path to the LLVM interpreter
LLI="lli"
(which "$LLI" > /dev/null) || LLI="/usr/local/opt/llvm@14/bin/lli"
(which "$LLI" > /dev/null) || LLI="/opt/homebrew/opt/llvm/bin/lli"
(which "$LLI" > /dev/null) || LLI="/opt/homebrew/Cellar/llvm@14/14.0.6/bin/lli"
# Path to the LLVM compiler
LLC="llc"
(which "$LLC" > /dev/null) || LLC="/usr/local/opt/llvm@14/bin/llc"
(which "$LLC" > /dev/null) || LLC="/opt/homebrew/opt/llvm/bin/llc"
(which "$LLC" > /dev/null) || LLC="/opt/homebrew/Cellar/llvm@14/14.0.6/bin/llc"
# Path to the C compiler
CC="cc"
# Path to the swamp compiler.
SWAMP="./swamp"
CFUNCS="./irgen.o"
# Set time limit for all operations
ulimit -t 30
basename=`echo $1 | sed 's/.*\\///
s/.swamp//'`
echo -n "Compiling $basename..."
eval "$SWAMP" "-l $1" ">" "${basename}.ll" &&
eval "$LLC" "-relocation-model=pic" "${basename}.ll" ">" "${basename}.s" &&
eval "$CC" "-o" "${basename}.exe" "${basename}.s" "$CFUNCS"
rm -f ${basename}.ll;
rm -f ${basename}.s;
printf "Done\n"
exit 0