forked from Sorasky4/mros2-wasm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.bash
128 lines (115 loc) · 2.19 KB
/
build.bash
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
if [ $# -gt 2 ] || [ $# -eq 0 ]
then
echo "Usage: $0 {all|up|clean} appname"
exit 1
fi
OPT=${1}
APPNAME=${2}
function clean_subdirectory()
{
rm -rf ${1}/cmake_build
rm -rf ${1}/public
}
if [ ${OPT} == "clean" ];
then
echo "build operation is set to clean"
rm -rf ./cmsis-wasm/Third_Party/FreeRTOS
rm -rf ./lwip-wasm/Third_Party/STM32CubeF7
clean_subdirectory cmsis-wasm
clean_subdirectory lwip-wasm
#clean_subdirectory mros2
rm -rf ../library
rm -rf cmake_build/
echo "build clean is completed"
exit 0
fi
if [ $# -ne 2 ]
then
echo "Usage: $0 {all|up|clean} appname"
exit 1
fi
if [ -d workspace/${APPNAME} ]
then
:
else
echo "ERROR: can not find appname=${APPNAME} on workspace/"
exit 1
fi
if [ -d cmake_build ]
then
:
else
mkdir cmake_build
fi
function download_files()
{
local dir=${1}
cd ${dir}
bash Third_Party/download.bash
cd ..
}
function build_subdirectory()
{
local dir=${1}/cmake_build
if [ -d ${dir} ]
then
:
else
mkdir -p ${dir}
fi
cd ${dir}
if [ $# -eq 1 ]
then
cmake ..
else
cmake .. -D ${2}
fi
make
if [ -d ../public/include ]
then
:
else
make install
fi
cd ../..
}
# generate of header file for template functions of MsgType
function generate_template_functions()
{
MROS2DIR=../mros2
TEMPLATESGEN_FILE=${MROS2DIR}/mros2_header_generator/templates_generator.py
echo "INFO: generate header file for template functions of MsgType"
cd workspace
python3 ${TEMPLATESGEN_FILE} ${APPNAME}
if [ $? -eq 0 ];
then
echo "INFO: header fille for template function of ${APPNAME}'s MsgType is successfully generated"
else
echo "ERROR: failed to generate header fille for template function of ${APPNAME}'s MsgType"
exit 1
fi
cd ..
}
if [ ${OPT} = "all" ]
then
download_files cmsis-wasm
# build_subdirectory cmsis-wasm
download_files lwip-wasm
# build_subdirectory lwip-wasm
generate_template_functions
# build_subdirectory mros2 CMAKE_OS_POSIX=true
cd cmake_build
cmake ../.. -D CMAKE_APPNAME=${APPNAME}
make
cd ..
elif [ ${OPT} = "up" ]
then
cd cmake_build
cmake -v ../.. -D CMAKE_APPNAME=${APPNAME}
make
cd ..
else
echo "ERROR: wrong operation ${OPT}"
exit 1
fi