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 | a76c961 | 2025-03-28 13:58:09 +0800 | [diff] [blame^] | 99 | [ -f out/bin/mbtk_otad ] && cp -f out/bin/mbtk_otad $1/bin |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 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/.. |
b.liu | 6339dca | 2025-02-20 17:47:23 +0800 | [diff] [blame] | 116 | [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin |
| 117 | [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin |
b.liu | 762260b | 2025-02-18 18:21:55 +0800 | [diff] [blame] | 118 | [ -f out/bin/mbtk_gnssd ] && cp -f out/bin/mbtk_gnssd $1/bin |
| 119 | [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin |
| 120 | |
| 121 | # Copy GNSS(5311) bin files. |
| 122 | [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc |
| 123 | [ -f mbtk/aboot-tiny/files/config/jacana_pvt.bin ] && cp -f mbtk/aboot-tiny/files/config/jacana_pvt.bin $1/etc |
| 124 | } |
| 125 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 126 | function file_copy() |
| 127 | { |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 128 | ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 129 | |
| 130 | if [ -d $ROOTFS_DIR ];then |
| 131 | echo "Copy MBTK out files..." |
| 132 | if [ ! -d $ROOTFS_DIR/bin ];then |
| 133 | mkdir $ROOTFS_DIR/bin |
| 134 | fi |
| 135 | if [ ! -d $ROOTFS_DIR/lib ];then |
| 136 | mkdir $ROOTFS_DIR/lib |
| 137 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 138 | |
b.liu | 762260b | 2025-02-18 18:21:55 +0800 | [diff] [blame] | 139 | copy_factory_files $ROOTFS_DIR |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 140 | else |
| 141 | echo "No found rootfs : $ROOTFS_DIR" |
| 142 | fi |
| 143 | } |
| 144 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 145 | function temp_mbtk_copy() |
| 146 | { |
| 147 | TEMP_MBTK_DIR=$ROOT_DIR/../temp_open |
| 148 | if [ -d $TEMP_MBTK_DIR ];then |
| 149 | rm -rf $TEMP_MBTK_DIR |
| 150 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 151 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 152 | mkdir -p $TEMP_MBTK_DIR/mbtk/include |
| 153 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin |
| 154 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib |
b.liu | 76541c9 | 2024-07-02 11:37:37 +0800 | [diff] [blame] | 155 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 156 | mkdir -p $TEMP_MBTK_DIR/mbtk/test |
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_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 159 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 160 | # Copy include file. |
| 161 | if [ -d mbtk/include ];then |
| 162 | cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include |
| 163 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 164 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 165 | # Copy test source. |
| 166 | if [ -d mbtk/test ];then |
| 167 | cope_file="mbtk/test/*" |
| 168 | files=$(ls $cope_file 2> /dev/null | wc -l) |
| 169 | if [ "$files" != "0" ] ;then #如果存在文件 |
| 170 | cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test |
| 171 | fi |
| 172 | fi |
| 173 | } |
| 174 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 175 | function print_arg() |
| 176 | { |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 177 | echo BUILD_STD_LIBC=$BUILD_STD_LIBC |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 178 | echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION |
b.liu | 9f91db3 | 2025-02-13 11:24:18 +0800 | [diff] [blame] | 179 | # echo MBTK_DEV_INFO_VERSION=$MBTK_DEV_INFO_VERSION |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 180 | } |
| 181 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 182 | function main() |
| 183 | { |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 184 | if [ ! -d out/lib ];then |
| 185 | mkdir -p out/lib |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 186 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 187 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 188 | if [ ! -d out/bin ];then |
| 189 | mkdir -p out/bin |
| 190 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 191 | |
b.liu | deb8e42 | 2024-12-14 17:36:56 +0800 | [diff] [blame] | 192 | if [ "$BUILD_LIBC_TEMP" == "musl" ];then |
| 193 | [ -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 |
| 194 | else |
| 195 | [ -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 |
| 196 | fi |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 197 | |
| 198 | if [ -n "$1" ] ;then |
| 199 | if [ "$1" == "v1" -o "$1" == "v2" ];then |
| 200 | build clean |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 201 | |
| 202 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 203 | else |
| 204 | build $1 |
| 205 | exit 0 |
| 206 | fi |
| 207 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 208 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 209 | if [ ! -d out/lib ];then |
| 210 | mkdir -p out/lib |
| 211 | fi |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 212 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 213 | if [ ! -d out/bin ];then |
| 214 | mkdir -p out/bin |
| 215 | fi |
| 216 | |
| 217 | build |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 218 | |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 219 | print_arg |
| 220 | |
| 221 | file_copy |
| 222 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 223 | temp_mbtk_copy |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 224 | } |
| 225 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 226 | # exit 1 |
| 227 | print_arg |
| 228 | |
| 229 | main $1 |