unplugged-vendor/vendor/yft/drivers/check_script/yft_check.sh

363 lines
14 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 出错以后终止
set -e
readonly YFT_CONST_FILE_VERSION=' >>> v8.0 @ 2016-1-28 by zhoushuang <<<'
readonly YFT_CONST_FLAG_HELP="-h"
readonly YFT_CONST_FLAG_PROJECT_ASSIGN='-p'
readonly YFT_SCRIPT_TO_ROOT_APDIX="/../../../../"
readonly YFT_CONST_LOG_BUILD='dists.log'
readonly YFT_KERNEL_CONFIG_ABSOLUTE_PATH="arch/arm/configs/"
readonly YFT_KERNEL_64BIT_CONFIG_ABSOLUTE_PATH="arch/arm64/configs/"
readonly YFT_LK_CONFIG_ABSOLUTE_PATH="vendor/mediatek/proprietary/bootable/bootloader/lk/project/"
readonly YFT_LK_CONFIG_FILE_TYPE=".mk"
readonly YFT_PROJECT_CONFIG_ABSOLUTE_PATH="device/mediateksample/"
readonly YFT_KERNEL_ENG_FILE_TYPE="_debug_defconfig"
readonly YFT_KERNEL_RELEASE_FILE_TYPE="_defconfig"
readonly YFT_KERNEL_RELEASE_K510_FILE_TYPE="mgk_64_k510_defconfig"
readonly YFT_PROJECT_CONFIG_FILE_NAME="ProjectConfig.mk"
readonly YFT_KERNEL_CONFIG="yft_kernel_config"
readonly YFT_LK_CONFIG="yft_bootable_config"
######user manual defined head_check_config
readonly YFT_HEAD_CONFIG_COMMIT_NAME="common_check.config"
readonly YFT_HEAD_CONFIG_USE_NAME="header_check"
readonly YFT_DISTS_INFO_CONFIG="dists_info.config"
function yft_print_usage() {
echo """
用法示例:
----------------
1 ./yft_check -p <Path of Project>
--------------------------------------
说明:
检查当前分支路径下的驱动配置
"""
yft_print_hints " ${YFT_CONST_FILE_VERSION}\n"
exit 1
}
########################################################################
# 说明:打印加粗的红色的字符串
# 用法:传入 ${1},要着重显示的字符串
function yft_print_red_string() {
echo -e "\033[01;31m${*}\033[0m"
}
# 说明:打印加粗的绿色的字符串
# 用法:传入 ${1},要着重显示的字符串
function yft_print_green_string() {
echo -e "\033[01;32m${*}\033[0m"
}
# 说明:打印加粗的蓝色的字符串
# 用法:传入 ${1},要着重显示的字符串
function yft_print_blue_string() {
echo -e "\033[01;34m${*}\033[0m"
}
# 说明:打印出错提示
# 用法:传入 ${1},要着重显示的字符串,必须终止
function yft_print_errors() {
m_errors_info=${*}
echo
yft_print_red_string ${YFT_CONST_HINTS_BEGIN}
yft_print_red_string " ${m_errors_info}"
yft_print_red_string ${YFT_CONST_HINTS_BEGIN}
echo
exit 1
}
function yft_check_base_with_log_file()
{
base_path=$2;
mtkproject=`cat $1 | grep ENV_YFT_BUILD_PLATFORM_NAME | cut -d '=' -f 2 `
yft_project_path=`cat $1 | grep ENV_YFT_BUILD_PROJECT_PATH | cut -d '=' -f 2 `
if [ $ARM_DIR == arm64 ];then
isarm32=0
else
isarm32=1
fi
mtk_lk_configfile=$base_path${YFT_LK_CONFIG_ABSOLUTE_PATH}${YFT_LK_CONFIG}${YFT_LK_CONFIG_FILE_TYPE}
if [ $isarm32 -eq 1 ];then
mtk_eng_kernel_configfile=$base_path$KERNEL_DIR/${YFT_KERNEL_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
mtk_release_kernel_configfile=$base_path$KERNEL_DIR/${YFT_KERNEL_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
yft_kernel_config_file=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_CONFIG}
else
mtk_eng_kernel_configfile=$base_path$KERNEL_DIR/${YFT_KERNEL_64BIT_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
mtk_release_kernel_configfile=$base_path$KERNEL_DIR/${YFT_KERNEL_64BIT_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
yft_kernel_config_file=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_64BIT_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_CONFIG}
fi
mtk_proj_config=$base_path${YFT_PROJECT_CONFIG_ABSOLUTE_PATH}$mtkproject"/"${YFT_PROJECT_CONFIG_FILE_NAME}
if [ ! -f $mtk_lk_configfile ];then
yft_print_errors "lk config filed not exit"
fi
if [ ! -f $yft_kernel_config_file ];then
yft_print_errors "yft_kernel_config_file is not exit"
fi
if [ ! -f $mtk_proj_config ];then
yft_print_errors "project config filed not exit"
fi
#echo "yft_check with file,$mtk_lk_configfile $mtk_eng_kernel_configfile $mtk_proj_config"
python check_and_gen_check_header.py -f $1
if [ $? -ne "0" ];then
yft_print_errors "check_and_gen_check_header failed $?"
else
if [ -f $yft_kernel_config_file ];then
python yft_check_config.py -c $mtk_proj_config -p $mtkproject -k $yft_kernel_config_file -l $mtk_lk_configfile -T header_check
else
python yft_check_config.py -c $mtk_proj_config -p $mtkproject -k $mtk_eng_kernel_configfile -l $mtk_lk_configfile -T header_check
if [ $? -ne "0" ];then
yft_print_errors "check_and_gen_check eng kernel configfile failed $?"
fi
python yft_check_config.py -c $mtk_proj_config -p $mtkproject -k $mtk_release_kernel_configfile -l $mtk_lk_configfile -T header_check
if [ $? -ne "0" ];then
yft_print_errors "check_and_gen_check eng release configfile failed $?"
fi
fi
fi
####in this mode, we need check more check mtkproject with yft config
yft_check_projectConfig "$mtk_proj_config"
####
}
function yft_generated_var_in_check(){
readonly YFT_CONST_GENERATED="yft_generated_var.ini"
script_path=$(pwd);
root_path=$script_path${YFT_SCRIPT_TO_ROOT_APDIX};
export local log_build_path="$root_path${YFT_CONST_GENERATED}";
[ ! -f "$log_build_path" ] && yft_print_errors "Not found $log_build_path" && return
local YFT_CONST_LOG_INFO=`cat $log_build_path`
export MTK_MACH_TYPE=`echo "${YFT_CONST_LOG_INFO}" | grep MTK_MACH_TYPE | cut -d '=' -f 2`
[ -z "$MTK_MACH_TYPE" ] && yft_print_errors "Not found MTK_MACH_TYPE" && return
export KERNEL_DIR=`echo "${YFT_CONST_LOG_INFO}" | grep KERNEL_DIR | cut -d '=' -f 2`
[ -z "$KERNEL_DIR" ] && yft_print_errors "Not found KERNEL_DIR" && return
export ARM_DIR=`echo "${YFT_CONST_LOG_INFO}" | grep ARM_DIR | cut -d '=' -f 2`
[ -z "$ARM_DIR" ] && yft_print_errors "Not found ARM_DIR" && return
unset YFT_CONST_LOG_INFO
echo "yft_generated_var_in_check.sh ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "MTK_MACH_TYPE=$MTK_MACH_TYPE"
echo "ARM_DIR=$ARM_DIR"
echo "KERNEL_DIR=$KERNEL_DIR"
echo "yft_generated_var_in_check.sh ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
}
function yft_check_base_with_dists_path_file()
{
project_path=$1;
base_path=$2;
base_path=$(echo $base_path | sed 's/\/$//g')
! test -d "${base_path}/${project_path}/${YFT_PROJECT_CONFIG_ABSOLUTE_PATH}" && yft_print_errors "dists branch is not exit --${base_path}/${project_path}/${YFT_PROJECT_CONFIG_ABSOLUTE_PATH} !!"
m_yft_build_makefile=$(find ${base_path}/${project_path}/${YFT_PROJECT_CONFIG_ABSOLUTE_PATH} -name ${YFT_PROJECT_CONFIG_FILE_NAME} -print)
#echo "yft_check_base_with_dists_path_file $1, $m_yft_build_makefile"
mtkproject=$(echo ${m_yft_build_makefile} | sed "s|.*${YFT_PROJECT_CONFIG_ABSOLUTE_PATH}||g" | sed 's|/.*||g')
if [ $ARM_DIR == arm64 ];then
isarm32=0
else
isarm32=1
fi
echo "fuck18"
dists_base_path=${base_path}/${project_path}/
mtk_lk_configfile=$dists_base_path${YFT_LK_CONFIG_ABSOLUTE_PATH}${YFT_LK_CONFIG}${YFT_LK_CONFIG_FILE_TYPE}
if [ $isarm32 -eq 1 ];then
mtk_eng_kernel_configfile=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
mtk_release_kernel_configfile=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
yft_kernel_config_file=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_CONFIG}
else
mtk_eng_kernel_configfile=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_64BIT_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
mtk_release_kernel_configfile=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_64BIT_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_RELEASE_K510_FILE_TYPE}
yft_kernel_config_file=$dists_base_path$KERNEL_DIR/${YFT_KERNEL_64BIT_CONFIG_ABSOLUTE_PATH}${YFT_KERNEL_CONFIG}
fi
mtk_proj_config=$dists_base_path${YFT_PROJECT_CONFIG_ABSOLUTE_PATH}$mtkproject"/"${YFT_PROJECT_CONFIG_FILE_NAME}
export mtk_proj_share_proj=`echo ${project_path}|cut -d '/' -f 3`
export mtk_proj_sub_proj=`echo ${project_path}|cut -d '/' -f 4`
mtk_proj_share_relative_path=dists/targets/${mtk_proj_share_proj}
yft_dists_info_config=${base_path}/${mtk_proj_share_relative_path}"/"${YFT_DISTS_INFO_CONFIG}
if [ ! -f $mtk_lk_configfile ];then
yft_print_errors "lk confis not exit !! $mtk_lk_configfile"
fi
if [ ! -f $mtk_proj_config ];then
yft_print_errors "project config filed not exit"
fi
if [ ! -f $yft_dists_info_config ];then
yft_print_errors "dists_info.config file not exit !! $yft_dists_info_config"
fi
yft_gen_checkmacro_by_dists_config "$yft_dists_info_config"
#local rf_mode="noc2k_fdd_3m"
python check_and_gen_check_header.py -l $project_path -p $mtkproject -r $rf_mode
if [ $? -ne "0" ];then
yft_print_errors "check_and_gen_check_header failed $?"
else
if [ -f $yft_kernel_config_file ];then
python yft_check_config.py -c $mtk_proj_config -p $mtkproject -k $yft_kernel_config_file -l $mtk_lk_configfile -T header_check
else
python yft_check_config.py -c $mtk_proj_config -p $mtkproject -k $mtk_eng_kernel_configfile -l $mtk_lk_configfile -T header_check
if [ $? -ne "0" ];then
yft_print_errors "check_and_gen_check eng kernel configfile failed $?"
fi
python yft_check_config.py -c $mtk_proj_config -p $mtkproject -k $mtk_release_kernel_configfile -l $mtk_lk_configfile -T header_check
if [ $? -ne "0" ];then
yft_print_errors "check_and_gen_check eng release configfile failed $?"
fi
fi
fi
####in this mode, we need check more check mtkproject with yft config
yft_check_projectConfig "$m_yft_build_makefile"
echo "fuck19"
####
}
#### this function is to generate the modem_config check files
## read config from dists_info.config and from dists_config.check
## then generate the related check macro to header_check
## the check example formate:
#
# RF_MODE=noc2k_fdd_3m
#
#
#
function yft_gen_checkmacro_by_dists_config()
{
base_path=$(echo $base_path | sed 's/\/$//g')
m_path_dists_config=$1;
local str_proj_cache=`cat ${m_path_dists_config} | grep -nE "^>:[[:space:]]*${mtk_proj_sub_proj}[[:space:]]*\$"`
local str_proj_no=`echo ${str_proj_cache}|cut -d ':' -f 1`
echo "str_no=${str_proj_no}"
if [ -f $log_build_path ];then
echo "dists.log is exit , ok"
export rf_mode=`cat $log_build_path | grep RF_MODE | cut -d '=' -f 2 `
if [ "" == "$rf_mode" ];then
rf_mode="unknown"
fi
else
yft_print_errors "yft_gen_checkmacro_by_dists_config dists.log file is not exit"
fi
# local rf_module="noc2k_cu_5m"
# local key_rf_work="RF_MODULE=${rf_module}"
# local read_line_no=0;
# local rf_config="unknown"
# cat ${m_path_dists_config} | while read line
# do
# read_line_no=`expr $read_line_no + 1`;
# if [[ ${read_line_no}<$str_proj_no ]];then
# continue;
# else
# local new_dists_config=$(echo $line | grep "^>:[[:space:]]*[[\w|-]+][[:space:]]*")
# local rf_config=$(echo $line | grep "^#RF_MODULE=" )
# echo "get new_dists_config=${new_dists_config}, ${line}, rf=${rf_config}"
# fi
# done
}
#### this function is to check the projectConfig files
## for custom_modem issue, if two modem defined , so world phone need define
## if three modem defined, so c2k need defined
function yft_check_projectConfig()
{
m_path_projectConfig=$1;
readonly m_modem_name=$(sed -n "/^[ \t]*CUSTOM_MODEM[ \t]*=/p" ${m_path_projectConfig} | tail -1 | sed 's/.*=//g')
readonly word_phone_supoort=$(sed -n "/^[ \t]*MTK_WORLD_PHONE[ \t]*=/p" ${m_path_projectConfig} | tail -1 | sed 's/\s//g')
readonly c2k_support=$(sed -n "/^[ \t]*MTK_C2K_SUPPORT[ \t]*=/p" ${m_path_projectConfig} | sed 's/\s//g')
modem_count=`echo $m_modem_name | wc -w`;
if [ "$modem_count" -eq 1 -a $word_phone_supoort="no" -a $c2k_support="no" ];then
echo "3m project defined"
elif [[ $modem_count == 2 && "yes"==${word_phone_supoort} && ${c2k_support}=="no" ]];then
echo "$modem_count $word_phone_supoort 5m project defined"
elif [ $modem_count -eq 3 -a $word_phone_supoort=="yes" -a $c2k_support=="yes" ];then
echo "c2k project defined"
else
echo "modem=$m_modem_name, modem_c =${modem_count}, ${word_phone_supoort},${c2k_support}"
yft_print_errors "project modem defined error!!!!"
fi
}
function yft_check()
{
# 空 或者 -h打印帮助
if [ "0" -eq "${#}" ];then
project_path="";
elif [ "${1}" == "${YFT_CONST_FLAG_HELP}" -o "${1}" != "${YFT_CONST_FLAG_PROJECT_ASSIGN}" ]; then
yft_print_usage
fi
#shift;
pushd $(dirname $0);
project_path=$2;
project_path=$(echo $project_path | sed 's/\/$//g')
[ ! -f "yft_check.sh" ] && yft_print_errors "path is error $(pwd)!"
script_path=$(pwd);
root_path=$script_path${YFT_SCRIPT_TO_ROOT_APDIX};
#echo $project_path;
export local log_build_path="$root_path${YFT_CONST_LOG_BUILD}";
if [ -f $YFT_HEAD_CONFIG_USE_NAME ];then
rm ${YFT_HEAD_CONFIG_USE_NAME}
fi
cp ${YFT_HEAD_CONFIG_COMMIT_NAME} ${YFT_HEAD_CONFIG_USE_NAME}
yft_generated_var_in_check
if [ "" != "$project_path" ];then
yft_check_base_with_dists_path_file "$project_path" "$root_path";
elif [ -f $log_build_path ];then
yft_check_base_with_log_file "$log_build_path" "$root_path";
fi
echo $path;
popd;
}
yft_check $@