blob: fd480389d33f5676f1d97a3039d295cb5ef7773a [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.liu87afc4c2024-08-14 17:33:45 +080038MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
39if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
40 export MBTK_SOURCE_VERSION=2
41else
42 export MBTK_SOURCE_VERSION=1
43fi
44
b.liub3b923a2024-06-06 15:15:49 +080045if [ "$BUILD_PLATFORM" == "master" ];then
b.liuf37bd332024-03-18 13:51:24 +080046 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
47 export BUILD_PROJECT=L509
48 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
49 export BUILD_PROJECT=L508
50 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
51 export BUILD_PROJECT=PN1803
52 else
53 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
54 exit 1
55 fi
56else
57 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
58 export BUILD_PROJECT=L509
yq.wang307d3452024-03-20 15:46:32 +080059 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-7`" == "L508_X6" ];then
60 export BUILD_PROJECT=L508_X6
b.liuf37bd332024-03-18 13:51:24 +080061 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
62 export BUILD_PROJECT=L508
63 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
64 export BUILD_PROJECT=PN1803
b.liuc25c5472024-06-13 21:35:06 +080065 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "T108-2" ];then
66 export BUILD_PROJECT=T108_2
b.liuf37bd332024-03-18 13:51:24 +080067 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "T108" ];then
68 export BUILD_PROJECT=T108
b.liuf37bd332024-03-18 13:51:24 +080069 else
70 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
71 exit 1
72 fi
73fi
74
b.liuced8dd02024-06-28 13:28:29 +080075export MBTK_AF_SUPPORT=`cat config | grep CONFIG_AF_SUPPORT | cut -d '=' -f 2`
76export MBTK_YX_SUPPORT=`cat config | grep CONFIG_YX_SUPPORT | cut -d '=' -f 2`
77export MBTK_SG_SUPPORT=`cat config | grep CONFIG_SG_SUPPORT | cut -d '=' -f 2`
78export MBTK_ALL_CID_SUPPORT=`cat config | grep CONFIG_MBTK_ALL_CID_SUPPORT | cut -d '=' -f 2`
79export MBTK_GNSS_MODE=`cat config | grep CONFIG_MBTK_GNSS_MODE | cut -d '=' -f 2`
80export MBTK_DUMP_SUPPORT=`cat config | grep CONFIG_MBTK_DUMP_SUPPORT | cut -d '=' -f 2`
81
82# 赛格默认打开 ALL_CID_SUPPORT
83if [ "$MBTK_SG_SUPPORT" == "y" ];then
84 export MBTK_ALL_CID_SUPPORT=y
85 export BUILD_STD_LIBC=musl
86fi
87
88# 安付默认打开 ALL_CID_SUPPORT
89if [ "$MBTK_AF_SUPPORT" == "y" ];then
90 export BUILD_STD_LIBC=musl
91fi
92
93
94# musl 不支持mbtk dump
95if [ "$BUILD_STD_LIBC" == "musl" ];then
96 export MBTK_DUMP_SUPPORT=n
97fi
b.liu5d5b8ba2024-02-20 14:00:33 +080098
b.liu1c1c7212023-12-22 16:35:27 +080099export STAGING_DIR=
100
b.liu17d7f8b2023-10-08 16:57:59 +0800101#TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM
102#echo "toolchain : $ROOT_DIR"
liubin281ac462023-07-19 14:22:54 +0800103
liubin281ac462023-07-19 14:22:54 +0800104
liubin281ac462023-07-19 14:22:54 +0800105
liubin207854f2023-07-19 17:25:29 +0800106function build()
107{
108 cd mbtk
liubin281ac462023-07-19 14:22:54 +0800109
liubin207854f2023-07-19 17:25:29 +0800110 if [ -n "$1" ] ;then
111 case "$1" in
112 clean)
113 make clean
114 ;;
115 *)
b.liu8f67dfb2023-11-27 11:27:51 +0800116# exit 1;;
117 make -C $1
liubin207854f2023-07-19 17:25:29 +0800118 esac
119 else # 无参数
120 make || exit 1
121 fi
liubin281ac462023-07-19 14:22:54 +0800122
liubin207854f2023-07-19 17:25:29 +0800123 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +0800124
liubin207854f2023-07-19 17:25:29 +0800125 echo "Build MBTK success."
126}
127
b.liu445758f2024-05-08 16:22:33 +0800128ln_lib()
129{
130 PWD_TEMP=`pwd`
131
132 cd $ROOTFS_DIR/lib
133 [ ! -f libpoweralarm.so ] && ln -s liblynq_lib.so libpoweralarm.so
134 [ ! -f liblynq-qser-audio.so ] && ln -s liblynq_lib.so liblynq-qser-audio.so
135 [ ! -f liblynq-adc.so ] && ln -s liblynq_lib.so liblynq-adc.so
136 [ ! -f liblynq-fota.so ] && ln -s liblynq_lib.so liblynq-fota.so
137 [ ! -f liblynq-qser-gnss.so ] && ln -s liblynq_lib.so liblynq-qser-gnss.so
138 [ ! -f liblynq-log.so ] && ln -s liblynq_lib.so liblynq-log.so
139 [ ! -f liblynq-led.so ] && ln -s liblynq_lib.so liblynq-led.so
140 [ ! -f liblynq-qser-autosuspend.so ] && ln -s liblynq_lib.so liblynq-qser-autosuspend.so
141 [ ! -f liblynq-systime.so ] && ln -s liblynq_lib.so liblynq-systime.so
142 [ ! -f liblynq-qser-thermal.so ] && ln -s liblynq_lib.so liblynq-qser-thermal.so
143 [ ! -f liblynq-qser-sim.so ] && ln -s liblynq_lib.so liblynq-qser-sim.so
144 [ ! -f liblynq-qser-sms.so ] && ln -s liblynq_lib.so liblynq-qser-sms.so
145 [ ! -f liblynq-qser-voice.so ] && ln -s liblynq_lib.so liblynq-qser-voice.so
146 [ ! -f liblynq-qser-network.so ] && ln -s liblynq_lib.so liblynq-qser-network.so
147 [ ! -f liblynq-qser-data.so ] && ln -s liblynq_lib.so liblynq-qser-data.so
148 [ ! -f liblynq-irq.so ] && ln -s liblynq_lib.so liblynq-irq.so
149
150 cd $PWD_TEMP
151}
152
b.liube08cda2024-05-24 16:37:54 +0800153function copy_bin_and_lib()
154{
155 # Copy All SO Files.
156 cp -f out/lib/* $1/lib
157
158 # Copy All Bin Files.
159 #cp -f out/bin/* $1/bin
160 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
161 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
162 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
163 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
164 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
165 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
166 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
167 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
168 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
169 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
170 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +0800171 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +0800172 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +0800173 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +0800174 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
175
176
177 # Copy GNSS(5311) bin files.
178 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
179 [ -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 +0800180}
181
liubin207854f2023-07-19 17:25:29 +0800182function file_copy()
183{
b.liuf678f992024-05-08 15:23:10 +0800184 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800185
186 if [ -d $ROOTFS_DIR ];then
187 echo "Copy MBTK out files..."
188 if [ ! -d $ROOTFS_DIR/bin ];then
189 mkdir $ROOTFS_DIR/bin
190 fi
191 if [ ! -d $ROOTFS_DIR/lib ];then
192 mkdir $ROOTFS_DIR/lib
193 fi
b.liube08cda2024-05-24 16:37:54 +0800194
195 copy_bin_and_lib $ROOTFS_DIR
b.liu445758f2024-05-08 16:22:33 +0800196
197 ln_lib
liubin207854f2023-07-19 17:25:29 +0800198 else
199 echo "No found rootfs : $ROOTFS_DIR"
200 fi
201}
202
b.liube08cda2024-05-24 16:37:54 +0800203function temp_mbtk_copy()
204{
205 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
206 if [ -d $TEMP_MBTK_DIR ];then
207 rm -rf $TEMP_MBTK_DIR
208 fi
209
210 mkdir -p $TEMP_MBTK_DIR/mbtk/include
211 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
212 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800213 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800214 mkdir -p $TEMP_MBTK_DIR/mbtk/test
215
216 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
217
218 # Copy include file.
219 if [ -d mbtk/include ];then
220 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
221 fi
222
223 # Copy test source.
224 if [ -d mbtk/test ];then
225 cope_file="mbtk/test/*"
226 files=$(ls $cope_file 2> /dev/null | wc -l)
227 if [ "$files" != "0" ] ;then #如果存在文件
228 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
229 fi
230 fi
231}
232
b.liuced8dd02024-06-28 13:28:29 +0800233function print_arg()
234{
235 echo BUILD_PROJECT=$BUILD_PROJECT
236 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800237 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800238 echo MBTK_GNSS_MODE=$MBTK_GNSS_MODE
239 echo MBTK_AF_SUPPORT=$MBTK_AF_SUPPORT
240 echo MBTK_YX_SUPPORT=$MBTK_YX_SUPPORT
241 echo MBTK_SG_SUPPORT=$MBTK_SG_SUPPORT
242 echo MBTK_ALL_CID_SUPPORT=$MBTK_ALL_CID_SUPPORT
243 echo MBTK_DUMP_SUPPORT=$MBTK_DUMP_SUPPORT
244}
245
liubin207854f2023-07-19 17:25:29 +0800246function main()
247{
liubine760bd52023-07-20 15:57:21 +0800248 if [ -n "$1" ] ;then
249 build $1
250 exit 0
251 fi
b.liuf534b1f2024-03-19 17:25:26 +0800252
b.liu2f89bfb2023-11-30 17:14:01 +0800253 if [ -d out/bin -a -d out/lib ];then
254 build
b.liuced8dd02024-06-28 13:28:29 +0800255
256 print_arg
b.liuf534b1f2024-03-19 17:25:26 +0800257
b.liu2f89bfb2023-11-30 17:14:01 +0800258 file_copy
259 else
b.liu2f89bfb2023-11-30 17:14:01 +0800260 if [ ! -d out/lib ];then
261 mkdir -p out/lib
262 fi
b.liu482dc0b2024-03-22 15:53:36 +0800263
264 if [ ! -d out/bin ];then
265 mkdir -p out/bin
266 fi
b.liu2f89bfb2023-11-30 17:14:01 +0800267
268 build
b.liuced8dd02024-06-28 13:28:29 +0800269
270 print_arg
b.liu2f89bfb2023-11-30 17:14:01 +0800271
272 file_copy
273 fi
b.liube08cda2024-05-24 16:37:54 +0800274
275 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800276}
277
b.liuced8dd02024-06-28 13:28:29 +0800278# exit 1
279print_arg
280
281main $1