blob: f9bb825052aec97cc93d84e24df3e5afc12a0849 [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.liube08cda2024-05-24 16:37:54 +0800137}
138
liubin207854f2023-07-19 17:25:29 +0800139function file_copy()
140{
b.liuf678f992024-05-08 15:23:10 +0800141 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800142
143 if [ -d $ROOTFS_DIR ];then
144 echo "Copy MBTK out files..."
145 if [ ! -d $ROOTFS_DIR/bin ];then
146 mkdir $ROOTFS_DIR/bin
147 fi
148 if [ ! -d $ROOTFS_DIR/lib ];then
149 mkdir $ROOTFS_DIR/lib
150 fi
b.liube08cda2024-05-24 16:37:54 +0800151
152 copy_bin_and_lib $ROOTFS_DIR
b.liu445758f2024-05-08 16:22:33 +0800153
154 ln_lib
liubin207854f2023-07-19 17:25:29 +0800155 else
156 echo "No found rootfs : $ROOTFS_DIR"
157 fi
158}
159
b.liube08cda2024-05-24 16:37:54 +0800160function temp_mbtk_copy()
161{
162 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
163 if [ -d $TEMP_MBTK_DIR ];then
164 rm -rf $TEMP_MBTK_DIR
165 fi
166
167 mkdir -p $TEMP_MBTK_DIR/mbtk/include
168 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
169 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
170 mkdir -p $TEMP_MBTK_DIR/mbtk/test
171
172 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
173
174 # Copy include file.
175 if [ -d mbtk/include ];then
176 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
177 fi
178
179 # Copy test source.
180 if [ -d mbtk/test ];then
181 cope_file="mbtk/test/*"
182 files=$(ls $cope_file 2> /dev/null | wc -l)
183 if [ "$files" != "0" ] ;then #如果存在文件
184 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
185 fi
186 fi
187}
188
liubin207854f2023-07-19 17:25:29 +0800189function main()
190{
liubine760bd52023-07-20 15:57:21 +0800191 if [ -n "$1" ] ;then
192 build $1
193 exit 0
194 fi
b.liuf534b1f2024-03-19 17:25:26 +0800195
b.liu2f89bfb2023-11-30 17:14:01 +0800196 if [ -d out/bin -a -d out/lib ];then
197 build
b.liuf534b1f2024-03-19 17:25:26 +0800198
b.liu2f89bfb2023-11-30 17:14:01 +0800199 file_copy
200 else
b.liu2f89bfb2023-11-30 17:14:01 +0800201 if [ ! -d out/lib ];then
202 mkdir -p out/lib
203 fi
b.liu482dc0b2024-03-22 15:53:36 +0800204
205 if [ ! -d out/bin ];then
206 mkdir -p out/bin
207 fi
b.liu2f89bfb2023-11-30 17:14:01 +0800208
209 build
210
211 file_copy
212 fi
b.liube08cda2024-05-24 16:37:54 +0800213
214 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800215}
216
liubine760bd52023-07-20 15:57:21 +0800217main $1