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 | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 17 | MBTK_SOURCE_VERSION_TEMP=`cat config | grep CONFIG_MBTK_SOURCE_VERSION | cut -d '=' -f 2` |
| 18 | if [ "$MBTK_SOURCE_VERSION_TEMP" == "2" ];then |
| 19 | export MBTK_SOURCE_VERSION=2 |
| 20 | else |
| 21 | export MBTK_SOURCE_VERSION=1 |
| 22 | fi |
| 23 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 24 | function build() |
| 25 | { |
| 26 | cd mbtk |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 27 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 28 | if [ -n "$1" ] ;then |
| 29 | case "$1" in |
| 30 | clean) |
| 31 | make clean |
| 32 | ;; |
| 33 | *) |
b.liu | 8f67dfb | 2023-11-27 11:27:51 +0800 | [diff] [blame] | 34 | # exit 1;; |
| 35 | make -C $1 |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 36 | esac |
| 37 | else # 无参数 |
| 38 | make || exit 1 |
| 39 | fi |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 40 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 41 | cd $ROOT_DIR |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 42 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 43 | echo "Build MBTK success." |
| 44 | } |
| 45 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 46 | function 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.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 64 | [ -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] | 65 | [ -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] | 66 | [ -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] | 67 | [ -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.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 73 | } |
| 74 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 75 | function file_copy() |
| 76 | { |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 77 | ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 78 | |
| 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.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 87 | |
| 88 | copy_bin_and_lib $ROOTFS_DIR |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 89 | else |
| 90 | echo "No found rootfs : $ROOTFS_DIR" |
| 91 | fi |
| 92 | } |
| 93 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 94 | function 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.liu | 76541c9 | 2024-07-02 11:37:37 +0800 | [diff] [blame] | 104 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 105 | 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.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 124 | function print_arg() |
| 125 | { |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 126 | echo BUILD_STD_LIBC=$BUILD_STD_LIBC |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 127 | echo MBTK_SOURCE_VERSION=$MBTK_SOURCE_VERSION |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 128 | } |
| 129 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 130 | function main() |
| 131 | { |
liubin | e760bd5 | 2023-07-20 15:57:21 +0800 | [diff] [blame] | 132 | if [ -n "$1" ] ;then |
| 133 | build $1 |
| 134 | exit 0 |
| 135 | fi |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 136 | |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 137 | if [ -d out/bin -a -d out/lib ];then |
| 138 | build |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 139 | |
| 140 | print_arg |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 141 | |
b.liu | 450e399 | 2024-10-10 10:59:29 +0800 | [diff] [blame^] | 142 | # file_copy |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 143 | else |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 144 | if [ ! -d out/lib ];then |
| 145 | mkdir -p out/lib |
| 146 | fi |
b.liu | 482dc0b | 2024-03-22 15:53:36 +0800 | [diff] [blame] | 147 | |
| 148 | if [ ! -d out/bin ];then |
| 149 | mkdir -p out/bin |
| 150 | fi |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 151 | |
| 152 | build |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 153 | |
| 154 | print_arg |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 155 | |
b.liu | 450e399 | 2024-10-10 10:59:29 +0800 | [diff] [blame^] | 156 | # file_copy |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 157 | fi |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 158 | |
| 159 | temp_mbtk_copy |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 160 | } |
| 161 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 162 | # exit 1 |
| 163 | print_arg |
| 164 | |
| 165 | main $1 |