blob: 30a04148a38bb7699bf4c43889d679078b5d8d97 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001#!/bin/bash
2
b.liu17d7f8b2023-10-08 16:57:59 +08003# static / shared
4export BUILD_LIB_TYPE=shared
b.liu450e3992024-10-10 10:59:29 +08005
6export STAGING_DIR=
b.liu17d7f8b2023-10-08 16:57:59 +08007
b.liu5d5b8ba2024-02-20 14:00:33 +08008ROOT_DIR=`pwd`
9
b.liuced8dd02024-06-28 13:28:29 +080010BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2`
11if [ "$BUILD_LIBC_TEMP" == "musl" ];then
12 export BUILD_STD_LIBC=musl
13else
14 export BUILD_STD_LIBC=glibc
15fi
b.liuf37bd332024-03-18 13:51:24 +080016
b.liu61eedc92024-11-13 16:07:00 +080017if [ -n "$1" ] ;then
18 case "$1" in
19 v1)
20 export MBTK_SOURCE_VERSION=1
21 ;;
22 v2)
23 export MBTK_SOURCE_VERSION=2
24 ;;
25 *)
26 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
27 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
28 export MBTK_SOURCE_VERSION=2
29 else
30 export MBTK_SOURCE_VERSION=1
31 fi
32 esac
b.liu87afc4c2024-08-14 17:33:45 +080033else
b.liu61eedc92024-11-13 16:07:00 +080034 MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
35 if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
36 export MBTK_SOURCE_VERSION=2
37 else
38 export MBTK_SOURCE_VERSION=1
39 fi
b.liu87afc4c2024-08-14 17:33:45 +080040fi
41
liubin207854f2023-07-19 17:25:29 +080042function build()
43{
44 cd mbtk
liubin281ac462023-07-19 14:22:54 +080045
liubin207854f2023-07-19 17:25:29 +080046 if [ -n "$1" ] ;then
47 case "$1" in
48 clean)
49 make clean
50 ;;
51 *)
b.liu8f67dfb2023-11-27 11:27:51 +080052# exit 1;;
53 make -C $1
liubin207854f2023-07-19 17:25:29 +080054 esac
55 else # 无参数
56 make || exit 1
57 fi
liubin281ac462023-07-19 14:22:54 +080058
liubin207854f2023-07-19 17:25:29 +080059 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080060
liubin207854f2023-07-19 17:25:29 +080061 echo "Build MBTK success."
62}
63
b.liube08cda2024-05-24 16:37:54 +080064function copy_bin_and_lib()
65{
66 # Copy All SO Files.
b.liu883991f2024-11-29 19:44:56 +080067# cp -f mbtk/libmbtk_lib/wifi/libs out/lib
b.liube08cda2024-05-24 16:37:54 +080068 cp -f out/lib/* $1/lib
69
70 # Copy All Bin Files.
71 #cp -f out/bin/* $1/bin
72 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
73 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
b.liufc2bdb82024-11-30 17:24:34 +080074 [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin
b.liube08cda2024-05-24 16:37:54 +080075 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
76 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
77 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
78 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
79 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
80 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
81 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
82 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
83 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +080084 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +080085 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +080086 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +080087 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
88
89
90 # Copy GNSS(5311) bin files.
91 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
92 [ -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 +080093}
94
liubin207854f2023-07-19 17:25:29 +080095function file_copy()
96{
b.liuf678f992024-05-08 15:23:10 +080097 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +080098
99 if [ -d $ROOTFS_DIR ];then
100 echo "Copy MBTK out files..."
101 if [ ! -d $ROOTFS_DIR/bin ];then
102 mkdir $ROOTFS_DIR/bin
103 fi
104 if [ ! -d $ROOTFS_DIR/lib ];then
105 mkdir $ROOTFS_DIR/lib
106 fi
b.liube08cda2024-05-24 16:37:54 +0800107
108 copy_bin_and_lib $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800109 else
110 echo "No found rootfs : $ROOTFS_DIR"
111 fi
112}
113
b.liube08cda2024-05-24 16:37:54 +0800114function temp_mbtk_copy()
115{
116 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
117 if [ -d $TEMP_MBTK_DIR ];then
118 rm -rf $TEMP_MBTK_DIR
119 fi
120
121 mkdir -p $TEMP_MBTK_DIR/mbtk/include
122 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
123 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800124 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800125 mkdir -p $TEMP_MBTK_DIR/mbtk/test
126
127 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
128
129 # Copy include file.
130 if [ -d mbtk/include ];then
131 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
132 fi
133
134 # Copy test source.
135 if [ -d mbtk/test ];then
136 cope_file="mbtk/test/*"
137 files=$(ls $cope_file 2> /dev/null | wc -l)
138 if [ "$files" != "0" ] ;then #如果存在文件
139 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
140 fi
141 fi
142}
143
b.liuced8dd02024-06-28 13:28:29 +0800144function print_arg()
145{
b.liuced8dd02024-06-28 13:28:29 +0800146 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800147 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800148}
149
liubin207854f2023-07-19 17:25:29 +0800150function main()
151{
b.liu61eedc92024-11-13 16:07:00 +0800152 if [ ! -d out/lib ];then
153 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800154 fi
b.liube08cda2024-05-24 16:37:54 +0800155
b.liu61eedc92024-11-13 16:07:00 +0800156 if [ ! -d out/bin ];then
157 mkdir -p out/bin
158 fi
159
160 if [ -n "$1" ] ;then
161 if [ "$1" == "v1" -o "$1" == "v2" ];then
162 build clean
163
164
165 else
166 build $1
167 exit 0
168 fi
169 fi
170
171 if [ ! -d out/lib ];then
172 mkdir -p out/lib
173 fi
174
175 if [ ! -d out/bin ];then
176 mkdir -p out/bin
177 fi
178
179 build
180
181 print_arg
182
183 file_copy
184
b.liube08cda2024-05-24 16:37:54 +0800185 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800186}
187
b.liuced8dd02024-06-28 13:28:29 +0800188# exit 1
189print_arg
190
191main $1