forked from nathanchance/env
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel
More file actions
executable file
·126 lines (100 loc) · 3.47 KB
/
kernel
File metadata and controls
executable file
·126 lines (100 loc) · 3.47 KB
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
#!/usr/bin/env bash
#
# Script to build a zImage from a kernel tree
#
# Copyright (C) 2017 Nathan Chancellor
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# SOURCE OUR UNIVERSAL FUNCTIONS SCRIPT AND MAC CHECK
source common
# START TIME
START=$(date +%s)
# GATHER PARAMETERS
while [[ $# -ge 1 ]]; do
case ${1} in
# ARCHITECTURE TO BUILD; DEFAULTS TO ARM64
"-a"|"--arch")
shift && enforce_value $@
ARCH=${1} ;;
# DEFCONFIG TO BUILD; DEFAULTS TO FLASH_DEFCONFIG
"-d"|"--defconfig")
shift && enforce_value $@
DEFCONFIG=${1} ;;
# SHOW FULL COMPILATION
"-D"|"--debug")
VERBOSITY=2 ;;
# IMAGE TO TARGET; DEFAULTS TO IMAGE.GZ-DTB
"-i"|"--image")
shift && enforce_value $@
IMAGE=${1} ;;
# TOOLCHAIN TO COMPILE WITH; DEFAULTS TO A73 TARGETED LINARO 7.x
"-t"|"--toolchain")
shift && enforce_value $@
case ${1} in
"a-4.9")
TOOLCHAIN=/opt/${1}/bin/aarch64-linux-android- ;;
"g-8.x")
TOOLCHAIN=/opt/${1}/bin/aarch64-gnu-linux-gnu- ;;
*)
TOOLCHAIN=${1} ;;
esac ;;
# UPLOAD IMAGE TO TRANSFER.SH
"-u"|"--upload")
UPLOAD=true ;;
# SHOW WARNINGS AND ERRORS DURING COMPILATION
"-w"|"--warnings")
VERBOSITY=1 ;;
esac
shift
done
# DEFAULTS FOR FLASH KERNEL FOR OP5
[[ -z ${ARCH} ]] && ARCH=arm64
[[ -z ${DEFCONFIG} ]] && DEFCONFIG=flash_defconfig
[[ -z ${IMAGE} ]] && IMAGE=Image.gz-dtb
[[ -z ${TOOLCHAIN} ]] && TOOLCHAIN=/opt/l-7.x-a73/bin/aarch64-linaro-linux-android-
# BASIC BUILD FUNCTION
function build() {
# SET MAKE VARIABLE
MAKE="make ${JOBS_FLAG} O=out ARCH=${ARCH}"
# REMOVE OUT FOLDER AND REMAKE IT
rm -rf out && mkdir out && echo
# MAKE DEFCONFIG
${MAKE} ${DEFCONFIG}
# MAKE KERNEL
time ${MAKE} CROSS_COMPILE="$(command -v ccache) ${TOOLCHAIN}"
}
# REPORT ERROR IF WE AREN'T IN A TREE WITH A MAKEFILE
[[ ! -f $(pwd)/Makefile ]] && report_error "This must be run in a kernel tree!"
# SHOW THE BASE VERSION WE ARE MAKING
header "BUILDING $(make kernelversion)"
# SHOW COMPILATION BASED ON FLAGS
case ${VERBOSITY} in
"2")
build ;;
"1")
build |& ag --nocolor "error:|warning" ;;
*)
build &> /dev/null ;;
esac
# REPORT SUCCESS
FINAL_IMAGE=out/arch/${ARCH}/boot/${IMAGE}
END=$(date +%s)
[[ -f ${FINAL_IMAGE} ]] && echo "\n${GRN}BUILT IN $(format_time ${END} ${START})${RST}\n
${BOLD}IMAGE:${RST} ${FINAL_IMAGE}\n
${BOLD}VERSION:${RST} $(cat out/include/config/kernel.release)" \
|| report_error "Kernel build failed!"
# UPLOAD IMAGE IF NECESSARY
[[ ${UPLOAD} = true ]] && echo && curl --upload-file ${FINAL_IMAGE} https://transfer.sh/"${IMAGE}"
# ALERT OF SCRIPT END
echo "\n\a"