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