blob: 3c6b547704431d99e6e7e4651871e1ab29370425 [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.liua6a2bd12025-08-14 12:14:58 +08008if [ ! -d ~/openwrt_toolchains ];then
9 echo "Start download toolchains."
10 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/
11fi
12
b.liu17d7f8b2023-10-08 16:57:59 +080013# static / shared
14export BUILD_LIB_TYPE=shared
b.liu450e3992024-10-10 10:59:29 +080015
16export STAGING_DIR=
b.liu17d7f8b2023-10-08 16:57:59 +080017
b.liu5d5b8ba2024-02-20 14:00:33 +080018ROOT_DIR=`pwd`
19
b.liuced8dd02024-06-28 13:28:29 +080020BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2`
21if [ "$BUILD_LIBC_TEMP" == "musl" ];then
22 export BUILD_STD_LIBC=musl
23else
24 export BUILD_STD_LIBC=glibc
25fi
b.liuf37bd332024-03-18 13:51:24 +080026
b.liudeb8e422024-12-14 17:36:56 +080027export BUILD_GCC_VERSION=`cat config | grep CONFIG_GCC_VERSION | cut -d '=' -f 2`
28
b.liu9f91db32025-02-13 11:24:18 +080029#export MBTK_DEV_INFO_VERSION=`cat config | grep CONFIG_DEV_INFO_VERSION | cut -d '=' -f 2`
b.liu61ad9172025-01-09 14:33:55 +080030export CONFIG_MBTK_5G_SUPPORT=`cat config | grep CONFIG_MBTK_5G_SUPPORT | cut -d '=' -f 2`
b.liu472cfaf2024-12-19 19:08:19 +080031
b.liu61eedc92024-11-13 16:07:00 +080032if [ -n "$1" ] ;then
33 case "$1" in
34 v1)
35 export MBTK_SOURCE_VERSION=1
36 ;;
37 v2)
38 export MBTK_SOURCE_VERSION=2
39 ;;
40 *)
41 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
42 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
43 export MBTK_SOURCE_VERSION=2
44 else
45 export MBTK_SOURCE_VERSION=1
46 fi
47 esac
b.liu87afc4c2024-08-14 17:33:45 +080048else
b.liu61eedc92024-11-13 16:07:00 +080049 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
50 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
51 export MBTK_SOURCE_VERSION=2
52 else
53 export MBTK_SOURCE_VERSION=1
54 fi
b.liu87afc4c2024-08-14 17:33:45 +080055fi
56
liubin207854f2023-07-19 17:25:29 +080057function build()
58{
59 cd mbtk
liubin281ac462023-07-19 14:22:54 +080060
liubin207854f2023-07-19 17:25:29 +080061 if [ -n "$1" ] ;then
62 case "$1" in
63 clean)
64 make clean
65 ;;
66 *)
b.liu8f67dfb2023-11-27 11:27:51 +080067# exit 1;;
68 make -C $1
liubin207854f2023-07-19 17:25:29 +080069 esac
70 else # 无参数
71 make || exit 1
72 fi
liubin281ac462023-07-19 14:22:54 +080073
liubin207854f2023-07-19 17:25:29 +080074 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080075
liubin207854f2023-07-19 17:25:29 +080076 echo "Build MBTK success."
77}
78
b.liube08cda2024-05-24 16:37:54 +080079function copy_bin_and_lib()
80{
81 # Copy All SO Files.
b.liu883991f2024-11-29 19:44:56 +080082# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
b.liube08cda2024-05-24 16:37:54 +080083 cp -f out/lib/* $1/lib
b.liu472cfaf2024-12-19 19:08:19 +080084
b.liube08cda2024-05-24 16:37:54 +080085 # Copy All Bin Files.
86 #cp -f out/bin/* $1/bin
87 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
88 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
b.liufc2bdb82024-11-30 17:24:34 +080089 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liube08cda2024-05-24 16:37:54 +080090 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
91 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
92 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
93 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
94 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
95 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
96 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
97 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
98 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +080099 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +0800100 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +0800101 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +0800102 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
b.liu3bf26ca2024-12-23 19:03:57 +0800103 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liua76c9612025-03-28 13:58:09 +0800104 [ -f out/bin/mbtk_otad ] && cp -f out/bin/mbtk_otad $1/bin
b.liu472cfaf2024-12-19 19:08:19 +0800105
b.liuced8dd02024-06-28 13:28:29 +0800106 # Copy GNSS(5311) bin files.
107 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
108 [ -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 +0800109}
110
b.liu762260b2025-02-18 18:21:55 +0800111function copy_factory_files()
112{
113 # Copy All SO Files.
114# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
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/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
b.liu6339dca2025-02-20 17:47:23 +0800121 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
122 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
b.liu762260b2025-02-18 18:21:55 +0800123 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
124 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
125
126 # Copy GNSS(5311) bin files.
127 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
128 [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc
129}
130
liubin207854f2023-07-19 17:25:29 +0800131function file_copy()
132{
b.liuf678f992024-05-08 15:23:10 +0800133 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800134
135 if [ -d $ROOTFS_DIR ];then
136 echo "Copy MBTK out files..."
137 if [ ! -d $ROOTFS_DIR/bin ];then
138 mkdir $ROOTFS_DIR/bin
139 fi
140 if [ ! -d $ROOTFS_DIR/lib ];then
141 mkdir $ROOTFS_DIR/lib
142 fi
b.liu472cfaf2024-12-19 19:08:19 +0800143
b.liu762260b2025-02-18 18:21:55 +0800144 copy_factory_files $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800145 else
146 echo "No found rootfs : $ROOTFS_DIR"
147 fi
148}
149
b.liube08cda2024-05-24 16:37:54 +0800150function temp_mbtk_copy()
151{
152 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
153 if [ -d $TEMP_MBTK_DIR ];then
154 rm -rf $TEMP_MBTK_DIR
155 fi
b.liu472cfaf2024-12-19 19:08:19 +0800156
b.liube08cda2024-05-24 16:37:54 +0800157 mkdir -p $TEMP_MBTK_DIR/mbtk/include
158 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
159 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800160 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800161 mkdir -p $TEMP_MBTK_DIR/mbtk/test
b.liu472cfaf2024-12-19 19:08:19 +0800162
b.liube08cda2024-05-24 16:37:54 +0800163 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
b.liu472cfaf2024-12-19 19:08:19 +0800164
b.liube08cda2024-05-24 16:37:54 +0800165 # Copy include file.
166 if [ -d mbtk/include ];then
167 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
168 fi
b.liu472cfaf2024-12-19 19:08:19 +0800169
b.liube08cda2024-05-24 16:37:54 +0800170 # Copy test source.
171 if [ -d mbtk/test ];then
172 cope_file="mbtk/test/*"
173 files=$(ls $cope_file 2> /dev/null | wc -l)
174 if [ "$files" != "0" ] ;then #如果存在文件
175 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
176 fi
177 fi
178}
179
b.liuced8dd02024-06-28 13:28:29 +0800180function print_arg()
181{
b.liuced8dd02024-06-28 13:28:29 +0800182 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800183 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liu9f91db32025-02-13 11:24:18 +0800184# echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800185}
186
liubin207854f2023-07-19 17:25:29 +0800187function main()
188{
b.liu61eedc92024-11-13 16:07:00 +0800189 if [ ! -d out/lib ];then
190 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800191 fi
b.liu472cfaf2024-12-19 19:08:19 +0800192
b.liu61eedc92024-11-13 16:07:00 +0800193 if [ ! -d out/bin ];then
194 mkdir -p out/bin
195 fi
b.liu472cfaf2024-12-19 19:08:19 +0800196
b.liudeb8e422024-12-14 17:36:56 +0800197 if [ "$BUILD_LIBC_TEMP" == "musl" ];then
198 [ -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
199 else
200 [ -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
201 fi
b.liu61eedc92024-11-13 16:07:00 +0800202
203 if [ -n "$1" ] ;then
204 if [ "$1" == "v1" -o "$1" == "v2" ];then
205 build clean
b.liu472cfaf2024-12-19 19:08:19 +0800206
207
b.liu61eedc92024-11-13 16:07:00 +0800208 else
209 build $1
210 exit 0
211 fi
212 fi
b.liu472cfaf2024-12-19 19:08:19 +0800213
b.liu61eedc92024-11-13 16:07:00 +0800214 if [ ! -d out/lib ];then
215 mkdir -p out/lib
216 fi
b.liu472cfaf2024-12-19 19:08:19 +0800217
b.liu61eedc92024-11-13 16:07:00 +0800218 if [ ! -d out/bin ];then
219 mkdir -p out/bin
220 fi
221
222 build
b.liu472cfaf2024-12-19 19:08:19 +0800223
b.liu61eedc92024-11-13 16:07:00 +0800224 print_arg
225
226 file_copy
227
b.liube08cda2024-05-24 16:37:54 +0800228 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800229}
230
b.liuced8dd02024-06-28 13:28:29 +0800231# exit 1
232print_arg
233
234main $1