-
Notifications
You must be signed in to change notification settings - Fork 143
/
build.sh
executable file
·88 lines (74 loc) · 2.32 KB
/
build.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
set -e
ESDK=${EPIPHANY_HOME}
ELIBS=${ESDK}/tools/host/lib
EINCS=${ESDK}/tools/host/include
ELDF="src/matmul_internal.ldf"
PARAM=$1
if [ $# -lt 1 ]
then
PARAM="s"
fi
echo -e "Mode: "$PARAM"\n"
if [ "$PARAM" = "s" ]
then
LIB_SRC_NAME="matmul_assembly"
LIB_SRC_EXTN=".S"
fi
LIB_SRC_FILE="${LIB_SRC_NAME}${LIB_SRC_EXTN}"
LIB_OBJ_FILE="${LIB_SRC_NAME}.o"
OPT_FLAG="-O3 -std=c99 -mlong-calls -mfp-mode=round-nearest -ffp-contract=fast -ffast-math -funroll-loops"
if [ "${LIB_SRC_EXTN}" = ".S" ]
then
ASM_FLAG="-DASM"
fi
echo -e "\nBuild HOST side application"
COMMAND="gcc ${DEFINE_FLAG} src/host_main.c -o Debug/host_main.elf -I ${EINCS} -L ${ELIBS} -le-hal -le-loader"
echo ${COMMAND}
eval ${COMMAND}
echo -e "\nBuild DEVICE side program"
COMMAND="e-gcc -c ${DEFINE_FLAG} src/e_dev_main.c -o Debug/e_dev_main.o -le-lib"
echo ${COMMAND}
eval ${COMMAND}
echo -e "\nBuilding device side libraries"
COMMAND="e-gcc -c -Wall ${ASM_FLAG} ${OPT_FLAG} -o Debug/matmul_main.o src/matmul_main.c -le-lib"
echo ${COMMAND}
eval ${COMMAND}
if [ "${LIB_SRC_EXTN}" = ".c" ]
then
COMMAND="e-gcc -c -Wall ${OPT_FLAG} -o Debug/${LIB_OBJ_FILE} src/${LIB_SRC_FILE} -le-lib"
else
COMMAND="e-gcc -c src/${LIB_SRC_FILE} -o Debug/${LIB_OBJ_FILE}"
fi
echo ${COMMAND}
eval ${COMMAND}
echo -e "\nLinking"
COMMAND="e-gcc -T ${ELDF} Debug/e_dev_main.o Debug/matmul_main.o Debug/${LIB_OBJ_FILE} -o Debug/e_dev_main.elf -le-lib"
echo ${COMMAND}
eval ${COMMAND}
echo -e "\nBuild complete\n"
#echo -e "\nGenerating assembly...."
#if [ "${LIB_SRC_EXTN}" = ".c" ]
#then
# COMMAND="e-gcc -S -fverbose-asm -g ${OPT_FLAG} src/${LIB_SRC_FILE} -o Assembly/${LIB_SRC_NAME}.s -le-lib"
# echo ${COMMAND}
# eval ${COMMAND}
#
# COMMAND="e-as -alhnd Assembly/${LIB_SRC_NAME}.s > Assembly/${LIB_SRC_NAME}_as.s"
# echo ${COMMAND}
# eval ${COMMAND}
#
# rm a.out
#fi
#COMMAND="e-objdump -d -S Debug/matmul_op.o > Assembly/matmul_op_objdump.s"
#COMMAND="e-objdump -d -S Debug/${LIB_OBJ_FILE} > Assembly/${LIB_SRC_NAME}_objdump.s"
#echo ${COMMAND}
#eval ${COMMAND}
#
#COMMAND="e-objdump -d -S Debug/matmul_main.o > Assembly/matmul_main_objdump.s"
#echo ${COMMAND}
#eval ${COMMAND}
#echo -e "\n\nExecuting program"
#COMMAND="./run.sh"
#echo ${COMMAND}
#eval ${COMMAND}