scripts: gki: Add GKI support

Add scripts to enable a build system to compile GKI
based kernels. Specifically, the scripts allows the
build systems to build a particular variant of defconfig
and a menuconfig interface to edit fragments.

Change-Id: I26399ce1911f9484650bb9ee4658c4043c5c556c
Signed-off-by: Raghavendra Rao Ananta <rananta@codeaurora.org>
This commit is contained in:
Raghavendra Rao Ananta 2019-05-19 12:16:36 -07:00
commit 3de4bf658a
4 changed files with 224 additions and 0 deletions

27
scripts/gki/envsetup.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2019, The Linux Foundation. All rights reserved.
SCRIPT_DIR=$(readlink -f $(dirname $0)/)
cd ${SCRIPT_DIR}
cd ../../
KERN_SRC=`pwd`
: ${ARCH:=arm64}
: ${CROSS_COMPILE:=aarch64-linux-gnu-}
: ${REAL_CC:=clang}
: ${KERN_OUT:=}
CONFIGS_DIR=${KERN_SRC}/arch/${ARCH}/configs/vendor
PLATFORM_NAME=$1
BASE_DEFCONFIG=${KERN_SRC}/arch/${ARCH}/configs/gki_defconfig
# Fragements that are available for the platform
QCOM_GKI_FRAG=${CONFIGS_DIR}/${PLATFORM_NAME}_GKI.config
QCOM_QGKI_FRAG=${CONFIGS_DIR}/${PLATFORM_NAME}_QGKI.config
QCOM_DEBUG_FRAG=${CONFIGS_DIR}/${PLATFORM_NAME}_debug.config
export ARCH CROSS_COMPILE REAL_CC KERN_SRC KERN_OUT CONFIGS_DIR BASE_DEFCONFIG \
QCOM_GKI_FRAG QCOM_QGKI_FRAG QCOM_DEBUG_FRAG

View file

@ -0,0 +1,22 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2019, The Linux Foundation. All rights reserved.
# Script to convert all the =m CONFIGs to =y
usage() {
echo "Usage: $0 <input_fragment_path> <output_fragment_path>"
echo "For example $0 arch/arm64/configs/lahaina_GKI.config arch/arm64/configs/lahaina_GKI_allyes.config"
echo "Note: The output fragment file will be created or overwritten if already exists"
exit 1
}
if [ "$#" -ne 2 ]; then
echo "Error: Invalid number of arguments"
usage
fi
INPUT_FRAG=$1
OUTPUT_FRAG=$2
sed 's/=m$/=y/g' ${INPUT_FRAG} > ${OUTPUT_FRAG}

View file

@ -0,0 +1,105 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2019, The Linux Foundation. All rights reserved.
# Script to edit the kconfig fragments through menuconfig
usage() {
echo "Usage: $0 <platform_defconfig_variant>"
echo "Variants: <platform>-gki_defconfig, <platform>-qgki_defconfig, and <platform>-qgki-debug_defconfig"
echo "Example: $0 lahaina-gki_defconfig"
exit 1
}
if [ -z "$1" ]; then
echo "Error: Failed to pass input argument"
usage
fi
SCRIPTS_ROOT=$(readlink -f $(dirname $0)/)
PLATFORM_NAME=`echo $1 | sed -r "s/(-gki_defconfig|-qgki_defconfig|-qgki-debug_defconfig)$//"`
PLATFORM_NAME=`echo $PLATFORM_NAME | sed "s/vendor\///g"`
# We should be in the kernel root after the envsetup
source ${SCRIPTS_ROOT}/envsetup.sh $PLATFORM_NAME
# Allyes fragment temporarily created on GKI config fragment
QCOM_GKI_ALLYES_FRAG=${CONFIGS_DIR}/${PLATFORM_NAME}_ALLYES_GKI.config
if [ ! -f "${QCOM_GKI_FRAG}" ]; then
echo "Error: Invalid input"
usage
fi
REQUIRED_DEFCONFIG=`echo $1 | sed "s/vendor\///g"`
FINAL_DEFCONFIG_BLEND=""
case "$REQUIRED_DEFCONFIG" in
${PLATFORM_NAME}-qgki-debug_defconfig )
FINAL_DEFCONFIG_BLEND+=" $QCOM_DEBUG_FRAG"
;& # Intentional fallthrough
${PLATFORM_NAME}-qgki_defconfig )
FINAL_DEFCONFIG_BLEND+=" $QCOM_QGKI_FRAG"
${SCRIPTS_ROOT}/fragment_allyesconfig.sh $QCOM_GKI_FRAG $QCOM_GKI_ALLYES_FRAG
FINAL_DEFCONFIG_BLEND+=" $QCOM_GKI_ALLYES_FRAG "
;;
${PLATFORM_NAME}-gki_defconfig )
FINAL_DEFCONFIG_BLEND+=" $QCOM_GKI_FRAG "
;&
esac
FINAL_DEFCONFIG_BLEND+=${BASE_DEFCONFIG}
# Reverse the order of the configs for the override to work properly
# Correct order is base_defconfig GKI.config QGKI.config debug.config
FINAL_DEFCONFIG_BLEND=`echo "${FINAL_DEFCONFIG_BLEND}" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }'`
echo "defconfig blend for $REQUIRED_DEFCONFIG: $FINAL_DEFCONFIG_BLEND"
${KERN_SRC}/scripts/kconfig/merge_config.sh $FINAL_DEFCONFIG_BLEND
make savedefconfig
mv defconfig defconfig_base
mv .config .config_base
# Strip off the complete file paths and retail only the values beginning with vendor/
MENUCONFIG_BLEND=""
for config_file in $FINAL_DEFCONFIG_BLEND; do
if [[ $config_file == *"gki_defconfig" ]]; then
MENUCONFIG_BLEND+=" "`basename $config_file`" "
else
MENUCONFIG_BLEND+=" vendor/"`basename $config_file`" "
fi
done
# Start the menuconfig
make ${MENUCONFIG_BLEND} menuconfig
make savedefconfig
# The fragment file that we are targeting to edit
FRAG_CONFIG=`echo ${MENUCONFIG_BLEND} | awk 'NF>1{print $NF}' | sed 's/vendor\///'`
FRAG_CONFIG=$CONFIGS_DIR/$FRAG_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 FRAG_DEFCONFIG
diff -u defconfig_base defconfig | grep "^+CONFIG_" | sed 's/^.//' >> ${FRAG_CONFIG}
# CONFIGs to be removed
configs_to_remove=`diff -u defconfig_base defconfig | grep "^-CONFIG_" | sed 's/^.//'`
for config_del in $configs_to_remove; do
sed -i "/$config_del/d" ${FRAG_CONFIG}
done
# CONFIGs that are set in base defconfig (or lower fragment), but wanted it to be disabled in FRAG_CONFIG
diff -u .config_base .config | grep "^+# CONFIG_" | sed 's/^.//' >> ${FRAG_CONFIG}
# Cleanup the config files generated during the process
rm -f .config_base .config defconfig defconfig_base
# Cleanup the allyes config fragment that was generated
rm -f $QCOM_GKI_ALLYES_FRAG

