-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_collinion
executable file
·38 lines (31 loc) · 965 Bytes
/
run_collinion
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
#!/usr/bin/bash
USAGE_MSG="Usage: $0 <your_algo_file> [ map_file ]"
if [[ -z $1 ]] ; then
echo ${USAGE_MSG}
exit 0
fi
ALGO_FILE="$PWD/$1"
MAP_FILE="$PWD/$2"
MAIN_FOLDER=$(find $HOME -name Collinion 2>/dev/null)
PROGRAM_FOLDER="$MAIN_FOLDER/program"
FORMATED_ALGO="$PROGRAM_FOLDER/src/ALGO.c"
CELL_TYPE_FILE="$PROGRAM_FOLDER/include/cell_types.h"
if [[ -f ${ALGO_FILE} ]] ; then
# format the line starting by DECLARE_TYPE
# and put it in the include/cell_types.h
grep 'DECLARE_TYPE' ${ALGO_FILE} | cut -d: -f2-100 | sed "s/;/,/" | awk 'BEGIN {print "#include <collinion.h>\nenum cell_types {"} {print "\t",$0} END { print "NB_TYPES };" }' > ${CELL_TYPE_FILE}
# Format the file and save it in src/ALGO.c
sed 's/.*DECLARE_TYPE.*//' ${ALGO_FILE} > ${FORMATED_ALGO}
else
echo ${USAGE_MSG}
exit 1
fi
make -C ${PROGRAM_FOLDER} algo
mv ${PROGRAM_FOLDER}/collinion .
if [[ -n $2 && -f $2 ]] ; then
./collinion $2
else
./collinion
fi
rm collinion
exit 0