blob: 038f8acd4440c611be562123334c63e398b7d24a [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001#!/bin/bash
2
3# Config item.
4# static / shared
b.liu17d7f8b2023-10-08 16:57:59 +08005#LIB_TYPE=static
liubin281ac462023-07-19 14:22:54 +08006# gcc-4.9 / gcc-8.4
b.liu17d7f8b2023-10-08 16:57:59 +08007#export PLATFORM=gcc-4.9
8
9# static / shared
10export BUILD_LIB_TYPE=shared
11# gcc-4.9 / gcc-8.4
12
b.liu5d5b8ba2024-02-20 14:00:33 +080013ROOT_DIR=`pwd`
14
15cd ..
16grep "url" .git/config | cut -d " " -f 3 | grep "kernel_5.4.195"
b.liu17d7f8b2023-10-08 16:57:59 +080017if [ $? -eq "0" ]; then
b.liub3b923a2024-06-06 15:15:49 +080018 export BUILD_PLATFORM=v2102
b.liu17d7f8b2023-10-08 16:57:59 +080019else
b.liub3b923a2024-06-06 15:15:49 +080020 export BUILD_PLATFORM=master
b.liu17d7f8b2023-10-08 16:57:59 +080021fi
liubin281ac462023-07-19 14:22:54 +080022
b.liu5d5b8ba2024-02-20 14:00:33 +080023export BUILD_BRANCH=`git branch | grep "*" | cut -d " " -f 2`
b.liuced8dd02024-06-28 13:28:29 +080024cd $ROOT_DIR
25
26BUILD_PROJECT_TEMP=`cat config | grep CONFIG_PROJECT | cut -d '=' -f 2`
27if [ "$BUILD_PROJECT_TEMP" == "DEFAULT" ];then
28 BUILD_PROJECT_TEMP=`cat ../build_version | grep PROJECT | cut -d '=' -f 2`
29fi
30
31BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2`
32if [ "$BUILD_LIBC_TEMP" == "musl" ];then
33 export BUILD_STD_LIBC=musl
34else
35 export BUILD_STD_LIBC=glibc
36fi
b.liuf37bd332024-03-18 13:51:24 +080037
b.liub3b923a2024-06-06 15:15:49 +080038if [ "$BUILD_PLATFORM" == "master" ];then
b.liuf37bd332024-03-18 13:51:24 +080039 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
40 export BUILD_PROJECT=L509
41 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
42 export BUILD_PROJECT=L508
43 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
44 export BUILD_PROJECT=PN1803
45 else
46 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
47 exit 1
48 fi
49else
50 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
51 export BUILD_PROJECT=L509
yq.wang307d3452024-03-20 15:46:32 +080052 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-7`" == "L508_X6" ];then
53 export BUILD_PROJECT=L508_X6
b.liuf37bd332024-03-18 13:51:24 +080054 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
55 export BUILD_PROJECT=L508
56 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
57 export BUILD_PROJECT=PN1803
b.liuc25c5472024-06-13 21:35:06 +080058 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "T108-2" ];then
59 export BUILD_PROJECT=T108_2
b.liuf37bd332024-03-18 13:51:24 +080060 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "T108" ];then
61 export BUILD_PROJECT=T108
b.liuf37bd332024-03-18 13:51:24 +080062 else
63 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
64 exit 1
65 fi
66fi
67
b.liuced8dd02024-06-28 13:28:29 +080068export MBTK_AF_SUPPORT=`cat config | grep CONFIG_AF_SUPPORT | cut -d '=' -f 2`
69export MBTK_YX_SUPPORT=`cat config | grep CONFIG_YX_SUPPORT | cut -d '=' -f 2`
70export MBTK_SG_SUPPORT=`cat config | grep CONFIG_SG_SUPPORT | cut -d '=' -f 2`
71export MBTK_ALL_CID_SUPPORT=`cat config | grep CONFIG_MBTK_ALL_CID_SUPPORT | cut -d '=' -f 2`
72export MBTK_GNSS_MODE=`cat config | grep CONFIG_MBTK_GNSS_MODE | cut -d '=' -f 2`
73export MBTK_DUMP_SUPPORT=`cat config | grep CONFIG_MBTK_DUMP_SUPPORT | cut -d '=' -f 2`
74
75# 赛格默认打开 ALL_CID_SUPPORT
76if [ "$MBTK_SG_SUPPORT" == "y" ];then
77 export MBTK_ALL_CID_SUPPORT=y
78 export BUILD_STD_LIBC=musl
79fi
80
81# 安付默认打开 ALL_CID_SUPPORT
82if [ "$MBTK_AF_SUPPORT" == "y" ];then
83 export BUILD_STD_LIBC=musl
84fi
85
86
87# musl 不支持mbtk dump
88if [ "$BUILD_STD_LIBC" == "musl" ];then
89 export MBTK_DUMP_SUPPORT=n
90fi
b.liu5d5b8ba2024-02-20 14:00:33 +080091
b.liu1c1c7212023-12-22 16:35:27 +080092export STAGING_DIR=
93
b.liu17d7f8b2023-10-08 16:57:59 +080094#TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM
95#echo "toolchain : $ROOT_DIR"
liubin281ac462023-07-19 14:22:54 +080096
liubin281ac462023-07-19 14:22:54 +080097
liubin281ac462023-07-19 14:22:54 +080098
liubin207854f2023-07-19 17:25:29 +080099function build()
100{
101 cd mbtk
liubin281ac462023-07-19 14:22:54 +0800102
liubin207854f2023-07-19 17:25:29 +0800103 if [ -n "$1" ] ;then
104 case "$1" in
105 clean)
106 make clean
107 ;;
108 *)
b.liu8f67dfb2023-11-27 11:27:51 +0800109# exit 1;;
110 make -C $1
liubin207854f2023-07-19 17:25:29 +0800111 esac
112 else # 无参数
113 make || exit 1
114 fi
liubin281ac462023-07-19 14:22:54 +0800115
liubin207854f2023-07-19 17:25:29 +0800116 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +0800117
liubin207854f2023-07-19 17:25:29 +0800118 echo "Build MBTK success."
119}
120
b.liu445758f2024-05-08 16:22:33 +0800121ln_lib()
122{
123 PWD_TEMP=`pwd`
124
125 cd $ROOTFS_DIR/lib
126 [ ! -f libpoweralarm.so ] && ln -s liblynq_lib.so libpoweralarm.so
127 [ ! -f liblynq-qser-audio.so ] && ln -s liblynq_lib.so liblynq-qser-audio.so
128 [ ! -f liblynq-adc.so ] && ln -s liblynq_lib.so liblynq-adc.so
129 [ ! -f liblynq-fota.so ] && ln -s liblynq_lib.so liblynq-fota.so
130 [ ! -f liblynq-qser-gnss.so ] && ln -s liblynq_lib.so liblynq-qser-gnss.so
131 [ ! -f liblynq-log.so ] && ln -s liblynq_lib.so liblynq-log.so
132 [ ! -f liblynq-led.so ] && ln -s liblynq_lib.so liblynq-led.so
133 [ ! -f liblynq-qser-autosuspend.so ] && ln -s liblynq_lib.so liblynq-qser-autosuspend.so
134 [ ! -f liblynq-systime.so ] && ln -s liblynq_lib.so liblynq-systime.so
135 [ ! -f liblynq-qser-thermal.so ] && ln -s liblynq_lib.so liblynq-qser-thermal.so
136 [ ! -f liblynq-qser-sim.so ] && ln -s liblynq_lib.so liblynq-qser-sim.so
137 [ ! -f liblynq-qser-sms.so ] && ln -s liblynq_lib.so liblynq-qser-sms.so
138 [ ! -f liblynq-qser-voice.so ] && ln -s liblynq_lib.so liblynq-qser-voice.so
139 [ ! -f liblynq-qser-network.so ] && ln -s liblynq_lib.so liblynq-qser-network.so
140 [ ! -f liblynq-qser-data.so ] && ln -s liblynq_lib.so liblynq-qser-data.so
141 [ ! -f liblynq-irq.so ] && ln -s liblynq_lib.so liblynq-irq.so
142
143 cd $PWD_TEMP
144}
145
b.liube08cda2024-05-24 16:37:54 +0800146function copy_bin_and_lib()
147{
148 # Copy All SO Files.
149 cp -f out/lib/* $1/lib
150
151 # Copy All Bin Files.
152 #cp -f out/bin/* $1/bin
153 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
154 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
155 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
156 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
157 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
158 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
159 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
160 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
161 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
162 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
163 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +0800164 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +0800165 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +0800166 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +0800167 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
168
169
170 # Copy GNSS(5311) bin files.
171 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
172 [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc
b.liube08cda2024-05-24 16:37:54 +0800173}
174
liubin207854f2023-07-19 17:25:29 +0800175function file_copy()
176{
b.liuf678f992024-05-08 15:23:10 +0800177 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800178
179 if [ -d $ROOTFS_DIR ];then
180 echo "Copy MBTK out files..."
181 if [ ! -d $ROOTFS_DIR/bin ];then
182 mkdir $ROOTFS_DIR/bin
183 fi
184 if [ ! -d $ROOTFS_DIR/lib ];then
185 mkdir $ROOTFS_DIR/lib
186 fi
b.liube08cda2024-05-24 16:37:54 +0800187
188 copy_bin_and_lib $ROOTFS_DIR
b.liu445758f2024-05-08 16:22:33 +0800189
190 ln_lib
liubin207854f2023-07-19 17:25:29 +0800191 else
192 echo "No found rootfs : $ROOTFS_DIR"
193 fi
194}
195
b.liube08cda2024-05-24 16:37:54 +0800196function temp_mbtk_copy()
197{
198 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
199 if [ -d $TEMP_MBTK_DIR ];then
200 rm -rf $TEMP_MBTK_DIR
201 fi
202
203 mkdir -p $TEMP_MBTK_DIR/mbtk/include
204 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
205 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800206 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800207 mkdir -p $TEMP_MBTK_DIR/mbtk/test
208
209 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
210
211 # Copy include file.
212 if [ -d mbtk/include ];then
213 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
214 fi
215
216 # Copy test source.
217 if [ -d mbtk/test ];then
218 cope_file="mbtk/test/*"
219 files=$(ls $cope_file 2> /dev/null | wc -l)
220 if [ "$files" != "0" ] ;then #如果存在文件
221 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
222 fi
223 fi
224}
225
b.liuced8dd02024-06-28 13:28:29 +0800226function print_arg()
227{
228 echo BUILD_PROJECT=$BUILD_PROJECT
229 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
230 echo MBTK_GNSS_MODE=$MBTK_GNSS_MODE
231 echo MBTK_AF_SUPPORT=$MBTK_AF_SUPPORT
232 echo MBTK_YX_SUPPORT=$MBTK_YX_SUPPORT
233 echo MBTK_SG_SUPPORT=$MBTK_SG_SUPPORT
234 echo MBTK_ALL_CID_SUPPORT=$MBTK_ALL_CID_SUPPORT
235 echo MBTK_DUMP_SUPPORT=$MBTK_DUMP_SUPPORT
236}
237
liubin207854f2023-07-19 17:25:29 +0800238function main()
239{
liubine760bd52023-07-20 15:57:21 +0800240 if [ -n "$1" ] ;then
241 build $1
242 exit 0
243 fi
b.liuf534b1f2024-03-19 17:25:26 +0800244
b.liu2f89bfb2023-11-30 17:14:01 +0800245 if [ -d out/bin -a -d out/lib ];then
246 build
b.liuced8dd02024-06-28 13:28:29 +0800247
248 print_arg
b.liuf534b1f2024-03-19 17:25:26 +0800249
b.liu2f89bfb2023-11-30 17:14:01 +0800250 file_copy
251 else
b.liu2f89bfb2023-11-30 17:14:01 +0800252 if [ ! -d out/lib ];then
253 mkdir -p out/lib
254 fi
b.liu482dc0b2024-03-22 15:53:36 +0800255
256 if [ ! -d out/bin ];then
257 mkdir -p out/bin
258 fi
b.liu2f89bfb2023-11-30 17:14:01 +0800259
260 build
b.liuced8dd02024-06-28 13:28:29 +0800261
262 print_arg
b.liu2f89bfb2023-11-30 17:14:01 +0800263
264 file_copy
265 fi
b.liube08cda2024-05-24 16:37:54 +0800266
267 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800268}
269
b.liuced8dd02024-06-28 13:28:29 +0800270# exit 1
271print_arg
272
273main $1