Present fragment config logic is target specific and located in the scripts/gki folder. The script does not scale well to different targets which may have different types of variants. Migrate fragment config logic to build.config files, where the variant stitching can be described in the relevant build.config.msm.target file. The fragment stitching logic must also be in kernel/build system in order to respect any Make invocation arguments (e.g. compiler). Change-Id: I77454c2b431b3f5c0ce75a17714b43913c03ced4 Signed-off-by: Elliot Berman <eberman@codeaurora.org>
159 lines
5.3 KiB
Plaintext
159 lines
5.3 KiB
Plaintext
CONFIG_DIR=arch/${ARCH}/configs
|
|
CC="${ROOT_DIR}/common/scripts/gcc-wrapper.py ${CC}"
|
|
|
|
################################################################################
|
|
## DTB general support
|
|
DTB_DIR=vendor/qcom
|
|
|
|
function clean_dtbs() {
|
|
rm -rf ${OUT_DIR}/arch/${ARCH}/boot/dts
|
|
}
|
|
append_cmd POST_DEFCONFIG_CMDS 'clean_dtbs'
|
|
|
|
FILES+="
|
|
arch/${ARCH}/boot/dts/${DTB_DIR}/*.dtb*
|
|
"
|
|
|
|
################################################################################
|
|
## DT 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
|
|
|
|
################################################################################
|
|
## 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
|
|
KCONFIG_CONFIG=${KERNEL_DIR}/arch/${ARCH}/configs/${DEFCONFIG} \
|
|
${KERNEL_DIR}/scripts/kconfig/merge_config.sh \
|
|
-m -r ${DEFCONFIG_FRAGMENTS}
|
|
}
|
|
append_cmd PRE_DEFCONFIG_CMDS "merge_defconfig_fragments"
|
|
|
|
# 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
|
|
# Configuration options to build images for MSM targets
|
|
# Must be included AFTER build.config.msm.<target>
|
|
|
|
MODULES_LIST=${KERNEL_DIR}/modules.list.${CONFIG_TARGET}
|
|
|
|
# boot image macros
|
|
BUILD_BOOT_IMG=1
|
|
BUILD_INITRAMFS=1
|
|
|
|
################################################################################
|
|
## 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
|
|
function determine_result_image {
|
|
if [[ $(${KERNEL_DIR}/scripts/config \
|
|
--file ${OUT_DIR}/.config \
|
|
--state CONFIG_BUILD_${ARCH^^}_UNCOMPRESSED_KERNEL) \
|
|
== 'y' ]];
|
|
then
|
|
KERNEL_BINARY=Image
|
|
else
|
|
KERNEL_BINARY=Image.gz
|
|
fi
|
|
}
|
|
append_cmd DIST_CMDS 'determine_result_image'
|