f554bcdf54
For msm targets, always generate boot.img with uncompressed Image. Change-Id: I06c7594f3880f8bbee77dda8747a6975fa5bdb1f Signed-off-by: Elliot Berman <eberman@codeaurora.org>
253 lines
8.4 KiB
Plaintext
253 lines
8.4 KiB
Plaintext
# 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
|
|
CONFIG_TARGET=msm.${MSM_ARCH}
|
|
|
|
################################################################################
|
|
##
|
|
function compile_external_dtc() {
|
|
(
|
|
OUT_DIR=${COMMON_OUT_DIR}/external/dtc
|
|
cd ${ROOT_DIR}/external/dtc
|
|
NO_PYTHON=1 CC=cc make
|
|
)
|
|
export PATH=${COMMON_OUT_DIR}/external/dtc:${PATH}
|
|
}
|
|
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*
|
|
"
|
|
|
|
################################################################################
|
|
## 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
|
|
if grep -q -v -E -e "^[+-]" $output; then
|
|
echo "========================================================"
|
|
echo "ERROR! Defconfig fragment did not apply as expected"
|
|
grep -v -E -e "^[+-]" $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}}"
|
|
}
|
|
|
|
function menuconfig() {
|
|
set +x
|
|
local orig_defconfig=$(mktemp)
|
|
local orig_config=$(mktemp)
|
|
|
|
cp ${OUT_DIR}/.config ${orig_config}
|
|
(cd ${KERNEL_DIR} && make "${TOOL_ARGS[@]}" O=${OUT_DIR} ${MAKE_ARGS} savedefconfig)
|
|
mv ${OUT_DIR}/defconfig ${orig_defconfig}
|
|
|
|
(cd ${KERNEL_DIR} && make "${TOOL_ARGS[@]}" O=${OUT_DIR} ${MAKE_ARGS} ${1:-menuconfig})
|
|
(cd ${KERNEL_DIR} && make "${TOOL_ARGS[@]}" O=${OUT_DIR} ${MAKE_ARGS} savedefconfig)
|
|
mv ${OUT_DIR}/defconfig ${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}
|
|
|
|
if [ -z "${FRAGMENT_CONFIG}" ]; then
|
|
rm "${orig_config}" "${orig_defconfig}"
|
|
exit
|
|
fi
|
|
|
|
local new_defconfig="${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG}"
|
|
local new_config="${OUT_DIR}/.config"
|
|
|
|
# CONFIGs to be added
|
|
# 'defconfig' file should have been generated.
|
|
# Diff this with the 'defconfig_base' from the previous step and extract only the lines that were added
|
|
# Finally, remove the "+" from the beginning of the lines and append it to the FRAGMENT
|
|
diff -u ${orig_defconfig} ${new_defconfig} | grep "^+CONFIG_" | sed 's/^.//' >> ${FRAGMENT_CONFIG}
|
|
|
|
# CONFIGs to be removed
|
|
configs_to_remove=`diff -u ${orig_defconfig} ${new_defconfig} | grep "^-CONFIG_" | sed 's/^.//'`
|
|
for config_del in $configs_to_remove; do
|
|
sed -i "/$config_del/d" ${FRAGMENT_CONFIG}
|
|
done
|
|
|
|
# CONFIGs that are unset in base defconfig (# CONFIG_X is not set), but enabled in fragments,
|
|
# the diff is shown as: -# CONFIG_X is not set. Hence, explicitly set them in the config fragments.
|
|
configs_to_set=`diff -u ${orig_defconfig} ${new_defconfig} | grep "^-# CONFIG_" | awk '{print $2}'`
|
|
for config_to_set in $configs_to_set; do
|
|
# The CONFIG could be set as 'm' in the previous steps. Ignore setting them to 'y'
|
|
if ! grep -q "$config_to_set" ${FRAGMENT_CONFIG}; then
|
|
echo $config_to_set=y >> ${FRAGMENT_CONFIG}
|
|
fi
|
|
done
|
|
|
|
# CONFIGs that are set in base defconfig (or lower fragment), but wanted it to be disabled in FRAG_CONFIG
|
|
diff -u ${orig_config} ${new_config} | grep "^+# CONFIG_" | sed 's/^.//' >> ${FRAGMENT_CONFIG}
|
|
|
|
echo
|
|
echo "Updated ${FRAGMENT_CONFIG}"
|
|
echo
|
|
|
|
rm "${orig_config}" "${orig_defconfig}"
|
|
exit
|
|
}
|
|
export -f menuconfig
|
|
|
|
################################################################################
|
|
## 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 -v ${module_list_flag} - > ${MODULES_STAGING_DIR}/vendor_dlkm.modules.load
|
|
|
|
VENDOR_DLKM_MODULES_LIST="${MODULES_STAGING_DIR}/vendor_dlkm.modules.load"
|
|
fi
|
|
}
|
|
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
|
|
|
|
################################################################################
|
|
## Miscellaneous
|
|
if [ -n "${EXTRA_CONFIGS}" ]; then
|
|
for extra_config in "${EXTRA_CONFIGS}"
|
|
do
|
|
. ${extra_config}
|
|
done
|
|
fi
|