This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·167 lines (152 loc) · 4.89 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash -eu
RTEMS_ARCH="i386"
RTEMS_BSP="pc386"
ROOT_DIR="$(dirname $(realpath ${BASH_SOURCE[0]}))"
CI_DIR="${ROOT_DIR}/ci"
RTEMS_DIR="${ROOT_DIR}/rtems_rtos"
RTEMS_VERSION="5.1"
OUT_EXE_NAME="rtems-ec-cli.exe"
FLAG_BUILD_ALL=0
FLAG_CLEAR_ALL=0
FLAG_REBUILD_APP=0
FLAG_BUILD_RTEMS=0
FLAG_BUILD_CROSS=0
function build_cross_compiler
{
rm -Rf ${RTEMS_DIR}/rtems-exe
echo "#########################################################"
echo " Build cross-compiler ..."
echo "#########################################################"
cd ${RTEMS_DIR}/rtems-source-builder
source-builder/sb-check
cd rtems
../source-builder/sb-set-builder \
--log=log-${RTEMS_ARCH}.txt \
--prefix=${RTEMS_DIR}/rtems-exe \
5/rtems-${RTEMS_ARCH}.bset
export PATH=${RTEMS_DIR}/rtems-exe/bin:$PATH
export PATH=${RTEMS_DIR}/rtems-exe/${RTEMS_ARCH}-rtems5/bin:$PATH
${RTEMS_DIR}/rtems-exe/bin/${RTEMS_ARCH}-rtems5-gcc -v
}
function build_rtems_os
{
rtems_os_version_lable=$(bash ${CI_DIR}/ci-generate-version.sh rtems --arch ${RTEMS_ARCH} --bsp ${RTEMS_BSP})
echo "version: $rtems_os_version_lable"
rm -Rf ${RTEMS_DIR}/tmp ${RTEMS_DIR}/build-*
export PATH=${RTEMS_DIR}/rtems-exe/bin:$PATH
export PATH=${RTEMS_DIR}/rtems-exe/${RTEMS_ARCH}-rtems5/bin:$PATH
echo "#########################################################"
echo " Build RTEMS OS ..."
echo "#########################################################"
cd ${RTEMS_DIR}/rtems
export LC_ALL="en_US.UTF-8"
./bootstrap -c
./bootstrap -H && ${RTEMS_DIR}/rtems-source-builder/source-builder/sb-bootstrap
mkdir -p ${RTEMS_DIR}/tmp; cd ${RTEMS_DIR}/tmp
${RTEMS_DIR}/rtems/rtems-bsps
${RTEMS_DIR}/rtems/configure --target=${RTEMS_ARCH}-rtems5 \
--prefix=${RTEMS_DIR}/build-$rtems_os_version_lable \
--disable-multiprocessing \
--disable-cxx \
--disable-rdbg \
--enable-maintainer-mode \
--enable-tests \
--enable-networking \
--enable-posix \
--disable-itron \
--disable-deprecated \
--disable-ada \
--disable-expada \
--enable-rtemsbsp=${RTEMS_BSP} \
USE_COM1_AS_CONSOLE=1 \
BSP_PRESS_KEY_FOR_RESET=0
make all
make install
rm -Rf ${RTEMS_DIR}/tmp
}
function build_application
{
cd ${ROOT_DIR}
project_version_lable=$(bash ${CI_DIR}/ci-generate-version.sh --arch ${RTEMS_ARCH} --bsp ${RTEMS_BSP})
rtems_os_version_lable=$(bash ${CI_DIR}/ci-generate-version.sh rtems --arch ${RTEMS_ARCH} --bsp ${RTEMS_BSP})
${ROOT_DIR}/waf --project-version=$project_version_lable \
configure --rtems=${RTEMS_DIR}/build-$rtems_os_version_lable \
--rtems-tools=${RTEMS_DIR}/rtems-exe \
--rtems-bsps=${RTEMS_ARCH}/${RTEMS_BSP}
${ROOT_DIR}/waf --version
${ROOT_DIR}/waf -vvv
cp ${ROOT_DIR}/build/${RTEMS_ARCH}-rtems5-${RTEMS_BSP}/${OUT_EXE_NAME} \
${ROOT_DIR}/${OUT_EXE_NAME}
tar -C ${ROOT_DIR} -zcvf ${ROOT_DIR}/${project_version_lable}.tar.gz ${OUT_EXE_NAME}
}
function print_help
{
echo "Use $0 [COMMANDS...]"
echo " all Build all: cross-compiler, RTEMS OS and ile-cli application"
echo " rtems Build RTEMS OS"
echo " cross Build cross-compiler"
echo " cleanall Clear all"
echo " rebuild Set rebuils flag"
echo " Delete the application's object files before building it"
echo " help Print help"
}
while [ "${1:-}" != "" ]; do
case "$1" in
"all")
FLAG_BUILD_ALL=1
break
;;
"rtems")
FLAG_BUILD_RTEMS=1
break
;;
"cross")
FLAG_BUILD_CROSS=1
break
;;
"cleanall")
FLAG_CLEAR_ALL=1
break
;;
"rebuild")
FLAG_REBUILD_APP=1
break
;;
"help")
print_help
exit 0
;;
*)
echo "invalid command ($1)"
print_help
exit 1
;;
esac
done
if [[ ${FLAG_CLEAR_ALL} -eq 1 ]] ; then
echo "#########################################################"
echo " Clean all ..."
echo "#########################################################"
rm -rf ${ROOT_DIR}/${OUT_EXE_NAME} ${ROOT_DIR}/build/ ${RTEMS_DIR}
exit 0
fi;
if [[ ${FLAG_BUILD_CROSS} -eq 1 ]] ; then
build_cross_compiler
exit 0
fi;
if [[ ${FLAG_BUILD_RTEMS} -eq 1 ]] ; then
build_rtems_os
exit 0
fi;
if [[ ${FLAG_BUILD_ALL} -eq 1 ]] ; then
build_cross_compiler
build_rtems_os
fi;
if [[ ${FLAG_REBUILD_APP} -eq 1 ]] ; then
project_version_lable=$(bash ${CI_DIR}/ci-generate-version.sh --arch ${RTEMS_ARCH} --bsp ${RTEMS_BSP})
rm -rf ${ROOT_DIR}/${OUT_EXE_NAME} \
${ROOT_DIR}/build/ \
${ROOT_DIR}/${project_version_lable}.tar.gz
fi;
build_application
exit 0