-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.sh
executable file
·138 lines (117 loc) · 3.42 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
#!/bin/bash
##
# Copyright (C) 2015, Samsung Electronics, Co., Ltd.
# Written by System S/W Group, S/W Platform R&D Team,
# Mobile Communication Division.
#
# Edited by Remilia Scarlet (remilia15)
##
set -e -o pipefail
PLATFORM=sc8830
DEFCONFIG=rz_gpve_defconfig
NAME=RZ_kernel
VERSION=v3.5
export ARCH=arm
export LOCALVERSION=-${VERSION}
KERNEL_PATH=$(pwd)
KERNEL_ZIP=${KERNEL_PATH}/kernel_zip
KERNEL_ZIP_NAME=${NAME}_${VERSION}.zip
KERNEL_IMAGE=${KERNEL_ZIP}/tools/Image
DT_IMG=${KERNEL_ZIP}/tools/dt.img
EXTERNAL_MODULE_PATH=${KERNEL_PATH}/external_module
OUTPUT_PATH=${KERNEL_PATH}/output
JOBS=`grep processor /proc/cpuinfo | wc -l`
# Colors
cyan='\033[0;36m'
yellow='\033[0;33m'
red='\033[0;31m'
nocol='\033[0m'
function build() {
clear;
BUILD_START=$(date +"%s");
echo -e "$cyan"
echo "***********************************************";
echo " Compiling RZ kernel ";
echo -e "***********************************************$nocol";
echo -e "$red";
if [ ! -e ${OUTPUT_PATH} ]; then
mkdir ${OUTPUT_PATH};
fi;
echo -e "Initializing defconfig...$nocol";
make O=output ${DEFCONFIG};
echo -e "$red";
echo -e "Building kernel...$nocol";
make O=output -j${JOBS};
make O=output -j${JOBS} dtbs;
./scripts/mkdtimg.sh -i ${KERNEL_PATH}/arch/arm/boot/dts/ -o dt.img;
find ${KERNEL_PATH} -name "Image" -exec mv -f {} ${KERNEL_ZIP}/tools \;
find ${KERNEL_PATH} -name "dt.img" -exec mv -f {} ${KERNEL_ZIP}/tools \;
BUILD_END=$(date +"%s");
DIFF=$(($BUILD_END - $BUILD_START));
echo -e "$yellow";
echo -e "Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds.$nocol";
}
function make_zip() {
echo -e "$red";
echo -e "Making flashable zip...$nocol";
cd ${KERNEL_PATH}/kernel_zip;
zip -r ${KERNEL_ZIP_NAME} ./;
mv ${KERNEL_ZIP_NAME} ${KERNEL_PATH};
}
function rm_if_exist() {
if [ -e $1 ]; then
rm -rf $1;
fi;
}
function clean() {
echo -e "$red";
echo -e "Cleaning build environment...$nocol";
make -j${JOBS} mrproper;
rm_if_exist ${KERNEL_ZIP_NAME};
rm_if_exist ${OUTPUT_PATH};
rm_if_exist ${DT_IMG};
echo -e "$yellow";
echo -e "Done!$nocol";
}
function main() {
clear;
read -p "Please specify Toolchain path: " tcpath;
if [ "${tcpath}" == "" ]; then
echo -e "$red"
export CROSS_COMPILE=/home/natsume/toolchain/linaro-4.9/bin/arm-eabi-;
echo -e "No toolchain path found. Using default local one:$nocol ${CROSS_COMPILE}";
else
export CROSS_COMPILE=${tcpath};
echo -e "$red";
echo -e "Specified toolchain path: $nocol ${CROSS_COMPILE}";
fi;
if [ "${USE_CCACHE}" == "1" ]; then
CCACHE_PATH=/usr/bin/ccache;
export CROSS_COMPILE="${CCACHE_PATH} ${CROSS_COMPILE}";
export JOBS=8;
echo -e "$red";
echo -e "You have enabled ccache through *export USE_CCACHE=1*, now using ccache...$nocol";
fi;
echo -e "***************************************************************";
echo " RZ Kernel for Samsung Galaxy Grand Prime SM-G531H";
echo -e "***************************************************************";
echo "Choices:";
echo "1. Cleanup source";
echo "2. Build kernel";
echo "3. Build kernel then make flashable ZIP";
echo "4. Make flashable ZIP package";
echo "Leave empty to exit this script (it'll show invalid choice)";
read -n 1 -p "Select your choice: " -s choice;
case ${choice} in
1) clean;;
2) build;;
3) build
make_zip;;
4) make_zip;;
*) echo
echo "Invalid choice entered. Exiting..."
sleep 2;
exit 1;;
esac
}
main $@