liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Config item. |
| 4 | # static / shared |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 5 | #LIB_TYPE=static |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 6 | # gcc-4.9 / gcc-8.4 |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 7 | #export PLATFORM=gcc-4.9 |
| 8 | |
| 9 | # static / shared |
| 10 | export BUILD_LIB_TYPE=shared |
| 11 | # gcc-4.9 / gcc-8.4 |
| 12 | |
b.liu | 5d5b8ba | 2024-02-20 14:00:33 +0800 | [diff] [blame] | 13 | ROOT_DIR=`pwd` |
| 14 | |
| 15 | cd .. |
| 16 | grep "url" .git/config | cut -d " " -f 3 | grep "kernel_5.4.195" |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 17 | if [ $? -eq "0" ]; then |
b.liu | 3403c93 | 2023-10-10 16:26:35 +0800 | [diff] [blame] | 18 | export BUILD_PLATFORM=asr1806 |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 19 | else |
b.liu | 3403c93 | 2023-10-10 16:26:35 +0800 | [diff] [blame] | 20 | export BUILD_PLATFORM=asr1803 |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 21 | fi |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 22 | |
b.liu | 5d5b8ba | 2024-02-20 14:00:33 +0800 | [diff] [blame] | 23 | export BUILD_BRANCH=`git branch | grep "*" | cut -d " " -f 2` |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 24 | BUILD_PROJECT_TEMP=`cat build_version | grep PROJECT | cut -d '=' -f 2` |
| 25 | echo "BUILD_PROJECT_TEMP=$BUILD_PROJECT_TEMP" |
| 26 | |
| 27 | if [ "$BUILD_PLATFORM" == "asr1803" ];then |
| 28 | if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then |
| 29 | export BUILD_PROJECT=L509 |
| 30 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then |
| 31 | export BUILD_PROJECT=L508 |
| 32 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then |
| 33 | export BUILD_PROJECT=PN1803 |
| 34 | else |
| 35 | echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP" |
| 36 | exit 1 |
| 37 | fi |
| 38 | else |
| 39 | if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then |
| 40 | export BUILD_PROJECT=L509 |
yq.wang | 307d345 | 2024-03-20 15:46:32 +0800 | [diff] [blame] | 41 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-7`" == "L508_X6" ];then |
| 42 | export BUILD_PROJECT=L508_X6 |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 43 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then |
| 44 | export BUILD_PROJECT=L508 |
| 45 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then |
| 46 | export BUILD_PROJECT=PN1803 |
| 47 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "T108" ];then |
| 48 | export BUILD_PROJECT=T108 |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 49 | else |
| 50 | echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP" |
| 51 | exit 1 |
| 52 | fi |
| 53 | fi |
| 54 | |
b.liu | 5d5b8ba | 2024-02-20 14:00:33 +0800 | [diff] [blame] | 55 | cd $ROOT_DIR |
| 56 | |
b.liu | 1c1c721 | 2023-12-22 16:35:27 +0800 | [diff] [blame] | 57 | export STAGING_DIR= |
| 58 | |
b.liu | 5d5b8ba | 2024-02-20 14:00:33 +0800 | [diff] [blame] | 59 | |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 60 | #TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM |
| 61 | #echo "toolchain : $ROOT_DIR" |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 62 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 63 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 64 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 65 | function build() |
| 66 | { |
| 67 | cd mbtk |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 68 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 69 | if [ -n "$1" ] ;then |
| 70 | case "$1" in |
| 71 | clean) |
| 72 | make clean |
| 73 | ;; |
| 74 | *) |
b.liu | 8f67dfb | 2023-11-27 11:27:51 +0800 | [diff] [blame] | 75 | # exit 1;; |
| 76 | make -C $1 |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 77 | esac |
| 78 | else # 无参数 |
| 79 | make || exit 1 |
| 80 | fi |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 81 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 82 | cd $ROOT_DIR |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 83 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 84 | echo "Build MBTK success." |
| 85 | } |
| 86 | |
| 87 | function file_copy() |
| 88 | { |
liubin | 1673a9c | 2023-07-19 20:59:43 +0800 | [diff] [blame] | 89 | ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 90 | |
| 91 | if [ -d $ROOTFS_DIR ];then |
| 92 | echo "Copy MBTK out files..." |
| 93 | if [ ! -d $ROOTFS_DIR/bin ];then |
| 94 | mkdir $ROOTFS_DIR/bin |
| 95 | fi |
| 96 | if [ ! -d $ROOTFS_DIR/lib ];then |
| 97 | mkdir $ROOTFS_DIR/lib |
| 98 | fi |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 99 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 100 | # Copy All SO Files. |
| 101 | cp -f out/lib/* $ROOTFS_DIR/lib |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 102 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 103 | # Copy All Bin Files. |
liubin | b8a0dd7 | 2023-08-04 15:26:48 +0800 | [diff] [blame] | 104 | #cp -f out/bin/* $ROOTFS_DIR/bin |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 105 | [ -f out/bin/at ] && cp -f out/bin/at $ROOTFS_DIR/bin |
| 106 | [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $ROOTFS_DIR/bin |
| 107 | [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $ROOTFS_DIR/bin |
| 108 | [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $ROOTFS_DIR/bin |
wangyouqiang | 387f7f2 | 2024-03-18 14:48:48 +0800 | [diff] [blame] | 109 | [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $ROOTFS_DIR/bin |
b.liu | 3a41a31 | 2024-02-28 09:57:39 +0800 | [diff] [blame] | 110 | [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $ROOTFS_DIR |
b.liu | c498452 | 2024-02-29 14:54:51 +0800 | [diff] [blame] | 111 | [ -f out/bin/device_info ] && cp -f out/bin/device_info $ROOTFS_DIR/bin |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 112 | [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $ROOTFS_DIR/bin |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 113 | else |
| 114 | echo "No found rootfs : $ROOTFS_DIR" |
| 115 | fi |
| 116 | } |
| 117 | |
| 118 | function main() |
| 119 | { |
liubin | e760bd5 | 2023-07-20 15:57:21 +0800 | [diff] [blame] | 120 | if [ -n "$1" ] ;then |
| 121 | build $1 |
| 122 | exit 0 |
| 123 | fi |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 124 | |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 125 | if [ -d out/bin -a -d out/lib ];then |
| 126 | build |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 127 | |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 128 | file_copy |
| 129 | else |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 130 | if [ ! -d out/lib ];then |
| 131 | mkdir -p out/lib |
| 132 | fi |
b.liu | 482dc0b | 2024-03-22 15:53:36 +0800 | [diff] [blame^] | 133 | |
| 134 | if [ ! -d out/bin ];then |
| 135 | mkdir -p out/bin |
| 136 | fi |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 137 | |
| 138 | build |
| 139 | |
| 140 | file_copy |
| 141 | fi |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 142 | } |
| 143 | |
liubin | e760bd5 | 2023-07-20 15:57:21 +0800 | [diff] [blame] | 144 | main $1 |