blob: a8fbe058010bd72051a89af1325d94b1b06198b0 [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.liu472cfaf2024-12-19 19:08:19 +080024export MBTK_DEV_INFO_VERSION=`cat config | grep CONFIG_DEV_INFO_VERSION | cut -d '=' -f 2`
25
b.liu61eedc92024-11-13 16:07:00 +080026if [ -n "$1" ] ;then
27 case "$1" in
28 v1)
29 export MBTK_SOURCE_VERSION=1
30 ;;
31 v2)
32 export MBTK_SOURCE_VERSION=2
33 ;;
34 *)
35 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
36 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
37 export MBTK_SOURCE_VERSION=2
38 else
39 export MBTK_SOURCE_VERSION=1
40 fi
41 esac
b.liu87afc4c2024-08-14 17:33:45 +080042else
b.liu61eedc92024-11-13 16:07:00 +080043 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
44 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
45 export MBTK_SOURCE_VERSION=2
46 else
47 export MBTK_SOURCE_VERSION=1
48 fi
b.liu87afc4c2024-08-14 17:33:45 +080049fi
50
liubin207854f2023-07-19 17:25:29 +080051function build()
52{
53 cd mbtk
liubin281ac462023-07-19 14:22:54 +080054
liubin207854f2023-07-19 17:25:29 +080055 if [ -n "$1" ] ;then
56 case "$1" in
57 clean)
58 make clean
59 ;;
60 *)
b.liu8f67dfb2023-11-27 11:27:51 +080061# exit 1;;
62 make -C $1
liubin207854f2023-07-19 17:25:29 +080063 esac
64 else # 无参数
65 make || exit 1
66 fi
liubin281ac462023-07-19 14:22:54 +080067
liubin207854f2023-07-19 17:25:29 +080068 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080069
liubin207854f2023-07-19 17:25:29 +080070 echo "Build MBTK success."
71}
72
b.liube08cda2024-05-24 16:37:54 +080073function copy_bin_and_lib()
74{
75 # Copy All SO Files.
b.liu883991f2024-11-29 19:44:56 +080076# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
b.liube08cda2024-05-24 16:37:54 +080077 cp -f out/lib/* $1/lib
b.liu472cfaf2024-12-19 19:08:19 +080078
b.liube08cda2024-05-24 16:37:54 +080079 # Copy All Bin Files.
80 #cp -f out/bin/* $1/bin
81 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
82 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
b.liufc2bdb82024-11-30 17:24:34 +080083 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liube08cda2024-05-24 16:37:54 +080084 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
85 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
86 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
87 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
88 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
89 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
90 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
91 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
92 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +080093 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +080094 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +080095 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +080096 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
b.liu472cfaf2024-12-19 19:08:19 +080097
98
b.liuced8dd02024-06-28 13:28:29 +080099 # Copy GNSS(5311) bin files.
100 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
101 [ -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 +0800102}
103
liubin207854f2023-07-19 17:25:29 +0800104function file_copy()
105{
b.liuf678f992024-05-08 15:23:10 +0800106 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +0800107
108 if [ -d $ROOTFS_DIR ];then
109 echo "Copy MBTK out files..."
110 if [ ! -d $ROOTFS_DIR/bin ];then
111 mkdir $ROOTFS_DIR/bin
112 fi
113 if [ ! -d $ROOTFS_DIR/lib ];then
114 mkdir $ROOTFS_DIR/lib
115 fi
b.liu472cfaf2024-12-19 19:08:19 +0800116
b.liube08cda2024-05-24 16:37:54 +0800117 copy_bin_and_lib $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800118 else
119 echo "No found rootfs : $ROOTFS_DIR"
120 fi
121}
122
b.liube08cda2024-05-24 16:37:54 +0800123function temp_mbtk_copy()
124{
125 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
126 if [ -d $TEMP_MBTK_DIR ];then
127 rm -rf $TEMP_MBTK_DIR
128 fi
b.liu472cfaf2024-12-19 19:08:19 +0800129
b.liube08cda2024-05-24 16:37:54 +0800130 mkdir -p $TEMP_MBTK_DIR/mbtk/include
131 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
132 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800133 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800134 mkdir -p $TEMP_MBTK_DIR/mbtk/test
b.liu472cfaf2024-12-19 19:08:19 +0800135
b.liube08cda2024-05-24 16:37:54 +0800136 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
b.liu472cfaf2024-12-19 19:08:19 +0800137
b.liube08cda2024-05-24 16:37:54 +0800138 # Copy include file.
139 if [ -d mbtk/include ];then
140 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
141 fi
b.liu472cfaf2024-12-19 19:08:19 +0800142
b.liube08cda2024-05-24 16:37:54 +0800143 # Copy test source.
144 if [ -d mbtk/test ];then
145 cope_file="mbtk/test/*"
146 files=$(ls $cope_file 2> /dev/null | wc -l)
147 if [ "$files" != "0" ] ;then #如果存在文件
148 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
149 fi
150 fi
151}
152
b.liuced8dd02024-06-28 13:28:29 +0800153function print_arg()
154{
b.liuced8dd02024-06-28 13:28:29 +0800155 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800156 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liu472cfaf2024-12-19 19:08:19 +0800157 echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800158}
159
liubin207854f2023-07-19 17:25:29 +0800160function main()
161{
b.liu61eedc92024-11-13 16:07:00 +0800162 if [ ! -d out/lib ];then
163 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800164 fi
b.liu472cfaf2024-12-19 19:08:19 +0800165
b.liu61eedc92024-11-13 16:07:00 +0800166 if [ ! -d out/bin ];then
167 mkdir -p out/bin
168 fi
b.liu472cfaf2024-12-19 19:08:19 +0800169
b.liudeb8e422024-12-14 17:36:56 +0800170 if [ "$BUILD_LIBC_TEMP" == "musl" ];then
171 [ -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
172 else
173 [ -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
174 fi
b.liu61eedc92024-11-13 16:07:00 +0800175
176 if [ -n "$1" ] ;then
177 if [ "$1" == "v1" -o "$1" == "v2" ];then
178 build clean
b.liu472cfaf2024-12-19 19:08:19 +0800179
180
b.liu61eedc92024-11-13 16:07:00 +0800181 else
182 build $1
183 exit 0
184 fi
185 fi
b.liu472cfaf2024-12-19 19:08:19 +0800186
b.liu61eedc92024-11-13 16:07:00 +0800187 if [ ! -d out/lib ];then
188 mkdir -p out/lib
189 fi
b.liu472cfaf2024-12-19 19:08:19 +0800190
b.liu61eedc92024-11-13 16:07:00 +0800191 if [ ! -d out/bin ];then
192 mkdir -p out/bin
193 fi
194
195 build
b.liu472cfaf2024-12-19 19:08:19 +0800196
b.liu61eedc92024-11-13 16:07:00 +0800197 print_arg
198
199 file_copy
200
b.liube08cda2024-05-24 16:37:54 +0800201 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800202}
203
b.liuced8dd02024-06-28 13:28:29 +0800204# exit 1
205print_arg
206
207main $1