blob: 8e42da07eb3b214525eca1987b914825ae3b7340 [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.liub3b923a2024-06-06 15:15:49 +080013# glibc / musl
14export BUILD_STD_LIBC=musl
15
b.liu5d5b8ba2024-02-20 14:00:33 +080016ROOT_DIR=`pwd`
17
18cd ..
19grep "url" .git/config | cut -d " " -f 3 | grep "kernel_5.4.195"
b.liu17d7f8b2023-10-08 16:57:59 +080020if [ $? -eq "0" ]; then
b.liub3b923a2024-06-06 15:15:49 +080021 export BUILD_PLATFORM=v2102
b.liu17d7f8b2023-10-08 16:57:59 +080022else
b.liub3b923a2024-06-06 15:15:49 +080023 export BUILD_PLATFORM=master
b.liu17d7f8b2023-10-08 16:57:59 +080024fi
liubin281ac462023-07-19 14:22:54 +080025
b.liu5d5b8ba2024-02-20 14:00:33 +080026export BUILD_BRANCH=`git branch | grep "*" | cut -d " " -f 2`
b.liuf37bd332024-03-18 13:51:24 +080027BUILD_PROJECT_TEMP=`cat build_version | grep PROJECT | cut -d '=' -f 2`
28echo "BUILD_PROJECT_TEMP=$BUILD_PROJECT_TEMP"
29
b.liub3b923a2024-06-06 15:15:49 +080030if [ "$BUILD_PLATFORM" == "master" ];then
b.liuf37bd332024-03-18 13:51:24 +080031 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
32 export BUILD_PROJECT=L509
33 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
34 export BUILD_PROJECT=L508
35 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
36 export BUILD_PROJECT=PN1803
37 else
38 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
39 exit 1
40 fi
41else
42 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
43 export BUILD_PROJECT=L509
yq.wang307d3452024-03-20 15:46:32 +080044 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-7`" == "L508_X6" ];then
45 export BUILD_PROJECT=L508_X6
b.liuf37bd332024-03-18 13:51:24 +080046 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
47 export BUILD_PROJECT=L508
48 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
49 export BUILD_PROJECT=PN1803
b.liuc25c5472024-06-13 21:35:06 +080050 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "T108-2" ];then
51 export BUILD_PROJECT=T108_2
b.liuf37bd332024-03-18 13:51:24 +080052 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "T108" ];then
53 export BUILD_PROJECT=T108
b.liuf37bd332024-03-18 13:51:24 +080054 else
55 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
56 exit 1
57 fi
58fi
59
b.liu5d5b8ba2024-02-20 14:00:33 +080060cd $ROOT_DIR
61
b.liu1c1c7212023-12-22 16:35:27 +080062export STAGING_DIR=
63
b.liu5d5b8ba2024-02-20 14:00:33 +080064
b.liu17d7f8b2023-10-08 16:57:59 +080065#TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM
66#echo "toolchain : $ROOT_DIR"
liubin281ac462023-07-19 14:22:54 +080067
liubin281ac462023-07-19 14:22:54 +080068
liubin281ac462023-07-19 14:22:54 +080069
liubin207854f2023-07-19 17:25:29 +080070function build()
71{
72 cd mbtk
liubin281ac462023-07-19 14:22:54 +080073
liubin207854f2023-07-19 17:25:29 +080074 if [ -n "$1" ] ;then
75 case "$1" in
76 clean)
77 make clean
78 ;;
79 *)
b.liu8f67dfb2023-11-27 11:27:51 +080080# exit 1;;
81 make -C $1
liubin207854f2023-07-19 17:25:29 +080082 esac
83 else # 无参数
84 make || exit 1
85 fi
liubin281ac462023-07-19 14:22:54 +080086
liubin207854f2023-07-19 17:25:29 +080087 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080088
liubin207854f2023-07-19 17:25:29 +080089 echo "Build MBTK success."
90}
91
b.liu445758f2024-05-08 16:22:33 +080092ln_lib()
93{
94 PWD_TEMP=`pwd`
95
96 cd $ROOTFS_DIR/lib
97 [ ! -f libpoweralarm.so ] && ln -s liblynq_lib.so libpoweralarm.so
98 [ ! -f liblynq-qser-audio.so ] && ln -s liblynq_lib.so liblynq-qser-audio.so
99 [ ! -f liblynq-adc.so ] && ln -s liblynq_lib.so liblynq-adc.so
100 [ ! -f liblynq-fota.so ] && ln -s liblynq_lib.so liblynq-fota.so
101 [ ! -f liblynq-qser-gnss.so ] && ln -s liblynq_lib.so liblynq-qser-gnss.so
102 [ ! -f liblynq-log.so ] && ln -s liblynq_lib.so liblynq-log.so
103 [ ! -f liblynq-led.so ] && ln -s liblynq_lib.so liblynq-led.so
104 [ ! -f liblynq-qser-autosuspend.so ] && ln -s liblynq_lib.so liblynq-qser-autosuspend.so
105 [ ! -f liblynq-systime.so ] && ln -s liblynq_lib.so liblynq-systime.so
106 [ ! -f liblynq-qser-thermal.so ] && ln -s liblynq_lib.so liblynq-qser-thermal.so
107 [ ! -f liblynq-qser-sim.so ] && ln -s liblynq_lib.so liblynq-qser-sim.so
108 [ ! -f liblynq-qser-sms.so ] && ln -s liblynq_lib.so liblynq-qser-sms.so
109 [ ! -f liblynq-qser-voice.so ] && ln -s liblynq_lib.so liblynq-qser-voice.so
110 [ ! -f liblynq-qser-network.so ] && ln -s liblynq_lib.so liblynq-qser-network.so
111 [ ! -f liblynq-qser-data.so ] && ln -s liblynq_lib.so liblynq-qser-data.so
112 [ ! -f liblynq-irq.so ] && ln -s liblynq_lib.so liblynq-irq.so
113
114 cd $PWD_TEMP
115}
116
b.liube08cda2024-05-24 16:37:54 +0800117function copy_bin_and_lib()
118{
119 # Copy All SO Files.
120 cp -f out/lib/* $1/lib
121
122 # Copy All Bin Files.
123 #cp -f out/bin/* $1/bin
124 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
125 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
126 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
127 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
128 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
129 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
130 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
131 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
132 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
133 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
134 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +0800135 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +0800136 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +0800137 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liube08cda2024-05-24 16:37:54 +0800138}
139
liubin207854f2023-07-19 17:25:29 +0800140function file_copy()
141{
b.liuf678f992024-05-08 15:23:10 +0800142 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800143
144 if [ -d $ROOTFS_DIR ];then
145 echo "Copy MBTK out files..."
146 if [ ! -d $ROOTFS_DIR/bin ];then
147 mkdir $ROOTFS_DIR/bin
148 fi
149 if [ ! -d $ROOTFS_DIR/lib ];then
150 mkdir $ROOTFS_DIR/lib
151 fi
b.liube08cda2024-05-24 16:37:54 +0800152
153 copy_bin_and_lib $ROOTFS_DIR
b.liu445758f2024-05-08 16:22:33 +0800154
155 ln_lib
liubin207854f2023-07-19 17:25:29 +0800156 else
157 echo "No found rootfs : $ROOTFS_DIR"
158 fi
159}
160
b.liube08cda2024-05-24 16:37:54 +0800161function temp_mbtk_copy()
162{
163 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
164 if [ -d $TEMP_MBTK_DIR ];then
165 rm -rf $TEMP_MBTK_DIR
166 fi
167
168 mkdir -p $TEMP_MBTK_DIR/mbtk/include
169 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
170 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
171 mkdir -p $TEMP_MBTK_DIR/mbtk/test
172
173 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
174
175 # Copy include file.
176 if [ -d mbtk/include ];then
177 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
178 fi
179
180 # Copy test source.
181 if [ -d mbtk/test ];then
182 cope_file="mbtk/test/*"
183 files=$(ls $cope_file 2> /dev/null | wc -l)
184 if [ "$files" != "0" ] ;then #如果存在文件
185 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
186 fi
187 fi
188}
189
liubin207854f2023-07-19 17:25:29 +0800190function main()
191{
liubine760bd52023-07-20 15:57:21 +0800192 if [ -n "$1" ] ;then
193 build $1
194 exit 0
195 fi
b.liuf534b1f2024-03-19 17:25:26 +0800196
b.liu2f89bfb2023-11-30 17:14:01 +0800197 if [ -d out/bin -a -d out/lib ];then
198 build
b.liuf534b1f2024-03-19 17:25:26 +0800199
b.liu2f89bfb2023-11-30 17:14:01 +0800200 file_copy
201 else
b.liu2f89bfb2023-11-30 17:14:01 +0800202 if [ ! -d out/lib ];then
203 mkdir -p out/lib
204 fi
b.liu482dc0b2024-03-22 15:53:36 +0800205
206 if [ ! -d out/bin ];then
207 mkdir -p out/bin
208 fi
b.liu2f89bfb2023-11-30 17:14:01 +0800209
210 build
211
212 file_copy
213 fi
b.liube08cda2024-05-24 16:37:54 +0800214
215 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800216}
217
liubine760bd52023-07-20 15:57:21 +0800218main $1