126 lines
3.8 KiB
Bash
Executable File
126 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ $1 == "" ]]; then
|
|
echo "error input null option ! please re-enter the correct options and you can input '--help' to get correct options"
|
|
exit 0
|
|
elif [[ $1 == "--help" ]]; then
|
|
echo "this is a pclint autoscan shell with two parameters"
|
|
echo "the first parameter you can input distro name to chose different distro"
|
|
echo "such as 'initgc' 'wayland' 'console' 'tiny' 'sato' 'busyboxgc'"
|
|
echo "the second parameter you should input gerrit project, the middle is separated by ',' without space"
|
|
echo "such as 'yocto/scripts,yocto/layers/meta-unisoc'"
|
|
exit 0
|
|
fi
|
|
|
|
DISTROSUFFIX=`echo $1 | awk -F+ '{print $2}'`
|
|
if [ -z "$DISTROSUFFIX" ];then
|
|
echo "Distro is empty, exit pclint.sh!"
|
|
exit 0
|
|
fi
|
|
|
|
OUTMACHINEPATH=$(pwd)
|
|
echo "$OUTMACHINEPATH"
|
|
|
|
if [ -d $OUTMACHINEPATH/../../../../prebuilts/scripts ];then
|
|
cd $OUTMACHINEPATH/../../../../prebuilts/scripts
|
|
else
|
|
echo "No prebuilts/scripts directory or path is error"
|
|
return 0
|
|
fi
|
|
|
|
SOURCEROOT=$(pwd)
|
|
echo "$SOURCEROOT"
|
|
|
|
BUILD_ARM_PATH="${SOURCEROOT}/../../build-unisoc-${DISTROSUFFIX}/tmp-unisoc_${DISTROSUFFIX}-glibc/work/armv7ahf-vfp-unisoc-linux-gnueabi"
|
|
BUILD_AARCH_PATH="${SOURCEROOT}/../../build-unisoc-${DISTROSUFFIX}/tmp-unisoc_${DISTROSUFFIX}-glibc/work/aarch64-unisoc-linux"
|
|
|
|
DESC=`cat project.txt`
|
|
DESD=`cat project.txt | awk '{print $1}' | uniq`
|
|
|
|
for LINE in $DESD
|
|
do
|
|
REPO=`echo $2 | grep $LINE`
|
|
if [ -n "$REPO" ];then
|
|
RECIPENAME=`cat project.txt | grep $LINE | awk '{print $2}'`
|
|
SOURCENAME=`cat project.txt | grep $LINE | awk '{print $3}'`
|
|
echo "$RECIPENAME $SOURCENAME" >> result.txt
|
|
fi
|
|
done
|
|
|
|
if [ -e "result.txt" ];then
|
|
sed -i 's/\r//g' result.txt
|
|
else
|
|
echo "No result.txt, exit pclint.sh!"
|
|
return 0
|
|
fi
|
|
|
|
function read_macro(){
|
|
COMPILE_LINE=`cat $TEMP_DIR/log.do_compile | grep -e $UNISOC_GCC`
|
|
if [ -n "$COMPILE_LINE" ];then
|
|
echo "$COMPILE_LINE" >> compile_line.txt
|
|
FIRST_LINE=`head -n 1 compile_line.txt`
|
|
for CODE in $FIRST_LINE
|
|
do
|
|
MACRO=`echo $CODE | grep '^-D'`
|
|
if [[ $MACRO ]];then
|
|
echo "$MACRO" >> $1_header.lnt
|
|
fi
|
|
done
|
|
rm compile_line.txt
|
|
else
|
|
echo "This log does not have correct compile line!"
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
function read_header_dir(){
|
|
for dir in `ls $1`
|
|
do
|
|
if [ -d $1/$dir ] && [ "$dir" != "oe-workdir" ] && [ "$dir" != "oe-logs" ]; then
|
|
echo "-i$1/$dir" >> $2_header.lnt
|
|
read_header_dir $1/$dir $NAME
|
|
fi
|
|
done
|
|
}
|
|
|
|
function read_source_file(){
|
|
for file in `ls $1`
|
|
do
|
|
if [ -d $1/$file ] && [ "$file" != "oe-workdir" ]; then
|
|
read_source_file $1/$file $NAME
|
|
elif [[ $file = *.c ]] || [[ $file = *.cpp ]]; then
|
|
echo "$1/$file" >> $2_source.lnt
|
|
fi
|
|
done
|
|
}
|
|
|
|
BBNAME=`cat result.txt | awk '{print $1}'`
|
|
|
|
if [[ $BBNAME ]]; then
|
|
for NAME in $BBNAME
|
|
do
|
|
SOURCECODE=`cat result.txt | grep $NAME | awk '{print $2}'`
|
|
SOURCE_DIR="$SOURCEROOT/../../$SOURCECODE"
|
|
if [ -d ${BUILD_ARM_PATH} ]; then
|
|
BUILD_DIR="$BUILD_ARM_PATH/$NAME/*/recipe-sysroot"
|
|
TEMP_DIR="$BUILD_ARM_PATH/$NAME/*/temp"
|
|
UNISOC_GCC="arm-unisoc-linux-gnueabi-g"
|
|
elif [ -d ${BUILD_AARCH_PATH} ]; then
|
|
BUILD_DIR="$BUILD_AARCH_PATH/$NAME/*/recipe-sysroot"
|
|
TEMP_DIR="$BUILD_AARCH_PATH/$NAME/*/temp"
|
|
UNISOC_GCC="aarch64-unisoc-linux-g"
|
|
else
|
|
echo "There is no correct compile directory! Please confirm!"
|
|
return 0
|
|
fi
|
|
read_header_dir $BUILD_DIR $NAME
|
|
read_header_dir $SOURCE_DIR $NAME
|
|
read_source_file $SOURCE_DIR $NAME
|
|
read_macro $NAME
|
|
done
|
|
else
|
|
echo "There are no repos to scan!"
|
|
fi
|
|
|
|
rm result.txt
|