-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·190 lines (167 loc) · 5.16 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
usage()
{
echo "USAGE: [-U] [-K] [-A] [-p] [-o] [-u] [-v VERSION_NAME] "
echo "No ARGS means use default build option "
echo "WHERE: -U = build uboot "
echo " -K = build kernel "
echo " -A = build android "
echo " -p = will build packaging in IMAGE "
echo " -o = build OTA package "
echo " -u = build update.img "
echo " -v = build android with 'user' or 'userdebug' "
exit 1
}
BUILD_UBOOT=false
BUILD_KERNEL=false
BUILD_ANDROID=false
BUILD_UPDATE_IMG=false
BUILD_OTA=false
BUILD_PACKING=false
BUILD_VARIANT=userdebug
# check pass argument
while getopts "UKApouv:" arg
do
case $arg in
U)
echo "will build u-boot"
BUILD_UBOOT=true
;;
K)
echo "will build kernel"
BUILD_KERNEL=true
;;
A)
echo "will build android"
BUILD_ANDROID=true
;;
p)
echo "will build packaging in IMAGE"
BUILD_PACKING=true
;;
o)
echo "will build ota package"
BUILD_OTA=true
;;
u)
echo "will build update.img"
BUILD_UPDATE_IMG=true
;;
v)
BUILD_VARIANT=$OPTARG
;;
?)
usage ;;
esac
done
source build/envsetup.sh >/dev/null
TARGET_PRODUCT=`get_build_var TARGET_PRODUCT`
#set jdk version
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
# source environment and chose target product
DEVICE=`get_build_var TARGET_PRODUCT`
BUILD_NUMBER=`get_build_var BUILD_NUMBER`
BUILD_ID=`get_build_var BUILD_ID`
UBOOT_DEFCONFIG=rk3368
KERNEL_DEFCONFIG=rockchip_defconfig
KERNEL_DTS=rk3368-xikp-avb
PACK_TOOL_DIR=RKTools/linux/Linux_Pack_Firmware
IMAGE_PATH=rockdev/Image-$TARGET_PRODUCT
export PROJECT_TOP=`gettop`
lunch $DEVICE-$BUILD_VARIANT
PLATFORM_VERSION=`get_build_var PLATFORM_VERSION`
DATE=$(date +%Y%m%d.%H%M)
STUB_PATH=Image/"$DEVICE"_"$PLATFORM_VERSION"_"$BUILD_VARIANT"_"$DATE"_RELEASE_TEST
STUB_PATH="$(echo $STUB_PATH | tr '[:lower:]' '[:upper:]')"
export STUB_PATH=$PROJECT_TOP/$STUB_PATH
export STUB_PATCH_PATH=$STUB_PATH/PATCHES
# build uboot
if [ "$BUILD_UBOOT" = true ] ; then
echo "start build uboot"
cd u-boot && make clean && make mrproper && make distclean && ./make.sh $UBOOT_DEFCONFIG && cd -
if [ $? -eq 0 ]; then
echo "Build uboot ok!"
else
echo "Build uboot failed!"
exit 1
fi
fi
# build kernel
if [ "$BUILD_KERNEL" = true ] ; then
echo "Start build kernel"
cd kernel && make clean && make ARCH=arm64 $KERNEL_DEFCONFIG && make ARCH=arm64 $KERNEL_DTS.img -j64 && cd -
if [ $? -eq 0 ]; then
echo "Build kernel ok!"
else
echo "Build kernel failed!"
exit 1
fi
fi
echo "package resoure.img with charger images"
cd u-boot && ./scripts/pack_resource.sh ../kernel/resource.img && cp resource.img ../kernel/resource.img && cd -
# build android
if [ "$BUILD_ANDROID" = true ] ; then
echo "start build android"
make installclean
make -j64
if [ $? -eq 0 ]; then
echo "Build android ok!"
else
echo "Build android failed!"
exit 1
fi
fi
# mkimage.sh
echo "make and copy android images"
./mkimage.sh
if [ $? -eq 0 ]; then
echo "Make image ok!"
else
echo "Make image failed!"
exit 1
fi
if [ "$BUILD_OTA" = true ] ; then
INTERNAL_OTA_PACKAGE_OBJ_TARGET=obj/PACKAGING/target_files_intermediates/$TARGET_PRODUCT-target_files-*.zip
INTERNAL_OTA_PACKAGE_TARGET=$TARGET_PRODUCT-ota-*.zip
echo "generate ota package"
make otapackage -j4
./mkimage.sh ota
cp $OUT/$INTERNAL_OTA_PACKAGE_TARGET $IMAGE_PATH/
cp $OUT/$INTERNAL_OTA_PACKAGE_OBJ_TARGET $IMAGE_PATH/
fi
if [ "$BUILD_UPDATE_IMG" = true ] ; then
mkdir -p $PACK_TOOL_DIR/rockdev/Image/
cp -f $IMAGE_PATH/* $PACK_TOOL_DIR/rockdev/Image/
echo "Make update.img"
cd $PACK_TOOL_DIR/rockdev && ./mkupdate.sh
if [ $? -eq 0 ]; then
echo "Make update image ok!"
else
echo "Make update image failed!"
exit 1
fi
cd -
mv $PACK_TOOL_DIR/rockdev/update.img $IMAGE_PATH/
rm $PACK_TOOL_DIR/rockdev/Image -rf
fi
if [ "$BUILD_PACKING" = true ] ; then
echo "make and copy packaging in IMAGE "
mkdir -p $STUB_PATH
#Generate patches
.repo/repo/repo forall -c "$PROJECT_TOP/device/rockchip/common/gen_patches_body.sh"
#Copy stubs
cp commit_id.xml $STUB_PATH/manifest_${DATE}.xml
mkdir -p $STUB_PATCH_PATH/kernel
cp kernel/.config $STUB_PATCH_PATH/kernel
cp kernel/vmlinux $STUB_PATCH_PATH/kernel
mkdir -p $STUB_PATH/IMAGES/
cp $IMAGE_PATH/* $STUB_PATH/IMAGES/
cp build.sh $STUB_PATH/build.sh
#Save build command info
echo "UBOOT: defconfig: $UBOOT_DEFCONFIG" >> $STUB_PATH/build_cmd_info.txt
echo "KERNEL: defconfig: $KERNEL_DEFCONFIG, dts: $KERNEL_DTS" >> $STUB_PATH/build_cmd_info.txt
echo "ANDROID:$DEVICE-$BUILD_VARIANT" >> $STUB_PATH/build_cmd_info.txt
echo "FINGER:$BUILD_ID/$BUILD_NUMBER/$BUILD_VARIANT" >> $STUB_PATH/build_cmd_info.txt
fi