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