View file

@ -0,0 +1,70 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2019, The Linux Foundation. All rights reserved.
# Script to generate a defconfig variant based on the input
usage() {
echo "Usage: $0 <platform_defconfig_variant>"
echo "Variants: <platform>-gki_defconfig, <platform>-qgki_defconfig, and <platform>-qgki-debug_defconfig"
echo "Example: $0 lahaina-gki_defconfig"
exit 1
}
if [ -z "$1" ]; then
echo "Error: Failed to pass input argument"
usage
fi
SCRIPTS_ROOT=$(readlink -f $(dirname $0)/)
PLATFORM_NAME=`echo $1 | sed -r "s/(-gki_defconfig|-qgki_defconfig|-qgki-debug_defconfig)$//"`
PLATFORM_NAME=`echo $PLATFORM_NAME | sed "s/vendor\///g"`
# We should be in the kernel root after the envsetup
source ${SCRIPTS_ROOT}/envsetup.sh $PLATFORM_NAME
# Allyes fragment temporarily created on GKI config fragment
QCOM_GKI_ALLYES_FRAG=${CONFIGS_DIR}/${PLATFORM_NAME}_ALLYES_GKI.config
if [ ! -f "${QCOM_GKI_FRAG}" ]; then
echo "Error: Invalid input"
usage
fi
REQUIRED_DEFCONFIG=`echo $1 | sed "s/vendor\///g"`
FINAL_DEFCONFIG_BLEND=""
case "$REQUIRED_DEFCONFIG" in
${PLATFORM_NAME}-qgki-debug_defconfig )
FINAL_DEFCONFIG_BLEND+=" $QCOM_DEBUG_FRAG"
;& # Intentional fallthrough
${PLATFORM_NAME}-qgki_defconfig )
FINAL_DEFCONFIG_BLEND+=" $QCOM_QGKI_FRAG"
${SCRIPTS_ROOT}/fragment_allyesconfig.sh $QCOM_GKI_FRAG $QCOM_GKI_ALLYES_FRAG
FINAL_DEFCONFIG_BLEND+=" $QCOM_GKI_ALLYES_FRAG "
;;
${PLATFORM_NAME}-gki_defconfig )
FINAL_DEFCONFIG_BLEND+=" $QCOM_GKI_FRAG "
;&
esac
FINAL_DEFCONFIG_BLEND+=${BASE_DEFCONFIG}
# Reverse the order of the configs for the override to work properly
# Correct order is base_defconfig GKI.config QGKI.config debug.config
FINAL_DEFCONFIG_BLEND=`echo "${FINAL_DEFCONFIG_BLEND}" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }'`
echo "defconfig blend for $REQUIRED_DEFCONFIG: $FINAL_DEFCONFIG_BLEND"
${KERN_SRC}/scripts/kconfig/merge_config.sh $FINAL_DEFCONFIG_BLEND
make savedefconfig
mv defconfig $CONFIGS_DIR/$REQUIRED_DEFCONFIG
# Cleanup the allyes config fragment that was generated
rm -f $QCOM_GKI_ALLYES_FRAG
# Cleanup the kernel source
make mrproper