blob: 87667f47d0625465af373dec0a8439c7766f46aa [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001#!/bin/bash
2
3# Config item.
4# static / shared
b.liu17d7f8b2023-10-08 16:57:59 +08005#LIB_TYPE=static
liubin281ac462023-07-19 14:22:54 +08006# gcc-4.9 / gcc-8.4
b.liu17d7f8b2023-10-08 16:57:59 +08007#export PLATFORM=gcc-4.9
8
9# static / shared
10export BUILD_LIB_TYPE=shared
11# gcc-4.9 / gcc-8.4
12
b.liu5d5b8ba2024-02-20 14:00:33 +080013ROOT_DIR=`pwd`
14
15cd ..
16grep "url" .git/config | cut -d " " -f 3 | grep "kernel_5.4.195"
b.liu17d7f8b2023-10-08 16:57:59 +080017if [ $? -eq "0" ]; then
b.liu3403c932023-10-10 16:26:35 +080018 export BUILD_PLATFORM=asr1806
b.liu17d7f8b2023-10-08 16:57:59 +080019else
b.liu3403c932023-10-10 16:26:35 +080020 export BUILD_PLATFORM=asr1803
b.liu17d7f8b2023-10-08 16:57:59 +080021fi
liubin281ac462023-07-19 14:22:54 +080022
b.liu5d5b8ba2024-02-20 14:00:33 +080023export BUILD_BRANCH=`git branch | grep "*" | cut -d " " -f 2`
b.liuf37bd332024-03-18 13:51:24 +080024BUILD_PROJECT_TEMP=`cat build_version | grep PROJECT | cut -d '=' -f 2`
25echo "BUILD_PROJECT_TEMP=$BUILD_PROJECT_TEMP"
26
27if [ "$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
38else
39 if [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-4`" == "L509" ];then
40 export BUILD_PROJECT=L509
yq.wang307d3452024-03-20 15:46:32 +080041 elif [ "`echo $BUILD_PROJECT_TEMP | cut -c 1-7`" == "L508_X6" ];then
42 export BUILD_PROJECT=L508_X6
b.liuf37bd332024-03-18 13:51:24 +080043 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.liuf37bd332024-03-18 13:51:24 +080049 else
50 echo "Unknown BUILD_PROJECT:$BUILD_PROJECT_TEMP"
51 exit 1
52 fi
53fi
54
b.liu5d5b8ba2024-02-20 14:00:33 +080055cd $ROOT_DIR
56
b.liu1c1c7212023-12-22 16:35:27 +080057export STAGING_DIR=
58
b.liu5d5b8ba2024-02-20 14:00:33 +080059
b.liu17d7f8b2023-10-08 16:57:59 +080060#TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM
61#echo "toolchain : $ROOT_DIR"
liubin281ac462023-07-19 14:22:54 +080062
liubin281ac462023-07-19 14:22:54 +080063
liubin281ac462023-07-19 14:22:54 +080064
liubin207854f2023-07-19 17:25:29 +080065function build()
66{
67 cd mbtk
liubin281ac462023-07-19 14:22:54 +080068
liubin207854f2023-07-19 17:25:29 +080069 if [ -n "$1" ] ;then
70 case "$1" in
71 clean)
72 make clean
73 ;;
74 *)
b.liu8f67dfb2023-11-27 11:27:51 +080075# exit 1;;
76 make -C $1
liubin207854f2023-07-19 17:25:29 +080077 esac
78 else # 无参数
79 make || exit 1
80 fi
liubin281ac462023-07-19 14:22:54 +080081
liubin207854f2023-07-19 17:25:29 +080082 cd $ROOT_DIR
liubin281ac462023-07-19 14:22:54 +080083
liubin207854f2023-07-19 17:25:29 +080084 echo "Build MBTK success."
85}
86
87function file_copy()
88{
liubin1673a9c2023-07-19 20:59:43 +080089 ROOTFS_DIR=$ROOT_DIR/../asr_code/mbtk
liubin207854f2023-07-19 17:25:29 +080090
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.liuf534b1f2024-03-19 17:25:26 +080099
liubin207854f2023-07-19 17:25:29 +0800100 # Copy All SO Files.
101 cp -f out/lib/* $ROOTFS_DIR/lib
b.liuf534b1f2024-03-19 17:25:26 +0800102
liubin207854f2023-07-19 17:25:29 +0800103 # Copy All Bin Files.
liubinb8a0dd72023-08-04 15:26:48 +0800104 #cp -f out/bin/* $ROOTFS_DIR/bin
b.liuf37bd332024-03-18 13:51:24 +0800105 [ -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
wangyouqiang387f7f22024-03-18 14:48:48 +0800109 [ -f out/bin/mbtk_mdio ] && cp -f out/bin/mbtk_mdio $ROOTFS_DIR/bin
b.liu3a41a312024-02-28 09:57:39 +0800110 [ -f out/bin/device_info_generate ] && cp -f out/bin/device_info_generate $ROOTFS_DIR
b.liuc4984522024-02-29 14:54:51 +0800111 [ -f out/bin/device_info ] && cp -f out/bin/device_info $ROOTFS_DIR/bin
b.liuf534b1f2024-03-19 17:25:26 +0800112 [ -f out/bin/mtd_info ] && cp -f out/bin/mtd_info $ROOTFS_DIR/bin
liubin207854f2023-07-19 17:25:29 +0800113 else
114 echo "No found rootfs : $ROOTFS_DIR"
115 fi
116}
117
118function main()
119{
liubine760bd52023-07-20 15:57:21 +0800120 if [ -n "$1" ] ;then
121 build $1
122 exit 0
123 fi
b.liuf534b1f2024-03-19 17:25:26 +0800124
b.liu2f89bfb2023-11-30 17:14:01 +0800125 if [ -d out/bin -a -d out/lib ];then
126 build
b.liuf534b1f2024-03-19 17:25:26 +0800127
b.liu2f89bfb2023-11-30 17:14:01 +0800128 file_copy
129 else
b.liu2f89bfb2023-11-30 17:14:01 +0800130 if [ ! -d out/lib ];then
131 mkdir -p out/lib
132 fi
b.liu482dc0b2024-03-22 15:53:36 +0800133
134 if [ ! -d out/bin ];then
135 mkdir -p out/bin
136 fi
b.liu2f89bfb2023-11-30 17:14:01 +0800137
138 build
139
140 file_copy
141 fi
liubin207854f2023-07-19 17:25:29 +0800142}
143
liubine760bd52023-07-20 15:57:21 +0800144main $1