-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildzf2
executable file
·138 lines (125 loc) · 3.34 KB
/
buildzf2
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
#!/bin/bash
export ARCH=x86_64
export CCOMPILE=$CROSS_COMPILE
export CROSS_COMPILE=x86_64-linux-android-
#Change Toolchain GCC versions from here
#But I personally prefer Google's x86_64-linux-android-4.9
GCC_VERSION=4.9
TC_PREFIX=x86_64-linux-android
TOOLCHAIN=$TC_PREFIX-$GCC_VERSION
CUR_DIR=$PWD
clear
echo "---------------SETTING UP ENVIRONMENT---------------"
start=`date +%s`
NOW=$(date +"%d-%m-%Y")
echo "Current Date : $NOW"
echo "Applying Build Settings"
export SLEEP=1
echo "Setting CPU Cores/Threads"
export CPUS=`nproc`
echo "Setting Version Number"
export VER=v1$1
echo "Setting Defconfig"
export DEFCONFIG=zenfone2_defconfig
echo "Setting bzImage Location"
export BZIMAGE=arch/x86/boot/bzImage
echo "Environment Setup Complete Now Moving To Compiling"
echo ""
echo ""
echo ""
echo "-----CHECKING IF TOOLCHAIN IS IN CORRECT PATH-------"
sleep $SLEEP
cd ..
TC=$PWD
if [ -f $TC/$TOOLCHAIN/bin/$TC_PREFIX-gcc ];
then
cd $CUR_DIR
echo "ToolChain exists"
echo "Starting Compilation"
echo "SETTING TOOLCHAIN PATH : $TC/$TOOLCHAIN/bin"
export PATH=$TC/$TOOLCHAIN/bin-ccache:$TC/$TOOLCHAIN/bin:$PATH
echo ""
echo ""
echo ""
sleep $SLEEP
echo "------------------COMPILING----------------------"
else
echo "Could not find toolchain at $TC/$TOOLCHAIN/"
echo "DOWNLOADING TOOLCAHIN"
git clone https://github.com/Zenfone2-development/x86_64-linux-android-$GCC_VERSION
echo "Starting Compilation"
echo "SETTING TOOLCHAIN PATH : $TC/$TOOLCHAIN/bin"
export PATH=$TC/$TOOLCHAIN/bin-ccache:$TC/$TOOLCHAIN/bin:$PATH
echo ""
echo ""
echo ""
sleep $SLEEP
cd $CUR_DIR
echo "------------------COMPILING----------------------"
fi
#Build
sleep $SLEEP
#make clean
echo "Starting Build Process"
export USE_CCACHE=1
sleep $SLEEP
if [ -f .config ];
then
echo ".config exists"
echo "Starting Compilation"
echo ""
echo ""
echo ""
echo "------------------COMPILING----------------------"
sleep $SLEEP
else
echo ".config Does Not Exists"
echo "Compiling From $DEFCONFIG"
make $DEFCONFIG
echo "Starting Compilation"
sleep $SLEEP
fi
make $EV -j$CPUS 2>&1 | tee build.log
if [ -f $BZIMAGE ];
then
echo "$BZIMAGE exists"
echo "-------------------SUCCESS-----------------------"
echo ""
echo ""
echo ""
sleep $SLEEP
else
echo "-----------------------------------ERROR------------------------------------"
echo " Failed to compile. Please Check *build.log* For Compile Errors"
echo "-----------------------------------ERROR------------------------------------"
echo "exiting script"
sleep $SLEEP
exit 0
fi
clear
echo "--------------------PACKING-------------------------"
echo "Starting Packing To Recovery Flashable Zip"
cd out/
echo "Removing Old Files"
rm -rf bzImage *.zip
sleep $SLEEP
echo "Copying bzImage"
mv ../arch/x86/boot/bzImage bzImage
sleep $SLEEP
echo "Compiling Atom7_"$VER".zip"
find . -type f -exec zip Atom7_"$VER".zip {} +
nowf=$(date +"%T")
cd ..
echo "Current Date : $NOW"
echo "Applying Build Settings : done"
echo "Version Number = $VER"
echo "cleaning previous files : done"
echo "Starting Build Process : done"
echo "Build complete"
end=`date +%s`
runtime=$((end-start))
echo "Completion Time :"
echo "$runtime sec\n"
echo "------------------- CLEANING------------------------"
make clean && make mrproper
echo "----------------------DONE--------------------------"