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 | b3b923a | 2024-06-06 15:15:49 +0800 | [diff] [blame] | 18 | export BUILD_PLATFORM=v2102 |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 19 | else |
b.liu | b3b923a | 2024-06-06 15:15:49 +0800 | [diff] [blame] | 20 | export BUILD_PLATFORM=master |
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 | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 24 | cd $ROOT_DIR |
| 25 | |
| 26 | BUILD_PROJECT_TEMP=`cat config | grep CONFIG_PROJECT | cut -d '=' -f 2` |
| 27 | if [ "$BUILD_PROJECT_TEMP" == "DEFAULT" ];then |
| 28 | BUILD_PROJECT_TEMP=`cat ../build_version | grep PROJECT | cut -d '=' -f 2` |
| 29 | fi |
| 30 | |
| 31 | BUILD_LIBC_TEMP=`cat config | grep CONFIG_MBTK_LIBC | cut -d '=' -f 2` |
| 32 | if [ "$BUILD_LIBC_TEMP" == "musl" ];then |
| 33 | export BUILD_STD_LIBC=musl |
| 34 | else |
| 35 | export BUILD_STD_LIBC=glibc |
| 36 | fi |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 37 | |
b.liu | b3b923a | 2024-06-06 15:15:49 +0800 | [diff] [blame] | 38 | if [ "$BUILD_PLATFORM" == "master" ];then |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 39 | if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then |
| 40 | export BUILD_PROJECT=L509 |
| 41 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then |
| 42 | export BUILD_PROJECT=L508 |
| 43 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then |
| 44 | export BUILD_PROJECT=PN1803 |
| 45 | else |
| 46 | echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP" |
| 47 | exit 1 |
| 48 | fi |
| 49 | else |
| 50 | if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then |
| 51 | export BUILD_PROJECT=L509 |
yq.wang | 307d345 | 2024-03-20 15:46:32 +0800 | [diff] [blame] | 52 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-7`" == "L508_X6" ];then |
| 53 | export BUILD_PROJECT=L508_X6 |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 54 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L508" ];then |
| 55 | export BUILD_PROJECT=L508 |
| 56 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "PN1803" ];then |
| 57 | export BUILD_PROJECT=PN1803 |
b.liu | c25c547 | 2024-06-13 21:35:06 +0800 | [diff] [blame] | 58 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-6`" == "T108-2" ];then |
| 59 | export BUILD_PROJECT=T108_2 |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 60 | elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "T108" ];then |
| 61 | export BUILD_PROJECT=T108 |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 62 | else |
| 63 | echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP" |
| 64 | exit 1 |
| 65 | fi |
| 66 | fi |
| 67 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 68 | export MBTK_AF_SUPPORT=`cat config | grep CONFIG_AF_SUPPORT | cut -d '=' -f 2` |
| 69 | export MBTK_YX_SUPPORT=`cat config | grep CONFIG_YX_SUPPORT | cut -d '=' -f 2` |
| 70 | export MBTK_SG_SUPPORT=`cat config | grep CONFIG_SG_SUPPORT | cut -d '=' -f 2` |
| 71 | export MBTK_ALL_CID_SUPPORT=`cat config | grep CONFIG_MBTK_ALL_CID_SUPPORT | cut -d '=' -f 2` |
| 72 | export MBTK_GNSS_MODE=`cat config | grep CONFIG_MBTK_GNSS_MODE | cut -d '=' -f 2` |
| 73 | export MBTK_DUMP_SUPPORT=`cat config | grep CONFIG_MBTK_DUMP_SUPPORT | cut -d '=' -f 2` |
| 74 | |
| 75 | # 赛格默认打开 ALL_CID_SUPPORT |
| 76 | if [ "$MBTK_SG_SUPPORT" == "y" ];then |
| 77 | export MBTK_ALL_CID_SUPPORT=y |
| 78 | export BUILD_STD_LIBC=musl |
| 79 | fi |
| 80 | |
| 81 | # 安付默认打开 ALL_CID_SUPPORT |
| 82 | if [ "$MBTK_AF_SUPPORT" == "y" ];then |
| 83 | export BUILD_STD_LIBC=musl |
| 84 | fi |
| 85 | |
| 86 | |
| 87 | # musl 不支持mbtk dump |
| 88 | if [ "$BUILD_STD_LIBC" == "musl" ];then |
| 89 | export MBTK_DUMP_SUPPORT=n |
| 90 | fi |
b.liu | 5d5b8ba | 2024-02-20 14:00:33 +0800 | [diff] [blame] | 91 | |
b.liu | 1c1c721 | 2023-12-22 16:35:27 +0800 | [diff] [blame] | 92 | export STAGING_DIR= |
| 93 | |
b.liu | 17d7f8b | 2023-10-08 16:57:59 +0800 | [diff] [blame] | 94 | #TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM |
| 95 | #echo "toolchain : $ROOT_DIR" |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 96 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 97 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 98 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 99 | function build() |
| 100 | { |
| 101 | cd mbtk |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 102 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 103 | if [ -n "$1" ] ;then |
| 104 | case "$1" in |
| 105 | clean) |
| 106 | make clean |
| 107 | ;; |
| 108 | *) |
b.liu | 8f67dfb | 2023-11-27 11:27:51 +0800 | [diff] [blame] | 109 | # exit 1;; |
| 110 | make -C $1 |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 111 | esac |
| 112 | else # 无参数 |
| 113 | make || exit 1 |
| 114 | fi |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 115 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 116 | cd $ROOT_DIR |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 117 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 118 | echo "Build MBTK success." |
| 119 | } |
| 120 | |
b.liu | 445758f | 2024-05-08 16:22:33 +0800 | [diff] [blame] | 121 | ln_lib() |
| 122 | { |
| 123 | PWD_TEMP=`pwd` |
| 124 | |
| 125 | cd $ROOTFS_DIR/lib |
| 126 | [ ! -f libpoweralarm.so ] && ln -s liblynq_lib.so libpoweralarm.so |
| 127 | [ ! -f liblynq-qser-audio.so ] && ln -s liblynq_lib.so liblynq-qser-audio.so |
| 128 | [ ! -f liblynq-adc.so ] && ln -s liblynq_lib.so liblynq-adc.so |
| 129 | [ ! -f liblynq-fota.so ] && ln -s liblynq_lib.so liblynq-fota.so |
| 130 | [ ! -f liblynq-qser-gnss.so ] && ln -s liblynq_lib.so liblynq-qser-gnss.so |
| 131 | [ ! -f liblynq-log.so ] && ln -s liblynq_lib.so liblynq-log.so |
| 132 | [ ! -f liblynq-led.so ] && ln -s liblynq_lib.so liblynq-led.so |
| 133 | [ ! -f liblynq-qser-autosuspend.so ] && ln -s liblynq_lib.so liblynq-qser-autosuspend.so |
| 134 | [ ! -f liblynq-systime.so ] && ln -s liblynq_lib.so liblynq-systime.so |
| 135 | [ ! -f liblynq-qser-thermal.so ] && ln -s liblynq_lib.so liblynq-qser-thermal.so |
| 136 | [ ! -f liblynq-qser-sim.so ] && ln -s liblynq_lib.so liblynq-qser-sim.so |
| 137 | [ ! -f liblynq-qser-sms.so ] && ln -s liblynq_lib.so liblynq-qser-sms.so |
| 138 | [ ! -f liblynq-qser-voice.so ] && ln -s liblynq_lib.so liblynq-qser-voice.so |
| 139 | [ ! -f liblynq-qser-network.so ] && ln -s liblynq_lib.so liblynq-qser-network.so |
| 140 | [ ! -f liblynq-qser-data.so ] && ln -s liblynq_lib.so liblynq-qser-data.so |
| 141 | [ ! -f liblynq-irq.so ] && ln -s liblynq_lib.so liblynq-irq.so |
| 142 | |
| 143 | cd $PWD_TEMP |
| 144 | } |
| 145 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 146 | function copy_bin_and_lib() |
| 147 | { |
| 148 | # Copy All SO Files. |
| 149 | cp -f out/lib/* $1/lib |
| 150 | |
| 151 | # Copy All Bin Files. |
| 152 | #cp -f out/bin/* $1/bin |
| 153 | [ -f out/bin/at ] && cp -f out/bin/at $1/bin |
| 154 | [ -f out/bin/mbtk_rild ] && cp -f out/bin/mbtk_rild $1/bin |
| 155 | [ -f out/bin/mbtk_logd ] && cp -f out/bin/mbtk_logd $1/bin |
| 156 | [ -f out/bin/mbtk_adbd ] && cp -f out/bin/mbtk_adbd $1/bin |
| 157 | [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $1/bin |
| 158 | [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $1/.. |
| 159 | [ -f out/bin/ota_update ] && cp -f out/bin/ota_update $1/.. |
| 160 | [ -f out/bin/device_info ] && cp -f out/bin/device_info $1/bin |
| 161 | [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $1/bin |
| 162 | [ -f out/bin/mbtk_sdk_ready ] && cp -f out/bin/mbtk_sdk_ready $1/bin |
| 163 | [ -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] | 164 | [ -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] | 165 | [ -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] | 166 | [ -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] | 167 | [ -f out/bin/aboot-tiny ] && cp -f out/bin/aboot-tiny $1/bin |
| 168 | |
| 169 | |
| 170 | # Copy GNSS(5311) bin files. |
| 171 | [ -f mbtk/aboot-tiny/files/release/jacana_fw.bin ] && cp -f mbtk/aboot-tiny/files/release/jacana_fw.bin $1/etc |
| 172 | [ -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] | 173 | } |
| 174 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 175 | function file_copy() |
| 176 | { |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 177 | ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk/rootfs |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 178 | |
| 179 | if [ -d $ROOTFS_DIR ];then |
| 180 | echo "Copy MBTK out files..." |
| 181 | if [ ! -d $ROOTFS_DIR/bin ];then |
| 182 | mkdir $ROOTFS_DIR/bin |
| 183 | fi |
| 184 | if [ ! -d $ROOTFS_DIR/lib ];then |
| 185 | mkdir $ROOTFS_DIR/lib |
| 186 | fi |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 187 | |
| 188 | copy_bin_and_lib $ROOTFS_DIR |
b.liu | 445758f | 2024-05-08 16:22:33 +0800 | [diff] [blame] | 189 | |
| 190 | ln_lib |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 191 | else |
| 192 | echo "No found rootfs : $ROOTFS_DIR" |
| 193 | fi |
| 194 | } |
| 195 | |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 196 | function temp_mbtk_copy() |
| 197 | { |
| 198 | TEMP_MBTK_DIR=$ROOT_DIR/../temp_open |
| 199 | if [ -d $TEMP_MBTK_DIR ];then |
| 200 | rm -rf $TEMP_MBTK_DIR |
| 201 | fi |
| 202 | |
| 203 | mkdir -p $TEMP_MBTK_DIR/mbtk/include |
| 204 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/bin |
| 205 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/lib |
b.liu | 76541c9 | 2024-07-02 11:37:37 +0800 | [diff] [blame] | 206 | mkdir -p $TEMP_MBTK_DIR/mbtk/rootfs/etc |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 207 | mkdir -p $TEMP_MBTK_DIR/mbtk/test |
| 208 | |
| 209 | copy_bin_and_lib $TEMP_MBTK_DIR/mbtk/rootfs |
| 210 | |
| 211 | # Copy include file. |
| 212 | if [ -d mbtk/include ];then |
| 213 | cp -rf mbtk/include/* $TEMP_MBTK_DIR/mbtk/include |
| 214 | fi |
| 215 | |
| 216 | # Copy test source. |
| 217 | if [ -d mbtk/test ];then |
| 218 | cope_file="mbtk/test/*" |
| 219 | files=$(ls $cope_file 2> /dev/null | wc -l) |
| 220 | if [ "$files" != "0" ] ;then #如果存在文件 |
| 221 | cp -rf $cope_file $TEMP_MBTK_DIR/mbtk/test |
| 222 | fi |
| 223 | fi |
| 224 | } |
| 225 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 226 | function print_arg() |
| 227 | { |
| 228 | echo BUILD_PROJECT=$BUILD_PROJECT |
| 229 | echo BUILD_STD_LIBC=$BUILD_STD_LIBC |
| 230 | echo MBTK_GNSS_MODE=$MBTK_GNSS_MODE |
| 231 | echo MBTK_AF_SUPPORT=$MBTK_AF_SUPPORT |
| 232 | echo MBTK_YX_SUPPORT=$MBTK_YX_SUPPORT |
| 233 | echo MBTK_SG_SUPPORT=$MBTK_SG_SUPPORT |
| 234 | echo MBTK_ALL_CID_SUPPORT=$MBTK_ALL_CID_SUPPORT |
| 235 | echo MBTK_DUMP_SUPPORT=$MBTK_DUMP_SUPPORT |
| 236 | } |
| 237 | |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 238 | function main() |
| 239 | { |
liubin | e760bd5 | 2023-07-20 15:57:21 +0800 | [diff] [blame] | 240 | if [ -n "$1" ] ;then |
| 241 | build $1 |
| 242 | exit 0 |
| 243 | fi |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 244 | |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 245 | if [ -d out/bin -a -d out/lib ];then |
| 246 | build |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 247 | |
| 248 | print_arg |
b.liu | f534b1f | 2024-03-19 17:25:26 +0800 | [diff] [blame] | 249 | |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 250 | file_copy |
| 251 | else |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 252 | if [ ! -d out/lib ];then |
| 253 | mkdir -p out/lib |
| 254 | fi |
b.liu | 482dc0b | 2024-03-22 15:53:36 +0800 | [diff] [blame] | 255 | |
| 256 | if [ ! -d out/bin ];then |
| 257 | mkdir -p out/bin |
| 258 | fi |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 259 | |
| 260 | build |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 261 | |
| 262 | print_arg |
b.liu | 2f89bfb | 2023-11-30 17:14:01 +0800 | [diff] [blame] | 263 | |
| 264 | file_copy |
| 265 | fi |
b.liu | be08cda | 2024-05-24 16:37:54 +0800 | [diff] [blame] | 266 | |
| 267 | temp_mbtk_copy |
liubin | 207854f | 2023-07-19 17:25:29 +0800 | [diff] [blame] | 268 | } |
| 269 | |
b.liu | ced8dd0 | 2024-06-28 13:28:29 +0800 | [diff] [blame] | 270 | # exit 1 |
| 271 | print_arg |
| 272 | |
| 273 | main $1 |