blob: 6a65bd49076311fba4dd69f18e592628c4220bae [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.
67 cp -f out/lib/* $1/lib
68
69 # Copy All Bin Files.
70 #cp -f out/bin/* $1/bin
71 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
72 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
73 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
74 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
75 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
76 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
77 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
78 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
79 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
80 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
81 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +080082 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +080083 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +080084 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +080085 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
86
87
88 # Copy GNSS(5311) bin files.
89 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
90 [ -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 +080091}
92
liubin207854f2023-07-19 17:25:29 +080093function file_copy()
94{
b.liuf678f992024-05-08 15:23:10 +080095 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +080096
97 if [ -d $ROOTFS_DIR ];then
98 echo "Copy MBTK out files..."
99 if [ ! -d $ROOTFS_DIR/bin ];then
100 mkdir $ROOTFS_DIR/bin
101 fi
102 if [ ! -d $ROOTFS_DIR/lib ];then
103 mkdir $ROOTFS_DIR/lib
104 fi
b.liube08cda2024-05-24 16:37:54 +0800105
106 copy_bin_and_lib $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +0800107 else
108 echo "No found rootfs : $ROOTFS_DIR"
109 fi
110}
111
b.liube08cda2024-05-24 16:37:54 +0800112function temp_mbtk_copy()
113{
114 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
115 if [ -d $TEMP_MBTK_DIR ];then
116 rm -rf $TEMP_MBTK_DIR
117 fi
118
119 mkdir -p $TEMP_MBTK_DIR/mbtk/include
120 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
121 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800122 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800123 mkdir -p $TEMP_MBTK_DIR/mbtk/test
124
125 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
126
127 # Copy include file.
128 if [ -d mbtk/include ];then
129 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
130 fi
131
132 # Copy test source.
133 if [ -d mbtk/test ];then
134 cope_file="mbtk/test/*"
135 files=$(ls $cope_file 2> /dev/null | wc -l)
136 if [ "$files" != "0" ] ;then #如果存在文件
137 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
138 fi
139 fi
140}
141
b.liuced8dd02024-06-28 13:28:29 +0800142function print_arg()
143{
b.liuced8dd02024-06-28 13:28:29 +0800144 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800145 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800146}
147
liubin207854f2023-07-19 17:25:29 +0800148function main()
149{
b.liu61eedc92024-11-13 16:07:00 +0800150 if [ ! -d out/lib ];then
151 mkdir -p out/lib
b.liu2f89bfb2023-11-30 17:14:01 +0800152 fi
b.liube08cda2024-05-24 16:37:54 +0800153
b.liu61eedc92024-11-13 16:07:00 +0800154 if [ ! -d out/bin ];then
155 mkdir -p out/bin
156 fi
157
158 if [ -n "$1" ] ;then
159 if [ "$1" == "v1" -o "$1" == "v2" ];then
160 build clean
161
162
163 else
164 build $1
165 exit 0
166 fi
167 fi
168
169 if [ ! -d out/lib ];then
170 mkdir -p out/lib
171 fi
172
173 if [ ! -d out/bin ];then
174 mkdir -p out/bin
175 fi
176
177 build
178
179 print_arg
180
181 file_copy
182
b.liube08cda2024-05-24 16:37:54 +0800183 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800184}
185
b.liuced8dd02024-06-28 13:28:29 +0800186# exit 1
187print_arg
188
189main $1