Created
December 26, 2014 05:33
-
-
Save WanghongLin/5e1d9ea00034c9a17840 to your computer and use it in GitHub Desktop.
bash script file to generate ctags and cscope data file for linux kernel project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function usage() | |
{ | |
echo "Usage: $0 kerneldir arch" | |
exit 1 | |
} | |
if [ "$1" == "" -o "$2" == "" ] | |
then | |
usage | |
fi | |
if [[ $1 =~ ^/.* ]]; then | |
KERNELDIR=$1 | |
else | |
KERNELDIR=$(readlink -f $1) | |
fi | |
ARCH=$2 | |
[ -d $KERNELDIR ] || { \ | |
echo "Invalid kernel directory"; \ | |
echo "Please specify a valid kernel directory"; \ | |
exit 1; \ | |
} | |
[ -d $KERNELDIR/arch/$ARCH ] || { \ | |
echo "Invalid archecture"; \ | |
echo "Valid archtures list are"; \ | |
find $KERNELDIR/arch -mindepth 1 -maxdepth 1 -type d -printf "%f "; \ | |
echo ""; | |
exit 1; \ | |
} | |
WORKING_DIR=kernel_$ARCH | |
[ -d $WORKING_DIR ] && rm -rf $WORKING_DIR | |
mkdir -p $WORKING_DIR | |
OUTDIR=`pwd`/$WORKING_DIR | |
cd / | |
find $KERNELDIR \ | |
-path "$KERNELDIR/arch/*" ! -path "$KERNELDIR/arch/$ARCH" -prune -o \ | |
-path "$KERNELDIR/include/asm-*" ! -path "$KERNELDIR/asm-$ARCH" -prune -o \ | |
-path "$KERNELDIR/tmp*" -prune -o \ | |
-path "$KERNELDIR/Documentation*" -prune -o \ | |
-path "$KERNELDIR/scripts*" -prune -o \ | |
-name "*.[chxsS]" -print > $OUTDIR/cscope.files | |
cd $OUTDIR | |
cscope -b -q -k | |
[ -f cscope.files ] && ctags -L cscope.files | |
echo "Successfully create ctags and cscope file in $OUTDIR" | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment