Mercurial > vim-gutentags
changeset 71:2d407e62d254
Cscope scripts
Add Unix script for running cscope
Take into account the arg cscope path for Windows
author | Jonathan Buschmann <jonthn@pinacea.com> |
---|---|
date | Sat, 02 May 2015 00:19:02 +0200 |
parents | 6c98089d9ffa |
children | 99b95da1bed7 |
files | plat/unix/update_scopedb.sh plat/win32/update_scopedb.cmd |
diffstat | 2 files changed, 74 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plat/unix/update_scopedb.sh Sat May 02 00:19:02 2015 +0200 @@ -0,0 +1,72 @@ +#!/bin/sh + +set -e + +PROG_NAME=$0 +CSCOPE_EXE=cscope +DB_FILE=cscope.out +PROJECT_ROOT= + +ShowUsage() { + echo "Usage:" + echo " $PROG_NAME <options>" + echo "" + echo " -e [exe=cscope]: The cscope executable to run" + echo " -f [file=cscope.out]: The path to the ctags file to update" + echo " -p [dir=]: The path to the project root" + echo "" +} + + +while getopts "h?e:f:p:" opt; do + case $opt in + h|\?) + ShowUsage + exit 0 + ;; + e) + CSCOPE_EXE=$OPTARG + ;; + f) + DB_FILE=$OPTARG + ;; + p) + PROJECT_ROOT=$OPTARG + ;; + esac +done + +shift $((OPTIND - 1)) + +if [ "$1" != "" ]; then + echo "Invalid Argument: $1" + exit 1 +fi + +echo "Locking cscope DB file..." +echo $$ > "$DB_FILE.lock" + +# Remove lock and temp file if script is stopped unexpectedly. +trap "rm -f \"$DB_FILE.lock\" \"$DB_FILE.temp\"" 0 3 4 15 + +PREVIOUS_DIR=$(pwd) +if [ -d "$PROJECT_ROOT" ]; then + cd "$PROJECT_ROOT" +fi + +echo "Running cscope" +echo "$CSCOPE_EXE -R -b -k -f \"$DB_FILE.temp\"" +"$CSCOPE_EXE" -R -v -b -k -f "$DB_FILE.temp" + +if [ -d "$PROJECT_ROOT" ]; then + cd "$PREVIOUS_DIR" +fi + +echo "Replacing cscope DB file" +echo "mv -f \"$DB_FILE.temp\" \"$DB_FILE\"" +mv -f "$DB_FILE.temp" "$DB_FILE" + +echo "Unlocking cscope DB file..." +rm -f "$DB_FILE.lock" + +echo "Done."
--- a/plat/win32/update_scopedb.cmd Wed Apr 29 21:24:16 2015 -0700 +++ b/plat/win32/update_scopedb.cmd Sat May 02 00:19:02 2015 +0200 @@ -6,7 +6,7 @@ rem ========================================== set CSCOPE_EXE=cscope -set DB_FILE=scope.out +set DB_FILE=cscope.out :ParseArgs if [%1]==[] goto :DoneParseArgs @@ -43,7 +43,7 @@ echo locked > "%DB_FILE%.lock" echo Running cscope -cscope -R -b -k -f "%DB_FILE%" +"%CSCOPE_EXE%" -R -b -k -f "%DB_FILE%" if ERRORLEVEL 1 ( echo ERROR: Cscope executable returned non-zero code. )