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