-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcake_compiler2
More file actions
executable file
·57 lines (41 loc) · 952 Bytes
/
cake_compiler2
File metadata and controls
executable file
·57 lines (41 loc) · 952 Bytes
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
54
55
56
57
#!/bin/bash
#!/bin/bash
OUTPUT=""
while getopts "h:c:o:" opt; do
case "$opt" in
h) echo "this doesn't work";exit 0;;
c) DIR="$OPTARG" ;;
o) OUTPUT="$OPTARG" ;;
*) echo "Invalid option: -$OPTARG" >&2; exit 1 ;;
esac
done
shift $((OPTIND - 1))
if [ $# -eq 0 ]; then
echo "Error: No source file specified."
exit 1
elif [ $# -gt 1 ]; then
echo "Error: Only one source file name allowed."
exit 1
fi
SOURCE=$1
SOURCE_NAME=$(basename "$SOURCE" ".cml")
CAKEASM="$SOURCE_NAME.S"
if [ -z "$OUTPUT" ]; then
OUTPUT="$SOURCE_NAME.cake"
fi
# Get utility files needed
if [ -z "$DIR" ]; then
DIR=$(dirname "$(realpath "$0")")
fi
BASIS_FFI="$DIR/basis_ffi.c"
CAKE="$DIR/cake"
CAKEFLAG=""
CFLAGS="-O2"
LDLIBS="-lm"
$CAKE $CAKEFLAGS < $SOURCE > $CAKEASM &&
echo "compiled" &&
mkdir -p $OUTPUT &&
rmdir $OUTPUT &&
cc $CAKEASM $BASIS_FFI -DEVAL -o $OUTPUT -lm &&
echo "linking" &&
rm $CAKEASM