blob: 96a6346f7b76ce7795c8b8a0c238a642bd0a2c10 [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
74 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
75 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
76 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
77 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
78 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
79 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
80 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
81 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
82 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +080083 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +080084 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +080085 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +080086 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
87
88
89 # Copy GNSS(5311) bin files.
90 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
91 [ -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 +080092}
93
liubin207854f2023-07-19 17:25:29 +080094function file_copy()
95{
b.liuf678f992024-05-08 15:23:10 +080096 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +080097
98 if [ -d $ROOTFS_DIR ];then
99 echo "Copy MBTK out files..."
100 if [ ! -d $ROOTFS_DIR/bin ];then
101 mkdir $ROOTFS_DIR/bin
102 fi
103 if [ ! -d $ROOTFS_DIR/lib ];then
104 mkdir $ROOTFS_DIR/lib
105 fi
b.liube08cda2024-05-24 16:37:54 +0800106
107 copy_bin_and_lib $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800108 else
109 echo "No found rootfs : $ROOTFS_DIR"
110 fi
111}
112
b.liube08cda2024-05-24 16:37:54 +0800113function temp_mbtk_copy()
114{
115 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
116 if [ -d $TEMP_MBTK_DIR ];then
117 rm -rf $TEMP_MBTK_DIR
118 fi
119
120 mkdir -p $TEMP_MBTK_DIR/mbtk/include
121 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
122 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800123 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800124 mkdir -p $TEMP_MBTK_DIR/mbtk/test
125
126 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
127
128 # Copy include file.
129 if [ -d mbtk/include ];then
130 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
131 fi
132
133 # Copy test source.
134 if [ -d mbtk/test ];then
135 cope_file="mbtk/test/*"
136 files=$(ls $cope_file 2> /dev/null | wc -l)
137 if [ "$files" != "0" ] ;then #如果存在文件
138 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
139 fi
140 fi
141}
142
b.liuced8dd02024-06-28 13:28:29 +0800143function print_arg()
144{
b.liuced8dd02024-06-28 13:28:29 +0800145 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800146 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800147}
148
liubin207854f2023-07-19 17:25:29 +0800149function main()
150{
b.liu61eedc92024-11-13 16:07:00 +0800151 if [ ! -d out/lib ];then
152 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800153 fi
b.liube08cda2024-05-24 16:37:54 +0800154
b.liu61eedc92024-11-13 16:07:00 +0800155 if [ ! -d out/bin ];then
156 mkdir -p out/bin
157 fi
158
159 if [ -n "$1" ] ;then
160 if [ "$1" == "v1" -o "$1" == "v2" ];then
161 build clean
162
163
164 else
165 build $1
166 exit 0
167 fi
168 fi
169
170 if [ ! -d out/lib ];then
171 mkdir -p out/lib
172 fi
173
174 if [ ! -d out/bin ];then
175 mkdir -p out/bin
176 fi
177
178 build
179
180 print_arg
181
182 file_copy
183
b.liube08cda2024-05-24 16:37:54 +0800184 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800185}
186
b.liuced8dd02024-06-28 13:28:29 +0800187# exit 1
188print_arg
189
190main $1