blob: 626e6f8142176135c3ca9162e726ba2e39744fb7 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001#!/bin/bash
2
b.liu575a0f12024-12-19 20:08:45 +08003if [ ! -f config ];then
4 echo "Exec init.sh in the first."
5 exit 1
6fi
7
b.liu17d7f8b2023-10-08 16:57:59 +08008# static / shared
9export BUILD_LIB_TYPE=shared
b.liu450e3992024-10-10 10:59:29 +080010
11export STAGING_DIR=
b.liu17d7f8b2023-10-08 16:57:59 +080012
b.liu5d5b8ba2024-02-20 14:00:33 +080013ROOT_DIR=`pwd`
14
b.liuced8dd02024-06-28 13:28:29 +080015BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2`
16if [ "$BUILD_LIBC_TEMP" == "musl" ];then
17 export BUILD_STD_LIBC=musl
18else
19 export BUILD_STD_LIBC=glibc
20fi
b.liuf37bd332024-03-18 13:51:24 +080021
b.liudeb8e422024-12-14 17:36:56 +080022export BUILD_GCC_VERSION=`cat config | grep CONFIG_GCC_VERSION | cut -d '=' -f 2`
23
b.liu9f91db32025-02-13 11:24:18 +080024#export MBTK_DEV_INFO_VERSION=`cat config | grep CONFIG_DEV_INFO_VERSION | cut -d '=' -f 2`
b.liu61ad9172025-01-09 14:33:55 +080025export CONFIG_MBTK_5G_SUPPORT=`cat config | grep CONFIG_MBTK_5G_SUPPORT | cut -d '=' -f 2`
b.liu472cfaf2024-12-19 19:08:19 +080026
b.liu61eedc92024-11-13 16:07:00 +080027if [ -n "$1" ] ;then
28 case "$1" in
29 v1)
30 export MBTK_SOURCE_VERSION=1
31 ;;
32 v2)
33 export MBTK_SOURCE_VERSION=2
34 ;;
35 *)
36 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
37 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
38 export MBTK_SOURCE_VERSION=2
39 else
40 export MBTK_SOURCE_VERSION=1
41 fi
42 esac
b.liu87afc4c2024-08-14 17:33:45 +080043else
b.liu61eedc92024-11-13 16:07:00 +080044 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
45 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
46 export MBTK_SOURCE_VERSION=2
47 else
48 export MBTK_SOURCE_VERSION=1
49 fi
b.liu87afc4c2024-08-14 17:33:45 +080050fi
51
liubin207854f2023-07-19 17:25:29 +080052function build()
53{
54 cd mbtk
liubin281ac462023-07-19 14:22:54 +080055
liubin207854f2023-07-19 17:25:29 +080056 if [ -n "$1" ] ;then
57 case "$1" in
58 clean)
59 make clean
60 ;;
61 *)
b.liu8f67dfb2023-11-27 11:27:51 +080062# exit 1;;
63 make -C $1
liubin207854f2023-07-19 17:25:29 +080064 esac
65 else # 无参数
66 make || exit 1
67 fi
liubin281ac462023-07-19 14:22:54 +080068
liubin207854f2023-07-19 17:25:29 +080069 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080070
liubin207854f2023-07-19 17:25:29 +080071 echo "Build MBTK success."
72}
73
b.liube08cda2024-05-24 16:37:54 +080074function copy_bin_and_lib()
75{
76 # Copy All SO Files.
b.liu883991f2024-11-29 19:44:56 +080077# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
b.liube08cda2024-05-24 16:37:54 +080078 cp -f out/lib/* $1/lib
b.liu472cfaf2024-12-19 19:08:19 +080079
b.liube08cda2024-05-24 16:37:54 +080080 # Copy All Bin Files.
81 #cp -f out/bin/* $1/bin
82 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
83 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
b.liufc2bdb82024-11-30 17:24:34 +080084 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liube08cda2024-05-24 16:37:54 +080085 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
86 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
87 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
88 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
89 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
90 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
91 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
92 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
93 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +080094 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +080095 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +080096 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +080097 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
b.liu3bf26ca2024-12-23 19:03:57 +080098 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liu472cfaf2024-12-19 19:08:19 +080099
100
b.liuced8dd02024-06-28 13:28:29 +0800101 # Copy GNSS(5311) bin files.
102 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
103 [ -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 +0800104}
105
b.liu762260b2025-02-18 18:21:55 +0800106function copy_factory_files()
107{
108 # Copy All SO Files.
109# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
110 cp -f out/lib/* $1/lib
111
112 # Copy All Bin Files.
113 #cp -f out/bin/* $1/bin
114 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
115 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
116 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
117 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
118
119 # Copy GNSS(5311) bin files.
120 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
121 [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc
122}
123
liubin207854f2023-07-19 17:25:29 +0800124function file_copy()
125{
b.liuf678f992024-05-08 15:23:10 +0800126 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800127
128 if [ -d $ROOTFS_DIR ];then
129 echo "Copy MBTK out files..."
130 if [ ! -d $ROOTFS_DIR/bin ];then
131 mkdir $ROOTFS_DIR/bin
132 fi
133 if [ ! -d $ROOTFS_DIR/lib ];then
134 mkdir $ROOTFS_DIR/lib
135 fi
b.liu472cfaf2024-12-19 19:08:19 +0800136
b.liu762260b2025-02-18 18:21:55 +0800137 copy_factory_files $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800138 else
139 echo "No found rootfs : $ROOTFS_DIR"
140 fi
141}
142
b.liube08cda2024-05-24 16:37:54 +0800143function temp_mbtk_copy()
144{
145 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
146 if [ -d $TEMP_MBTK_DIR ];then
147 rm -rf $TEMP_MBTK_DIR
148 fi
b.liu472cfaf2024-12-19 19:08:19 +0800149
b.liube08cda2024-05-24 16:37:54 +0800150 mkdir -p $TEMP_MBTK_DIR/mbtk/include
151 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
152 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800153 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800154 mkdir -p $TEMP_MBTK_DIR/mbtk/test
b.liu472cfaf2024-12-19 19:08:19 +0800155
b.liube08cda2024-05-24 16:37:54 +0800156 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
b.liu472cfaf2024-12-19 19:08:19 +0800157
b.liube08cda2024-05-24 16:37:54 +0800158 # Copy include file.
159 if [ -d mbtk/include ];then
160 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
161 fi
b.liu472cfaf2024-12-19 19:08:19 +0800162
b.liube08cda2024-05-24 16:37:54 +0800163 # Copy test source.
164 if [ -d mbtk/test ];then
165 cope_file="mbtk/test/*"
166 files=$(ls $cope_file 2> /dev/null | wc -l)
167 if [ "$files" != "0" ] ;then #如果存在文件
168 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
169 fi
170 fi
171}
172
b.liuced8dd02024-06-28 13:28:29 +0800173function print_arg()
174{
b.liuced8dd02024-06-28 13:28:29 +0800175 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800176 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liu9f91db32025-02-13 11:24:18 +0800177# echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800178}
179
liubin207854f2023-07-19 17:25:29 +0800180function main()
181{
b.liu61eedc92024-11-13 16:07:00 +0800182 if [ ! -d out/lib ];then
183 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800184 fi
b.liu472cfaf2024-12-19 19:08:19 +0800185
b.liu61eedc92024-11-13 16:07:00 +0800186 if [ ! -d out/bin ];then
187 mkdir -p out/bin
188 fi
b.liu472cfaf2024-12-19 19:08:19 +0800189
b.liudeb8e422024-12-14 17:36:56 +0800190 if [ "$BUILD_LIBC_TEMP" == "musl" ];then
191 [ -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so ] && cp -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_musl.so mbtk/libmbtk_lib/wifi/libs/libwpa_client.so
192 else
193 [ -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so ] && cp -f mbtk/libmbtk_lib/wifi/libs/libwpa_client_glibc.so mbtk/libmbtk_lib/wifi/libs/libwpa_client.so
194 fi
b.liu61eedc92024-11-13 16:07:00 +0800195
196 if [ -n "$1" ] ;then
197 if [ "$1" == "v1" -o "$1" == "v2" ];then
198 build clean
b.liu472cfaf2024-12-19 19:08:19 +0800199
200
b.liu61eedc92024-11-13 16:07:00 +0800201 else
202 build $1
203 exit 0
204 fi
205 fi
b.liu472cfaf2024-12-19 19:08:19 +0800206
b.liu61eedc92024-11-13 16:07:00 +0800207 if [ ! -d out/lib ];then
208 mkdir -p out/lib
209 fi
b.liu472cfaf2024-12-19 19:08:19 +0800210
b.liu61eedc92024-11-13 16:07:00 +0800211 if [ ! -d out/bin ];then
212 mkdir -p out/bin
213 fi
214
215 build
b.liu472cfaf2024-12-19 19:08:19 +0800216
b.liu61eedc92024-11-13 16:07:00 +0800217 print_arg
218
219 file_copy
220
b.liube08cda2024-05-24 16:37:54 +0800221 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800222}
223
b.liuced8dd02024-06-28 13:28:29 +0800224# exit 1
225print_arg
226
227main $1