blob: 4991331b07ec5faab1f5f9c8024fd48ed58462a6 [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.liu3403c932023-10-10 16:26:35 +080018 export BUILD_PLATFORM=asr1806
b.liu17d7f8b2023-10-08 16:57:59 +080019else
b.liu3403c932023-10-10 16:26:35 +080020 export BUILD_PLATFORM=asr1803
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.liuf37bd332024-03-18 13:51:24 +080024BUILD_PROJECT_TEMP=`cat build_version | grep PROJECT | cut -d '=' -f 2`
25echo "BUILD_PROJECT_TEMP=$BUILD_PROJECT_TEMP"
26
27if [ "$BUILD_PLATFORM" == "asr1803" ];then
28 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
29 export BUILD_PROJECT=L509
30 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
31 export BUILD_PROJECT=L508
32 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
33 export BUILD_PROJECT=PN1803
34 else
35 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
36 exit 1
37 fi
38else
39 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
40 export BUILD_PROJECT=L509
yq.wang307d3452024-03-20 15:46:32 +080041 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-7`" == "L508_X6" ];then
42 export BUILD_PROJECT=L508_X6
b.liuf37bd332024-03-18 13:51:24 +080043 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then
44 export BUILD_PROJECT=L508
45 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then
46 export BUILD_PROJECT=PN1803
47 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "T108" ];then
48 export BUILD_PROJECT=T108
b.liuf37bd332024-03-18 13:51:24 +080049 else
50 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
51 exit 1
52 fi
53fi
54
b.liu5d5b8ba2024-02-20 14:00:33 +080055cd $ROOT_DIR
56
b.liu1c1c7212023-12-22 16:35:27 +080057export STAGING_DIR=
58
b.liu5d5b8ba2024-02-20 14:00:33 +080059
b.liu17d7f8b2023-10-08 16:57:59 +080060#TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM
61#echo "toolchain : $ROOT_DIR"
liubin281ac462023-07-19 14:22:54 +080062
liubin281ac462023-07-19 14:22:54 +080063
liubin281ac462023-07-19 14:22:54 +080064
liubin207854f2023-07-19 17:25:29 +080065function build()
66{
67 cd mbtk
liubin281ac462023-07-19 14:22:54 +080068
liubin207854f2023-07-19 17:25:29 +080069 if [ -n "$1" ] ;then
70 case "$1" in
71 clean)
72 make clean
73 ;;
74 *)
b.liu8f67dfb2023-11-27 11:27:51 +080075# exit 1;;
76 make -C $1
liubin207854f2023-07-19 17:25:29 +080077 esac
78 else # 无参数
79 make || exit 1
80 fi
liubin281ac462023-07-19 14:22:54 +080081
liubin207854f2023-07-19 17:25:29 +080082 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080083
liubin207854f2023-07-19 17:25:29 +080084 echo "Build MBTK success."
85}
86
b.liu445758f2024-05-08 16:22:33 +080087ln_lib()
88{
89 PWD_TEMP=`pwd`
90
91 cd $ROOTFS_DIR/lib
92 [ ! -f libpoweralarm.so ] && ln -s liblynq_lib.so libpoweralarm.so
93 [ ! -f liblynq-qser-audio.so ] && ln -s liblynq_lib.so liblynq-qser-audio.so
94 [ ! -f liblynq-adc.so ] && ln -s liblynq_lib.so liblynq-adc.so
95 [ ! -f liblynq-fota.so ] && ln -s liblynq_lib.so liblynq-fota.so
96 [ ! -f liblynq-qser-gnss.so ] && ln -s liblynq_lib.so liblynq-qser-gnss.so
97 [ ! -f liblynq-log.so ] && ln -s liblynq_lib.so liblynq-log.so
98 [ ! -f liblynq-led.so ] && ln -s liblynq_lib.so liblynq-led.so
99 [ ! -f liblynq-qser-autosuspend.so ] && ln -s liblynq_lib.so liblynq-qser-autosuspend.so
100 [ ! -f liblynq-systime.so ] && ln -s liblynq_lib.so liblynq-systime.so
101 [ ! -f liblynq-qser-thermal.so ] && ln -s liblynq_lib.so liblynq-qser-thermal.so
102 [ ! -f liblynq-qser-sim.so ] && ln -s liblynq_lib.so liblynq-qser-sim.so
103 [ ! -f liblynq-qser-sms.so ] && ln -s liblynq_lib.so liblynq-qser-sms.so
104 [ ! -f liblynq-qser-voice.so ] && ln -s liblynq_lib.so liblynq-qser-voice.so
105 [ ! -f liblynq-qser-network.so ] && ln -s liblynq_lib.so liblynq-qser-network.so
106 [ ! -f liblynq-qser-data.so ] && ln -s liblynq_lib.so liblynq-qser-data.so
107 [ ! -f liblynq-irq.so ] && ln -s liblynq_lib.so liblynq-irq.so
108
109 cd $PWD_TEMP
110}
111
b.liube08cda2024-05-24 16:37:54 +0800112function copy_bin_and_lib()
113{
114 # Copy All SO Files.
115 cp -f out/lib/* $1/lib
116
117 # Copy All Bin Files.
118 #cp -f out/bin/* $1/bin
119 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
120 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
121 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
122 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
123 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
124 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
125 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
126 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
127 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
128 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
129 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +0800130 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liube08cda2024-05-24 16:37:54 +0800131}
132
liubin207854f2023-07-19 17:25:29 +0800133function file_copy()
134{
b.liuf678f992024-05-08 15:23:10 +0800135 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800136
137 if [ -d $ROOTFS_DIR ];then
138 echo "Copy MBTK out files..."
139 if [ ! -d $ROOTFS_DIR/bin ];then
140 mkdir $ROOTFS_DIR/bin
141 fi
142 if [ ! -d $ROOTFS_DIR/lib ];then
143 mkdir $ROOTFS_DIR/lib
144 fi
b.liube08cda2024-05-24 16:37:54 +0800145
146 copy_bin_and_lib $ROOTFS_DIR
b.liu445758f2024-05-08 16:22:33 +0800147
148 ln_lib
liubin207854f2023-07-19 17:25:29 +0800149 else
150 echo "No found rootfs : $ROOTFS_DIR"
151 fi
152}
153
b.liube08cda2024-05-24 16:37:54 +0800154function temp_mbtk_copy()
155{
156 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
157 if [ -d $TEMP_MBTK_DIR ];then
158 rm -rf $TEMP_MBTK_DIR
159 fi
160
161 mkdir -p $TEMP_MBTK_DIR/mbtk/include
162 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
163 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
164 mkdir -p $TEMP_MBTK_DIR/mbtk/test
165
166 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
167
168 # Copy include file.
169 if [ -d mbtk/include ];then
170 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
171 fi
172
173 # Copy test source.
174 if [ -d mbtk/test ];then
175 cope_file="mbtk/test/*"
176 files=$(ls $cope_file 2> /dev/null | wc -l)
177 if [ "$files" != "0" ] ;then #如果存在文件
178 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
179 fi
180 fi
181}
182
liubin207854f2023-07-19 17:25:29 +0800183function main()
184{
liubine760bd52023-07-20 15:57:21 +0800185 if [ -n "$1" ] ;then
186 build $1
187 exit 0
188 fi
b.liuf534b1f2024-03-19 17:25:26 +0800189
b.liu2f89bfb2023-11-30 17:14:01 +0800190 if [ -d out/bin -a -d out/lib ];then
191 build
b.liuf534b1f2024-03-19 17:25:26 +0800192
b.liu2f89bfb2023-11-30 17:14:01 +0800193 file_copy
194 else
b.liu2f89bfb2023-11-30 17:14:01 +0800195 if [ ! -d out/lib ];then
196 mkdir -p out/lib
197 fi
b.liu482dc0b2024-03-22 15:53:36 +0800198
199 if [ ! -d out/bin ];then
200 mkdir -p out/bin
201 fi
b.liu2f89bfb2023-11-30 17:14:01 +0800202
203 build
204
205 file_copy
206 fi
b.liube08cda2024-05-24 16:37:54 +0800207
208 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800209}
210
liubine760bd52023-07-20 15:57:21 +0800211main $1