build.config: Add fragment config awareness
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>
This commit is contained in:
parent
01adee9201
commit
655afa578d
@ -40,11 +40,86 @@ if [ ! -z $VARIANT ]; then
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
## menuconfig
|
||||
## 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
|
||||
|
@ -1,11 +1,6 @@
|
||||
################################################################################
|
||||
# Common MSM configuration for building GKI-based kernels
|
||||
|
||||
function generate_defconfig() {
|
||||
${KERNEL_DIR}/scripts/gki/generate_defconfig.sh ${DEFCONFIG}
|
||||
}
|
||||
DEFCONFIG=vendor/${MSM_ARCH}-${VARIANT}_defconfig
|
||||
append_cmd PRE_DEFCONFIG_CMDS 'generate_defconfig'
|
||||
DEFCONFIG="gki_defconfig"
|
||||
|
||||
if [ -z "${GKI_RAMDISK_PREBUILT_BINARY}" ]; then
|
||||
GKI_RAMDISK_PREBUILT_BINARY=prebuilts/boot-artifacts/${ARCH}/gki-ramdisk.cpio
|
||||
@ -14,10 +9,3 @@ fi
|
||||
if [ "${BOOT_IMAGE_HEADER_VERSION}" -lt "3" ]; then
|
||||
VENDOR_RAMDISK_BINARY="${GKI_RAMDISK_PREBUILT_BINARY} ${VENDOR_RAMDISK_BINARY}"
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
## menuconfig
|
||||
function menuconfig() {
|
||||
${KERNEL_DIR}/scripts/gki/fragment_menuconfig.sh ${DEFCONFIG}
|
||||
}
|
||||
export -f menuconfig
|
||||
|
@ -30,6 +30,7 @@ KMI_WHITELIST=abi_gki_qcom_whitelist
|
||||
case "${VARIANT}" in
|
||||
gki)
|
||||
. ${KERNEL_DIR}/build.config.msm.gki
|
||||
apply_defconfig_fragment ${KERNEL_DIR}/arch/${ARCH}/configs/vendor/${MSM_ARCH}_GKI.config vendor/${MSM_ARCH}-gki_defconfig
|
||||
;;
|
||||
gki-ack)
|
||||
# In gki-only, then using ACK's GKI config directly
|
||||
|
@ -28,6 +28,7 @@ KMI_WHITELIST=abi_gki_qcom_whitelist
|
||||
case "${VARIANT}" in
|
||||
gki)
|
||||
. ${KERNEL_DIR}/build.config.msm.gki
|
||||
apply_defconfig_fragment ${KERNEL_DIR}/arch/${ARCH}/configs/vendor/${MSM_ARCH}_GKI.config vendor/${MSM_ARCH}-gki_defconfig
|
||||
;;
|
||||
gki-ack)
|
||||
# In gki-only, then using ACK's GKI config directly
|
||||
|
Loading…
Reference in New Issue
Block a user