-
Notifications
You must be signed in to change notification settings - Fork 430
/
build.config.msm.common
243 lines (216 loc) · 7.97 KB
/
build.config.msm.common
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# The following additional environment variables are considered when build.config.msm.common is
# included:
#
# DT_OVERLAY_SUPPORT
# If set, then create a dtbo.img
# BUILD_VENDOR_DLKM
# If set, then enables creation of vendor_dlkm.img using all modules
# not part of the first-stage ramdisk
# EXTRA_CONFIGS
# All files in this list are sourced
CONFIG_DIR=arch/${ARCH}/configs
BRANCH=msm-waipio
if [ -z $CONFIG_TARGET ]; then
CONFIG_TARGET=msm.${MSM_ARCH}
fi
################################################################################
##
function compile_external_dtc() {
(
OUT_DIR=${COMMON_OUT_DIR}/external/dtc
[ "${SKIP_MRPROPER}" != "1" ] && rm -rf ${OUT_DIR}
cd ${ROOT_DIR}/external/dtc
DTC_MAKE_ARGS=("CC=${HOSTCC}" "AR=${AR}")
DTC_MAKE_ARGS+=("LDFLAGS=${HOSTLDFLAGS} -fuse-ld=${LD##*.} --rtlib=compiler-rt")
DTC_MAKE_ARGS+=("EXTRA_CFLAGS=${HOSTCFLAGS}")
# PKG_CONFIG would pull from host environment to determine if libyaml and libpython are
# available. We want a hermetic build that doesn't rely on host tools, so make dtc build think
# none of these libraries are installed.
DTC_MAKE_ARGS+=("PKG_CONFIG=false")
make all install "${DTC_MAKE_ARGS[@]}" NO_PYTHON=1 PREFIX=${COMMON_OUT_DIR}/host
)
}
append_cmd PRE_DEFCONFIG_CMDS 'compile_external_dtc'
################################################################################
## DTB general support
DTB_DIR=vendor/qcom
MAKE_GOALS+=" dtbs"
function clean_dtbs() {
rm -rf ${OUT_DIR}/arch/${ARCH}/boot/dts/${DTB_DIR}/*
}
append_cmd POST_DEFCONFIG_CMDS 'clean_dtbs'
FILES+="
arch/${ARCH}/boot/dts/${DTB_DIR}/*.dtb*
.config
Module.symvers
"
################################################################################
## DT Overlay
DTC_OVERLAY_TEST_EXT=ufdt_apply_overlay
function add_dt_overlay_defconfig() {
${KERNEL_DIR}/scripts/config --file ${OUT_DIR}/.config \
-e BUILD_ARM64_DT_OVERLAY
(cd ${KERNEL_DIR} && make "${TOOL_ARGS[@]}" O=${OUT_DIR} "${MAKE_ARGS[@]}" olddefconfig)
}
if [ ! -z $DT_OVERLAY_SUPPORT ] && [ ! $DT_OVERLAY_SUPPORT -eq "0" ]; then
append_cmd POST_DEFCONFIG_CMDS 'add_dt_overlay_defconfig'
fi
################################################################################
## Variant Selection
if [ -z "${VARIANT}" ] || [ "${VARIANT}" == "default" ]; then
VARIANT="${VARIANTS[0]}"
fi
if [ ! -z $MSM_ARCH ]; then
BRANCH+=-${MSM_ARCH}
fi
if [ ! -z $VARIANT ]; then
BRANCH+=-${VARIANT}
fi
if ( for v in "${VARIANTS[@]}"; do if [ "${v}" = "${VARIANT}" ]; then exit 1; fi; done; exit 0 ) ; then
echo "Unsupported variant '${VARIANT}'"
exit 1
fi
################################################################################
## defconfigs
# Helper function to let build.config files merge config fragments
# Usage: append_cmd PRE_DEFCONFIG_CMDS 'merge_defconfig_fragment ${DEFCONFIG} ${fragment_config}'
DEFCONFIG_FRAGMENTS=""
function merge_defconfig_fragments() {
if ( [ -z "${DEFCONFIG_FRAGMENTS}" ] ||
[ "${DEFCONFIG_FRAGMENTS}" = "${DEFCONFIG}" ] ); then
echo "No defconfig fragments for ${DEFCONFIG}"
return
fi
local output=$(mktemp)
KCONFIG_CONFIG=${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG} \
${KERNEL_DIR}/scripts/kconfig/merge_config.sh \
-m -r -y ${DEFCONFIG_FRAGMENTS} | tee $output
set +x
if grep -q -E -e "Previous value: [^=]+=[ym]" $output; then
echo "========================================================"
echo "ERROR! Detected overridden config!"
grep -C 1 -E -e "Previous value: [^=]+=[ym]" $output >&2
rm $output
exit 1
fi
local temp_config=$(mktemp)
(cd ${KERNEL_DIR} && KCONFIG_CONFIG=${temp_config} make "${TOOL_ARGS[@]}" O=${OUT_DIR} "${MAKE_ARGS[@]}" ${DEFCONFIG}) 2>&1 | tee $output
if grep -q -e "warning:" $output; then
echo "========================================================"
echo "ERROR! Treating config warnings as errors"
grep -e "warning" $output >&2
rm $output $temp_config
exit 1
fi
rm $output $temp_config
set -x
}
append_cmd PRE_DEFCONFIG_CMDS "merge_defconfig_fragments"
function check_merged_defconfig() {
if ( [ -z "${DEFCONFIG_FRAGMENTS}" ] ||
[ "${DEFCONFIG_FRAGMENTS}" = "${DEFCONFIG}" ] ); then
return
fi
local output=$(mktemp)
${KERNEL_DIR}/scripts/diffconfig "${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}" ${OUT_DIR}/.config > $output
set +x
# Allow CONFIG_CMDLINE changes
if grep -q -v -E -e "^\+" -e "^CMDLINE " $output; then
echo "========================================================"
echo "ERROR! Defconfig fragment did not apply as expected"
grep -v -E -e "^\+" -e "^CMDLINE " $output
rm $output
exit 1
fi
rm $output
set -x
}
append_cmd POST_DEFCONFIG_CMDS "check_merged_defconfig"
# Wrapper function around merge_defconfig_fragment to reduce repeated logic
# Usage: apply_defconfig_fragment ${KERNEL_DIR}/cuttlefish.fragment cuttlefish-gki_defconfig
function apply_defconfig_fragment() {
FRAGMENT_CONFIG=$1
if [ -z "${DEFCONFIG_FRAGMENTS}" ]; then
DEFCONFIG_FRAGMENTS="${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}"
fi
DEFCONFIG_FRAGMENTS="${DEFCONFIG_FRAGMENTS} $1"
DEFCONFIG="${2:-${DEFCONFIG}}"
}
################################################################################
## DLKMs
if [ -e "${KERNEL_DIR}/modules.list.${CONFIG_TARGET}" ]; then
MODULES_LIST=${KERNEL_DIR}/modules.list.${CONFIG_TARGET}
fi
if [ -e "${KERNEL_DIR}/modules.blocklist.${CONFIG_TARGET}" ]; then
MODULES_BLOCKLIST="${KERNEL_DIR}/modules.blocklist.${CONFIG_TARGET}"
VENDOR_DLKM_MODULES_BLOCKLIST="${KERNEL_DIR}/modules.blocklist.${CONFIG_TARGET}"
fi
function prepare_vendor_dlkm() {
if [ -z "${VENDOR_DLKM_MODULES_LIST}" ]; then
local module_list_flag=
if [ -e "${MODULES_LIST}" ]; then
module_list_flag="-f ${MODULES_LIST}"
else
module_list_flag="-e ''"
fi
(cd "${MODULES_STAGING_DIR}/lib/modules/" && find -type f -name "*.ko" -printf "%f\n") | \
grep -w -v ${module_list_flag} - > ${MODULES_STAGING_DIR}/vendor_dlkm.modules.load
VENDOR_DLKM_MODULES_LIST="${MODULES_STAGING_DIR}/vendor_dlkm.modules.load"
fi
SUPER_IMAGE_CONTENTS+="${DIST_DIR}/vendor_dlkm.img"
}
if [ "${BUILD_VENDOR_DLKM}" == "1" ]; then
append_cmd DIST_CMDS 'prepare_vendor_dlkm'
if [ -e "${KERNEL_DIR}/modules.vendor_blocklist.${CONFIG_TARGET}" ]; then
VENDOR_DLKM_MODULES_BLOCKLIST="${KERNEL_DIR}/modules.vendor_blocklist.${CONFIG_TARGET}"
fi
fi
KERNEL_BINARY=Image
################################################################################
## DT Overlay
LIBUFDT_PREBUILTS_BIN=tools/libufdt/utils/src
function make_dtbo_img() {
mkdir -p ${DIST_DIR}/
mkdtboimg.py create ${DIST_DIR}/dtbo.img --page_size=${PAGE_SIZE} ${DIST_DIR}/*.dtbo
}
if [ ! -z $DT_OVERLAY_SUPPORT ] && [ ! $DT_OVERLAY_SUPPORT -eq "0" ]; then
append_cmd DIST_CMDS 'make_dtbo_img'
fi
################################################################################
## Cating all the DTBs and create a dtb.img
function make_dtb_img() {
mkdir -p ${DIST_DIR}/
mkdtboimg.py create ${DIST_DIR}/${MSM_ARCH}-dtb.img --page_size=${PAGE_SIZE} ${DIST_DIR}/*.dtb
}
if [ ! -z $DTB_IMG_CREATE ] && [ ! $DTB_IMG_CREATE -eq "0" ]; then
append_cmd DIST_CMDS 'make_dtb_img'
fi
################################################################################
## Miscellaneous
if [ -n "${EXTRA_CONFIGS}" ]; then
for extra_config in "${EXTRA_CONFIGS}"
do
. ${extra_config}
done
fi
################################################################################
## Copy prebuilt files to ${COMMON_OUT_DIR}/host/bin to be used by CI tools
DIST_BINS="""
build/android/merge_dtbs.py
build/build-tools/path/linux-x86/ufdt_apply_overlay
"""
function copy_dist_bins() (
set +x
set -e
mkdir -p ${COMMON_OUT_DIR}/host/bin
echo "Copying binaries to host/bin"
for FILE in $(ls -1 ${DIST_BINS}); do
if [ -f ${ROOT_DIR}/${FILE} ]; then
echo " $FILE"
cp -p ${ROOT_DIR}/${FILE} ${COMMON_OUT_DIR}/host/bin/
else
echo " $FILE is not a file, skipping"
fi
done
)
append_cmd DIST_CMDS 'copy_dist_bins'