blob: c0bc5913be5e3c3ea13a15708679bb76230b2783 [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.liua35c3332025-08-15 21:07:02 +08008function mbtk_toolchain_download()
9{
10 MBTK_TOOLCHAIN_DIR=~/openwrt_toolchains
11
12 # git clone "ssh://b.liu@192.168.1.198:29418/ASR1803_openwrt_mbtk_source" mbtk_source && scp -p -P 29418 b.liu@192.168.1.198:hooks/commit-msg "mbtk_source/.git/hooks/"
13 GIT_URL=`grep "url" .git/config | cut -d " " -f 3 | \
14 sed "s/ASR1803_openwrt_mbtk_source/mbtk_toolchains_for_asr_linux/"`
15
16 GIT_IP=`echo $GIT_URL | cut -d ":" -f 2`
17 GIT_IP=${GIT_IP: 2}
18 GIT_PORT=`echo $GIT_URL | cut -d "/" -f 3 | cut -d ":" -f 2`
19
20 if [ ! -d $MBTK_TOOLCHAIN_DIR ];then
21 echo "Start download toolchains."
22 # git clone "ssh://b.liu@192.168.1.198:29418/mbtk_toolchains_for_asr_linux" ~/openwrt_toolchains && scp -p -P 29418 b.liu@192.168.1.198:hooks/commit-msg ~/openwrt_toolchains/.git/hooks/
23 git clone "$GIT_URL" $MBTK_TOOLCHAIN_DIR && scp -p -P $GIT_PORT $GIT_IP:hooks/commit-msg "$MBTK_TOOLCHAIN_DIR/.git/hooks/"
24 fi
25}
26
27mbtk_toolchain_download
b.liua6a2bd12025-08-14 12:14:58 +080028
b.liu17d7f8b2023-10-08 16:57:59 +080029# static / shared
30export BUILD_LIB_TYPE=shared
b.liu450e3992024-10-10 10:59:29 +080031
32export STAGING_DIR=
b.liu17d7f8b2023-10-08 16:57:59 +080033
b.liu5d5b8ba2024-02-20 14:00:33 +080034ROOT_DIR=`pwd`
35
b.liuced8dd02024-06-28 13:28:29 +080036BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2`
37if [ "$BUILD_LIBC_TEMP" == "musl" ];then
38 export BUILD_STD_LIBC=musl
39else
40 export BUILD_STD_LIBC=glibc
41fi
b.liuf37bd332024-03-18 13:51:24 +080042
b.liudeb8e422024-12-14 17:36:56 +080043export BUILD_GCC_VERSION=`cat config | grep CONFIG_GCC_VERSION | cut -d '=' -f 2`
44
b.liu9f91db32025-02-13 11:24:18 +080045#export MBTK_DEV_INFO_VERSION=`cat config | grep CONFIG_DEV_INFO_VERSION | cut -d '=' -f 2`
b.liu61ad9172025-01-09 14:33:55 +080046export CONFIG_MBTK_5G_SUPPORT=`cat config | grep CONFIG_MBTK_5G_SUPPORT | cut -d '=' -f 2`
b.liu472cfaf2024-12-19 19:08:19 +080047
b.liu61eedc92024-11-13 16:07:00 +080048if [ -n "$1" ] ;then
49 case "$1" in
50 v1)
51 export MBTK_SOURCE_VERSION=1
52 ;;
53 v2)
54 export MBTK_SOURCE_VERSION=2
55 ;;
56 *)
57 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
58 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
59 export MBTK_SOURCE_VERSION=2
60 else
61 export MBTK_SOURCE_VERSION=1
62 fi
63 esac
b.liu87afc4c2024-08-14 17:33:45 +080064else
b.liu61eedc92024-11-13 16:07:00 +080065 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
66 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
67 export MBTK_SOURCE_VERSION=2
68 else
69 export MBTK_SOURCE_VERSION=1
70 fi
b.liu87afc4c2024-08-14 17:33:45 +080071fi
72
liubin207854f2023-07-19 17:25:29 +080073function build()
74{
75 cd mbtk
liubin281ac462023-07-19 14:22:54 +080076
liubin207854f2023-07-19 17:25:29 +080077 if [ -n "$1" ] ;then
78 case "$1" in
79 clean)
80 make clean
81 ;;
82 *)
b.liu8f67dfb2023-11-27 11:27:51 +080083# exit 1;;
84 make -C $1
liubin207854f2023-07-19 17:25:29 +080085 esac
86 else # 无参数
87 make || exit 1
88 fi
liubin281ac462023-07-19 14:22:54 +080089
liubin207854f2023-07-19 17:25:29 +080090 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080091
liubin207854f2023-07-19 17:25:29 +080092 echo "Build MBTK success."
93}
94
b.liube08cda2024-05-24 16:37:54 +080095function copy_bin_and_lib()
96{
97 # Copy All SO Files.
b.liu883991f2024-11-29 19:44:56 +080098# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
b.liube08cda2024-05-24 16:37:54 +080099 cp -f out/lib/* $1/lib
b.liu472cfaf2024-12-19 19:08:19 +0800100
b.liube08cda2024-05-24 16:37:54 +0800101 # Copy All Bin Files.
102 #cp -f out/bin/* $1/bin
103 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
104 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
b.liufc2bdb82024-11-30 17:24:34 +0800105 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liube08cda2024-05-24 16:37:54 +0800106 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
107 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
108 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
109 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
110 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
111 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
112 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
113 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
114 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +0800115 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +0800116 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +0800117 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +0800118 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
b.liu3bf26ca2024-12-23 19:03:57 +0800119 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liua76c9612025-03-28 13:58:09 +0800120 [ -f out/bin/mbtk_otad ] && cp -f out/bin/mbtk_otad $1/bin
b.liu472cfaf2024-12-19 19:08:19 +0800121
b.liuced8dd02024-06-28 13:28:29 +0800122 # Copy GNSS(5311) bin files.
123 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
124 [ -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 +0800125}
126
b.liu762260b2025-02-18 18:21:55 +0800127function copy_factory_files()
128{
129 # Copy All SO Files.
130# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
131 cp -f out/lib/* $1/lib
132
133 # Copy All Bin Files.
134 #cp -f out/bin/* $1/bin
135 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
136 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
b.liu6339dca2025-02-20 17:47:23 +0800137 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
138 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
b.liu762260b2025-02-18 18:21:55 +0800139 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
140 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
141
142 # Copy GNSS(5311) bin files.
143 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
144 [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc
145}
146
liubin207854f2023-07-19 17:25:29 +0800147function file_copy()
148{
b.liuf678f992024-05-08 15:23:10 +0800149 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800150
151 if [ -d $ROOTFS_DIR ];then
152 echo "Copy MBTK out files..."
153 if [ ! -d $ROOTFS_DIR/bin ];then
154 mkdir $ROOTFS_DIR/bin
155 fi
156 if [ ! -d $ROOTFS_DIR/lib ];then
157 mkdir $ROOTFS_DIR/lib
158 fi
b.liu472cfaf2024-12-19 19:08:19 +0800159
b.liu762260b2025-02-18 18:21:55 +0800160 copy_factory_files $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800161 else
162 echo "No found rootfs : $ROOTFS_DIR"
163 fi
164}
165
b.liube08cda2024-05-24 16:37:54 +0800166function temp_mbtk_copy()
167{
168 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
169 if [ -d $TEMP_MBTK_DIR ];then
170 rm -rf $TEMP_MBTK_DIR
171 fi
b.liu472cfaf2024-12-19 19:08:19 +0800172
b.liube08cda2024-05-24 16:37:54 +0800173 mkdir -p $TEMP_MBTK_DIR/mbtk/include
174 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
175 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800176 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800177 mkdir -p $TEMP_MBTK_DIR/mbtk/test
b.liu472cfaf2024-12-19 19:08:19 +0800178
b.liube08cda2024-05-24 16:37:54 +0800179 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
b.liu472cfaf2024-12-19 19:08:19 +0800180
b.liube08cda2024-05-24 16:37:54 +0800181 # Copy include file.
182 if [ -d mbtk/include ];then
183 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
184 fi
b.liu472cfaf2024-12-19 19:08:19 +0800185
b.liube08cda2024-05-24 16:37:54 +0800186 # Copy test source.
187 if [ -d mbtk/test ];then
188 cope_file="mbtk/test/*"
189 files=$(ls $cope_file 2> /dev/null | wc -l)
190 if [ "$files" != "0" ] ;then #如果存在文件
191 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
192 fi
193 fi
194}
195
b.liuced8dd02024-06-28 13:28:29 +0800196function print_arg()
197{
b.liuced8dd02024-06-28 13:28:29 +0800198 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800199 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liu9f91db32025-02-13 11:24:18 +0800200# echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800201}
202
liubin207854f2023-07-19 17:25:29 +0800203function main()
204{
b.liu61eedc92024-11-13 16:07:00 +0800205 if [ ! -d out/lib ];then
206 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800207 fi
b.liu472cfaf2024-12-19 19:08:19 +0800208
b.liu61eedc92024-11-13 16:07:00 +0800209 if [ ! -d out/bin ];then
210 mkdir -p out/bin
211 fi
b.liu472cfaf2024-12-19 19:08:19 +0800212
b.liudeb8e422024-12-14 17:36:56 +0800213 if [ "$BUILD_LIBC_TEMP" == "musl" ];then
214 [ -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
215 else
216 [ -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
217 fi
b.liu61eedc92024-11-13 16:07:00 +0800218
219 if [ -n "$1" ] ;then
220 if [ "$1" == "v1" -o "$1" == "v2" ];then
221 build clean
b.liu472cfaf2024-12-19 19:08:19 +0800222
223
b.liu61eedc92024-11-13 16:07:00 +0800224 else
225 build $1
226 exit 0
227 fi
228 fi
b.liu472cfaf2024-12-19 19:08:19 +0800229
b.liu61eedc92024-11-13 16:07:00 +0800230 if [ ! -d out/lib ];then
231 mkdir -p out/lib
232 fi
b.liu472cfaf2024-12-19 19:08:19 +0800233
b.liu61eedc92024-11-13 16:07:00 +0800234 if [ ! -d out/bin ];then
235 mkdir -p out/bin
236 fi
237
238 build
b.liu472cfaf2024-12-19 19:08:19 +0800239
b.liu61eedc92024-11-13 16:07:00 +0800240 print_arg
241
242 file_copy
243
b.liube08cda2024-05-24 16:37:54 +0800244 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800245}
246
b.liuced8dd02024-06-28 13:28:29 +0800247# exit 1
248print_arg
249
250main $1