blob: 61f1207bcbe2d4a00c468d7f82680de5f0697bea [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.liu87afc4c2024-08-14 17:33:45 +080017MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2`
18if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then
19 export MBTK_SOURCE_VERSION=2
20else
21 export MBTK_SOURCE_VERSION=1
22fi
23
liubin207854f2023-07-19 17:25:29 +080024function build()
25{
26 cd mbtk
liubin281ac462023-07-19 14:22:54 +080027
liubin207854f2023-07-19 17:25:29 +080028 if [ -n "$1" ] ;then
29 case "$1" in
30 clean)
31 make clean
32 ;;
33 *)
b.liu8f67dfb2023-11-27 11:27:51 +080034# exit 1;;
35 make -C $1
liubin207854f2023-07-19 17:25:29 +080036 esac
37 else # 无参数
38 make || exit 1
39 fi
liubin281ac462023-07-19 14:22:54 +080040
liubin207854f2023-07-19 17:25:29 +080041 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080042
liubin207854f2023-07-19 17:25:29 +080043 echo "Build MBTK success."
44}
45
b.liube08cda2024-05-24 16:37:54 +080046function copy_bin_and_lib()
47{
48 # Copy All SO Files.
49 cp -f out/lib/* $1/lib
50
51 # Copy All Bin Files.
52 #cp -f out/bin/* $1/bin
53 [ -f out/bin/at ] && cp -f out/bin/at $1/bin
54 [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin
55 [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin
56 [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin
57 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin
58 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/..
59 [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/..
60 [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin
61 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin
62 [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin
63 [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin
b.liu8f231a12024-05-31 17:55:06 +080064 [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin
b.liu047a21c2024-06-07 17:54:41 +080065 [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin
b.liu717dc082024-06-20 10:51:49 +080066 [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin
b.liuced8dd02024-06-28 13:28:29 +080067 [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin
68
69
70 # Copy GNSS(5311) bin files.
71 [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc
72 [ -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 +080073}
74
liubin207854f2023-07-19 17:25:29 +080075function file_copy()
76{
b.liuf678f992024-05-08 15:23:10 +080077 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs
liubin207854f2023-07-19 17:25:29 +080078
79 if [ -d $ROOTFS_DIR ];then
80 echo "Copy MBTK out files..."
81 if [ ! -d $ROOTFS_DIR/bin ];then
82 mkdir $ROOTFS_DIR/bin
83 fi
84 if [ ! -d $ROOTFS_DIR/lib ];then
85 mkdir $ROOTFS_DIR/lib
86 fi
b.liube08cda2024-05-24 16:37:54 +080087
88 copy_bin_and_lib $ROOTFS_DIR
liubin207854f2023-07-19 17:25:29 +080089 else
90 echo "No found rootfs : $ROOTFS_DIR"
91 fi
92}
93
b.liube08cda2024-05-24 16:37:54 +080094function temp_mbtk_copy()
95{
96 TEMP_MBTK_DIR=$ROOT_DIR/../temp_open
97 if [ -d $TEMP_MBTK_DIR ];then
98 rm -rf $TEMP_MBTK_DIR
99 fi
100
101 mkdir -p $TEMP_MBTK_DIR/mbtk/include
102 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin
103 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib
b.liu76541c92024-07-02 11:37:37 +0800104 mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc
b.liube08cda2024-05-24 16:37:54 +0800105 mkdir -p $TEMP_MBTK_DIR/mbtk/test
106
107 copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs
108
109 # Copy include file.
110 if [ -d mbtk/include ];then
111 cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include
112 fi
113
114 # Copy test source.
115 if [ -d mbtk/test ];then
116 cope_file="mbtk/test/*"
117 files=$(ls $cope_file 2> /dev/null | wc -l)
118 if [ "$files" != "0" ] ;then #如果存在文件
119 cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test
120 fi
121 fi
122}
123
b.liuced8dd02024-06-28 13:28:29 +0800124function print_arg()
125{
b.liuced8dd02024-06-28 13:28:29 +0800126 echo BUILD_STD_LIBC=$BUILD_STD_LIBC
b.liu87afc4c2024-08-14 17:33:45 +0800127 echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION
b.liuced8dd02024-06-28 13:28:29 +0800128}
129
liubin207854f2023-07-19 17:25:29 +0800130function main()
131{
liubine760bd52023-07-20 15:57:21 +0800132 if [ -n "$1" ] ;then
133 build $1
134 exit 0
135 fi
b.liuf534b1f2024-03-19 17:25:26 +0800136
b.liu2f89bfb2023-11-30 17:14:01 +0800137 if [ -d out/bin -a -d out/lib ];then
138 build
b.liuced8dd02024-06-28 13:28:29 +0800139
140 print_arg
b.liuf534b1f2024-03-19 17:25:26 +0800141
b.liu450e3992024-10-10 10:59:29 +0800142 # file_copy
b.liu2f89bfb2023-11-30 17:14:01 +0800143 else
b.liu2f89bfb2023-11-30 17:14:01 +0800144 if [ ! -d out/lib ];then
145 mkdir -p out/lib
146 fi
b.liu482dc0b2024-03-22 15:53:36 +0800147
148 if [ ! -d out/bin ];then
149 mkdir -p out/bin
150 fi
b.liu2f89bfb2023-11-30 17:14:01 +0800151
152 build
b.liuced8dd02024-06-28 13:28:29 +0800153
154 print_arg
b.liu2f89bfb2023-11-30 17:14:01 +0800155
b.liu450e3992024-10-10 10:59:29 +0800156 # file_copy
b.liu2f89bfb2023-11-30 17:14:01 +0800157 fi
b.liube08cda2024-05-24 16:37:54 +0800158
159 temp_mbtk_copy
liubin207854f2023-07-19 17:25:29 +0800160}
161
b.liuced8dd02024-06-28 13:28:29 +0800162# exit 1
163print_arg
164
165main $1