liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
b.liu | 575a0f1 | 2024-12-19 20:08:45 +0800 | [diff] [blame] | 3 | if [ ! -f config ];then |
| 4 | echo "Exec init.sh in the first." |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 8 | # static / shared |
| 9 | export BUILD_LIB_TYPE=shared |
b.liu | 450e399 | 2024-10-10 10:59:29 +0800 | [diff] [blame] | 10 | |
| 11 | export STAGING_DIR= |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 12 | |
b.liu | 5d5b8ba | 2024-02-20 14:00:33 +0800 | [diff] [blame] | 13 | ROOT_DIR=`pwd` |
| 14 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 15 | BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2` |
| 16 | if [ "$BUILD_LIBC_TEMP" == "musl" ];then |
| 17 | export BUILD_STD_LIBC=musl |
| 18 | else |
| 19 | export BUILD_STD_LIBC=glibc |
| 20 | fi |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 21 | |
b.liu | deb8e42 | 2024-12-14 17:36:56 +0800 | [diff] [blame] | 22 | export BUILD_GCC_VERSION=`cat config | grep CONFIG_GCC_VERSION | cut -d '=' -f 2` |
| 23 | |
b.liu | 9f91db3 | 2025-02-13 11:24:18 +0800 | [diff] [blame] | 24 | #export MBTK_DEV_INFO_VERSION=`cat config | grep CONFIG_DEV_INFO_VERSION | cut -d '=' -f 2` |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 25 | export CONFIG_MBTK_5G_SUPPORT=`cat config | grep CONFIG_MBTK_5G_SUPPORT | cut -d '=' -f 2` |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 26 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 27 | if [ -n "$1" ] ;then |
| 28 | case "$1" in |
| 29 | v1) |
| 30 | export MBTK_SOURCE_VERSION=1 |
| 31 | ;; |
| 32 | v2) |
| 33 | export MBTK_SOURCE_VERSION=2 |
| 34 | ;; |
| 35 | *) |
| 36 | MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2` |
| 37 | if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then |
| 38 | export MBTK_SOURCE_VERSION=2 |
| 39 | else |
| 40 | export MBTK_SOURCE_VERSION=1 |
| 41 | fi |
| 42 | esac |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 43 | else |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 44 | MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2` |
| 45 | if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then |
| 46 | export MBTK_SOURCE_VERSION=2 |
| 47 | else |
| 48 | export MBTK_SOURCE_VERSION=1 |
| 49 | fi |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 50 | fi |
| 51 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 52 | function build() |
| 53 | { |
| 54 | cd mbtk |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 55 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 56 | if [ -n "$1" ] ;then |
| 57 | case "$1" in |
| 58 | clean) |
| 59 | make clean |
| 60 | ;; |
| 61 | *) |
b.liu | 8f67dfb | 2023-11-27 11:27:51 +0800 | [diff] [blame] | 62 | # exit 1;; |
| 63 | make -C $1 |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 64 | esac |
| 65 | else # 无参数 |
| 66 | make || exit 1 |
| 67 | fi |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 68 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 69 | cd $ROOT_DIR |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 70 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 71 | echo "Build MBTK success." |
| 72 | } |
| 73 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 74 | function copy_bin_and_lib() |
| 75 | { |
| 76 | # Copy All SO Files. |
b.liu | 883991f | 2024-11-29 19:44:56 +0800 | [diff] [blame] | 77 | # cp -f mbtk/libmbtk_lib/wifi/libs out/lib |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 78 | cp -f out/lib/* $1/lib |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 79 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 80 | # Copy All Bin Files. |
| 81 | #cp -f out/bin/* $1/bin |
| 82 | [ -f out/bin/at ] && cp -f out/bin/at $1/bin |
| 83 | [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin |
b.liu | fc2bdb8 | 2024-11-30 17:24:34 +0800 | [diff] [blame] | 84 | [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 85 | [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin |
| 86 | [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin |
| 87 | [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin |
| 88 | [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/.. |
| 89 | [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/.. |
| 90 | [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin |
| 91 | [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin |
| 92 | [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin |
| 93 | [ -f out/bin/mbtk_reboot ] && cp -f out/bin/mbtk_reboot $1/bin |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 94 | [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin |
b.liu | 047a21c | 2024-06-07 17:54:41 +0800 | [diff] [blame] | 95 | [ -f out/bin/mbtk_version ] && cp -f out/bin/mbtk_version $1/bin |
b.liu | 717dc08 | 2024-06-20 10:51:49 +0800 | [diff] [blame] | 96 | [ -f out/bin/mbtk_servicesd ] && cp -f out/bin/mbtk_servicesd $1/bin |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 97 | [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin |
b.liu | 3bf26ca | 2024-12-23 19:03:57 +0800 | [diff] [blame] | 98 | [ -f out/bin/mbtk_rtpd ] && cp -f out/bin/mbtk_rtpd $1/bin |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 99 | |
| 100 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 101 | # Copy GNSS(5311) bin files. |
| 102 | [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc |
| 103 | [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 104 | } |
| 105 | |
b.liu | 762260b | 2025-02-18 18:21:55 +0800 | [diff] [blame^] | 106 | function copy_factory_files() |
| 107 | { |
| 108 | # Copy All SO Files. |
| 109 | # cp -f mbtk/libmbtk_lib/wifi/libs out/lib |
| 110 | cp -f out/lib/* $1/lib |
| 111 | |
| 112 | # Copy All Bin Files. |
| 113 | #cp -f out/bin/* $1/bin |
| 114 | [ -f out/bin/at ] && cp -f out/bin/at $1/bin |
| 115 | [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/.. |
| 116 | [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin |
| 117 | [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin |
| 118 | |
| 119 | # Copy GNSS(5311) bin files. |
| 120 | [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc |
| 121 | [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc |
| 122 | } |
| 123 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 124 | function file_copy() |
| 125 | { |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 126 | ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 127 | |
| 128 | if [ -d $ROOTFS_DIR ];then |
| 129 | echo "Copy MBTK out files..." |
| 130 | if [ ! -d $ROOTFS_DIR/bin ];then |
| 131 | mkdir $ROOTFS_DIR/bin |
| 132 | fi |
| 133 | if [ ! -d $ROOTFS_DIR/lib ];then |
| 134 | mkdir $ROOTFS_DIR/lib |
| 135 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 136 | |
b.liu | 762260b | 2025-02-18 18:21:55 +0800 | [diff] [blame^] | 137 | copy_factory_files $ROOTFS_DIR |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 138 | else |
| 139 | echo "No found rootfs : $ROOTFS_DIR" |
| 140 | fi |
| 141 | } |
| 142 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 143 | function temp_mbtk_copy() |
| 144 | { |
| 145 | TEMP_MBTK_DIR=$ROOT_DIR/../temp_open |
| 146 | if [ -d $TEMP_MBTK_DIR ];then |
| 147 | rm -rf $TEMP_MBTK_DIR |
| 148 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 149 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 150 | mkdir -p $TEMP_MBTK_DIR/mbtk/include |
| 151 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin |
| 152 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib |
b.liu | 76541c9 | 2024-07-02 11:37:37 +0800 | [diff] [blame] | 153 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 154 | mkdir -p $TEMP_MBTK_DIR/mbtk/test |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 155 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 156 | copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 157 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 158 | # Copy include file. |
| 159 | if [ -d mbtk/include ];then |
| 160 | cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include |
| 161 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 162 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 163 | # Copy test source. |
| 164 | if [ -d mbtk/test ];then |
| 165 | cope_file="mbtk/test/*" |
| 166 | files=$(ls $cope_file 2> /dev/null | wc -l) |
| 167 | if [ "$files" != "0" ] ;then #如果存在文件 |
| 168 | cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test |
| 169 | fi |
| 170 | fi |
| 171 | } |
| 172 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 173 | function print_arg() |
| 174 | { |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 175 | echo BUILD_STD_LIBC=$BUILD_STD_LIBC |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 176 | echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION |
b.liu | 9f91db3 | 2025-02-13 11:24:18 +0800 | [diff] [blame] | 177 | # echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 178 | } |
| 179 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 180 | function main() |
| 181 | { |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 182 | if [ ! -d out/lib ];then |
| 183 | mkdir -p out/lib |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 184 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 185 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 186 | if [ ! -d out/bin ];then |
| 187 | mkdir -p out/bin |
| 188 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 189 | |
b.liu | deb8e42 | 2024-12-14 17:36:56 +0800 | [diff] [blame] | 190 | if [ "$BUILD_LIBC_TEMP" == "musl" ];then |
| 191 | [ -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 |
| 192 | else |
| 193 | [ -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 |
| 194 | fi |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 195 | |
| 196 | if [ -n "$1" ] ;then |
| 197 | if [ "$1" == "v1" -o "$1" == "v2" ];then |
| 198 | build clean |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 199 | |
| 200 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 201 | else |
| 202 | build $1 |
| 203 | exit 0 |
| 204 | fi |
| 205 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 206 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 207 | if [ ! -d out/lib ];then |
| 208 | mkdir -p out/lib |
| 209 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 210 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 211 | if [ ! -d out/bin ];then |
| 212 | mkdir -p out/bin |
| 213 | fi |
| 214 | |
| 215 | build |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 216 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 217 | print_arg |
| 218 | |
| 219 | file_copy |
| 220 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 221 | temp_mbtk_copy |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 222 | } |
| 223 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 224 | # exit 1 |
| 225 | print_arg |
| 226 | |
| 227 | main $1 |