blob: 4943e9496009cfb14ceaa297d4315e6fd39fd9ef [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.liua76c9612025-03-28 13:58:09 +080099 [ -f out/bin/mbtk_otad ] && cp -f out/bin/mbtk_otad $1/bin
b.liu472cfaf2024-12-19 19:08:19 +0800100
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/..
b.liu6339dca2025-02-20 17:47:23 +0800116 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
117 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
b.liu762260b2025-02-18 18:21:55 +0800118 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
119 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
120
121 # Copy GNSS(5311) bin files.
122 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
123 [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc
124}
125
liubin207854f2023-07-19 17:25:29 +0800126function file_copy()
127{
b.liuf678f992024-05-08 15:23:10 +0800128 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800129
130 if [ -d $ROOTFS_DIR ];then
131 echo "Copy MBTK out files..."
132 if [ ! -d $ROOTFS_DIR/bin ];then
133 mkdir $ROOTFS_DIR/bin
134 fi
135 if [ ! -d $ROOTFS_DIR/lib ];then
136 mkdir $ROOTFS_DIR/lib
137 fi
b.liu472cfaf2024-12-19 19:08:19 +0800138
b.liu762260b2025-02-18 18:21:55 +0800139 copy_factory_files $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800140 else
141 echo "No found rootfs : $ROOTFS_DIR"
142 fi
143}
144
b.liube08cda2024-05-24 16:37:54 +0800145function temp_mbtk_copy()
146{
147 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
148 if [ -d $TEMP_MBTK_DIR ];then
149 rm -rf $TEMP_MBTK_DIR
150 fi
b.liu472cfaf2024-12-19 19:08:19 +0800151
b.liube08cda2024-05-24 16:37:54 +0800152 mkdir -p $TEMP_MBTK_DIR/mbtk/include
153 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
154 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800155 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800156 mkdir -p $TEMP_MBTK_DIR/mbtk/test
b.liu472cfaf2024-12-19 19:08:19 +0800157
b.liube08cda2024-05-24 16:37:54 +0800158 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
b.liu472cfaf2024-12-19 19:08:19 +0800159
b.liube08cda2024-05-24 16:37:54 +0800160 # Copy include file.
161 if [ -d mbtk/include ];then
162 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
163 fi
b.liu472cfaf2024-12-19 19:08:19 +0800164
b.liube08cda2024-05-24 16:37:54 +0800165 # Copy test source.
166 if [ -d mbtk/test ];then
167 cope_file="mbtk/test/*"
168 files=$(ls $cope_file 2> /dev/null | wc -l)
169 if [ "$files" != "0" ] ;then #如果存在文件
170 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
171 fi
172 fi
173}
174
b.liuced8dd02024-06-28 13:28:29 +0800175function print_arg()
176{
b.liuced8dd02024-06-28 13:28:29 +0800177 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800178 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liu9f91db32025-02-13 11:24:18 +0800179# echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800180}
181
liubin207854f2023-07-19 17:25:29 +0800182function main()
183{
b.liu61eedc92024-11-13 16:07:00 +0800184 if [ ! -d out/lib ];then
185 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800186 fi
b.liu472cfaf2024-12-19 19:08:19 +0800187
b.liu61eedc92024-11-13 16:07:00 +0800188 if [ ! -d out/bin ];then
189 mkdir -p out/bin
190 fi
b.liu472cfaf2024-12-19 19:08:19 +0800191
b.liudeb8e422024-12-14 17:36:56 +0800192 if [ "$BUILD_LIBC_TEMP" == "musl" ];then
193 [ -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
194 else
195 [ -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
196 fi
b.liu61eedc92024-11-13 16:07:00 +0800197
198 if [ -n "$1" ] ;then
199 if [ "$1" == "v1" -o "$1" == "v2" ];then
200 build clean
b.liu472cfaf2024-12-19 19:08:19 +0800201
202
b.liu61eedc92024-11-13 16:07:00 +0800203 else
204 build $1
205 exit 0
206 fi
207 fi
b.liu472cfaf2024-12-19 19:08:19 +0800208
b.liu61eedc92024-11-13 16:07:00 +0800209 if [ ! -d out/lib ];then
210 mkdir -p out/lib
211 fi
b.liu472cfaf2024-12-19 19:08:19 +0800212
b.liu61eedc92024-11-13 16:07:00 +0800213 if [ ! -d out/bin ];then
214 mkdir -p out/bin
215 fi
216
217 build
b.liu472cfaf2024-12-19 19:08:19 +0800218
b.liu61eedc92024-11-13 16:07:00 +0800219 print_arg
220
221 file_copy
222
b.liube08cda2024-05-24 16:37:54 +0800223 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800224}
225
b.liuced8dd02024-06-28 13:28:29 +0800226# exit 1
227print_arg
228
229main $1