-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·98 lines (88 loc) · 2.18 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
#!/usr/bin/env bash
# Check result function
function check_result {
if [ "0" -ne "$?" ]
then
(repo forall -c "git reset --hard") >/dev/null
echo -e $CL_RED$1
exit 1
fi
}
# Fix libraries
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
# CCache
export USE_CCACHE=1
export CCACHE_NLEVELS=4
export PATH=~/bin:$PATH
export PATH="$PATH:/opt/local/bin/:$WORKSPACE/$ROM_NAME/prebuilts/misc/$(uname|awk '{print tolower($0)}')-x86/ccache"
case $REPO_BRANCH in
"cm-10"* | "omni-4.3" )
export CCACHE_DIR=~/.jb_ccache ;;
"cm-11"* | "omni-4.4" )
export CCACHE_DIR=~/.kk_ccache ;;
*)
export CCACHE_DIR=~/.ccache ;;
esac
ccache -M 50G
# Build directory
export JENKINS_BUILD_DIR="$ROM_NAME"
mkdir -p $JENKINS_BUILD_DIR
cd $JENKINS_BUILD_DIR
# Syncing
if [ $SYNC = "true" ]
then
rm -rf kernel/*
rm -rf .repo/manifests*
rm -f .repo/local_manifests/dyn-*.xml
repo init -u https://github.com/TeamCanjica/android.git -b $REPO_BRANCH
check_result "Repo init failed!"
echo -e $CL_BLU"Syncing..."$CL_RST
repo sync -f -d -c
check_result "Repo sync failed!"
echo -e $CL_GRN"Sync complete."$CL_RST
fi
# Cherrypicking
if [ "$CHERRYPICK" = "true" ]
then
. $WORKSPACE/BuildBot/cherry-pick.sh
check_result "Cherrypicking failed!"
echo -e $CL_GRN"Cherrypicking Complete"$CL_RST
fi
# Get prebuilts
if [ $ROM_NAME = "cm" ]
then
./vendor/cm/get-prebuilts
fi
# Set environment and lunch
. build/envsetup.sh
lunch $LUNCH
check_result "Lunch failed!"
# Clean
if [ $CLEAN = "true" ]
then
echo -e $CL_BLU"Cleaning..."$CL_RST
make clobber
echo -e $CL_GRN"Clean complete!"$CL_RST
else
echo -e $CL_YLW"Cleaning skipped, removing only last built package."$CL_RST
rm -f out/target/product/$DEVICE/cm-*
rm -f out/target/product/$DEVICE/system/build.prop
fi
# Start Build
if [ "$SINGLE_PACKAGE" = "false" ]
then
echo -e $CL_MAG"Building..."$CL_RST
time mka bacon
check_result "Build failed!"
echo -e $CL_GRN""$DEVICE" build finished!"$CL_RST
else
echo -e $CL_BLU"Building single package only: $PACKAGE_NAME"$CL_RST
if [ $PACKAGE_NAME = "*/*" ]
then
time mmm $PACKAGE_NAME
else
time mka $PACKAGE_NAME
fi
check_result "Build failed!"c
echo -e $CL_GRN"Package build finished!"$CL_RST
fi