-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_slider.sh
executable file
·139 lines (126 loc) · 4.71 KB
/
build_slider.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
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
function exit_if_error {
if [ $1 -ne 0 ]; then
echo "ERROR: $2: retval=$1" >&2
exit $1
fi
}
function copy_gki_prebuilts {
mkdir -p ${DIST_DIR}
echo "Copying GKI prebuilts from ${GKI_PREBUILTS_DIR} to ${DIST_DIR}."
cp ${GKI_PREBUILTS_DIR}/* ${DIST_DIR}/
}
function build_gki {
echo "Building GKI kernel using ${KERNEL_BUILD_CONFIG}..."
SKIP_CP_KERNEL_HDR=1 \
OUT_DIR=${BASE_OUT}/${KERNEL_OUT_DIR} \
DIST_DIR=${DIST_DIR} \
LTO=${LTO} \
KMI_SYMBOL_LIST_STRICT_MODE=${ENABLE_STRICT_KMI} \
TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI} \
BUILD_CONFIG=${KERNEL_BUILD_CONFIG} \
build/build.sh KCFLAGS=-Werror "$@"
exit_if_error $? "Failed to compile ${KERNEL_OUT_DIR}"
}
function build_pixel {
echo "Building device kernel..."
BUILD_CONFIG=${DEVICE_KERNEL_BUILD_CONFIG} \
OUT_DIR=${BASE_OUT}/device-kernel/ \
DIST_DIR=${DIST_DIR} \
LTO=${LTO} \
MIXED_BUILD=1 \
KBUILD_MIXED_TREE=${GKI_BINARIES_DIR} \
KMI_SYMBOL_LIST_STRICT_MODE=${ENABLE_STRICT_KMI} \
TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI} \
build/build.sh KCFLAGS=-Werror "$@"
exit_if_error $? "Failed to compile device kernel"
}
EXPERIMENTAL_BUILD=${EXPERIMENTAL_BUILD:-0}
BASE_OUT=${OUT_DIR:-out}/mixed/
DIST_DIR=${DIST_DIR:-${BASE_OUT}/dist/}
LTO=${LTO:-thin}
GKI_BINARIES_DIR=$(readlink -m ${DIST_DIR})
GKI_PREBUILTS_DIR=$(readlink -m "prebuilts/boot-artifacts/kernel/")
DEFAULT_CONFIG="private/gs-google/build.config.slider"
DEVICE_KERNEL_BUILD_CONFIG=${DEVICE_KERNEL_BUILD_CONFIG:-${DEFAULT_CONFIG}}
TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI:-1}
CHECK_DIRTY_AOSP=0
if [ -z "${BUILD_KERNEL}" ]; then
if [ "${EXPERIMENTAL_BUILD}" != "0" -o -n "${GKI_DEFCONFIG_FRAGMENT}" ]; then
BUILD_KERNEL=1
else
CHECK_DIRTY_AOSP=1
BUILD_KERNEL=0
fi
fi
if [ "${LTO}" = "none" ]; then
ENABLE_STRICT_KMI=0
else
ENABLE_STRICT_KMI=${ENABLE_STRICT_KMI:-1}
fi
if [ "${EXPERIMENTAL_BUILD}" != "0" ]; then
KERNEL_OUT_DIR=android12-5.10-staging
KERNEL_BUILD_CONFIG=common/build.config.gki.aarch64
else
KERNEL_OUT_DIR=android12-5.10
KERNEL_BUILD_CONFIG=aosp/build.config.gki.aarch64
fi
if [ -n "${BUILD_ABI}" ]; then
echo "The ABI update workflow has changed. Please read go/gki-p21-workflow"
echo " for instructions on updating ABI/symbol list."
exit_if_error 1 "BUILD_ABI is deprecated"
fi
if [ -n "${BUILD_CONFIG}" ]; then
exit_if_error 1 "BUILD_CONFIG is not supported for $0"
fi
if [ "${BUILD_KERNEL}" = "0" ]; then
if [ "${EXPERIMENTAL_BUILD}" != "0" -o -n "${GKI_DEFCONFIG_FRAGMENT}" ]; then
echo "BUILD_KERNEL=0 is incompatible with EXPERIMENTAL_BUILD=1 and"
echo " GKI_DEFCONFIG_FRAGMENT."
exit_if_error 1 "Flags incompatible with BUILD_KERNEL=0 detected"
elif [ "${LTO}" = "none" ]; then
echo "LTO=none requires BUILD_KERNEL=1, EXPERIMENTAL_BUILD=1, or"
echo " GKI_DEFCONFIG_FRAGMENT to be set."
exit_if_error 1 "LTO=none requires building the kernel"
fi
fi
# If BUILD_KERNEL is not explicitly set, be sure that there are no aosp/
# changes not present in the prebuilt.
if [ "${CHECK_DIRTY_AOSP}" != "0" ]; then
PREBUILTS_SHA=$(strings ${GKI_PREBUILTS_DIR}/vmlinux |
grep "Linux version 5.10" |
sed -n "s/^.*-g\([0-9a-f]\{12\}\)-.*/\1/p")
pushd aosp/ > /dev/null
# The AOSP sha can sometimes be longer than 12 characters; fix its length.
AOSP_SHA=$(git log -1 --abbrev=12 --pretty="format:%h")
if [ "${PREBUILTS_SHA}" != "${AOSP_SHA}" -o -n \
"$(git --no-optional-locks status -uno --porcelain ||
git diff-index --name-only HEAD)" ]; then
echo "There are changes in aosp/ which are not in the prebuilts."
echo " Please set BUILD_KERNEL=1 if you wish to build these changes, or"
echo " BUILD_KERNEL=0 if you wish to disregard them and use prebuilts."
exit_if_error 1 "aosp/ changes detected without BUILD_KERNEL set"
fi
popd > /dev/null
fi
if [ "${EXPERIMENTAL_BUILD}" = "0" -a "${BUILD_KERNEL}" != "0" ]; then
pushd aosp/ > /dev/null
# Booting AOSP ToT does not always work; throw a warning to prevent this.
REPO_SHA=$(git log -1 --pretty="format:%H" m/s-dev-gs-pixel-5.10)
LOCAL_MERGE_BASE=$(git merge-base HEAD aosp/android12-5.10)
if [ "${REPO_SHA}" != "${LOCAL_MERGE_BASE}" ]; then
echo "Your aosp/ directory appears to be synced to a point beyond the"
echo " latest AOSP merge point. This is not supported, currently, as"
echo " it is prone to errors. Please base any changes on"
echo " m/s-dev-gs-pixel-5.10."
exit_if_error 1 "aosp/ is not based on m/s-dev-gs-pixel-5.10"
fi
popd > /dev/null
fi
if [ "${BUILD_KERNEL}" != "0" -o "${EXPERIMENTAL_BUILD}" != "0" ]; then
build_gki
else
copy_gki_prebuilts
fi
build_pixel