Fix make_etags failure on Mac.
Previously make_etags always ran make_ctags -e when make_etags was executed. However, because non-Exuberant ctags on Mac does not support -e option (and also on other platforms including old Linux), ctags failed. To avoid the failure change make_ctags so that if non-Exuberant ctags is used and ctags -e option is requested, run etags command instead. If etags command does not exist, make_ctags will fail. Also refactor make_ctags and tweak make_etags to emit proper usage message. Author: Fujii Masao Reviewed-by: Tatsuo Ishii Discussion: https://www.postgresql.org/message-id/369c13b9-8b0f-d6f9-58fc-61258ec8f713%40oss.nttdata.com
This commit is contained in:
parent
3b12e68a5c
commit
87f21d2c68
@ -9,15 +9,19 @@ then echo $usage
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MODE=
|
EMACS_MODE=
|
||||||
NO_SYMLINK=
|
NO_SYMLINK=
|
||||||
|
IS_EXUBERANT=
|
||||||
|
PROG="ctags"
|
||||||
|
TAGS_OPT="-a -f"
|
||||||
TAGS_FILE="tags"
|
TAGS_FILE="tags"
|
||||||
|
FLAGS=
|
||||||
|
IGNORE_IDENTIFIES=
|
||||||
|
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
if [ $1 = "-e" ]
|
if [ $1 = "-e" ]
|
||||||
then MODE="-e"
|
then EMACS_MODE="Y"
|
||||||
TAGS_FILE="TAGS"
|
|
||||||
elif [ $1 = "-n" ]
|
elif [ $1 = "-n" ]
|
||||||
then NO_SYMLINK="Y"
|
then NO_SYMLINK="Y"
|
||||||
else
|
else
|
||||||
@ -27,15 +31,24 @@ do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
command -v ctags >/dev/null || \
|
if [ ! "$EMACS_MODE" ]
|
||||||
|
then (command -v ctags >/dev/null) || \
|
||||||
{ echo "'ctags' program not found" 1>&2; exit 1; }
|
{ echo "'ctags' program not found" 1>&2; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
|
|
||||||
rm -f ./$TAGS_FILE
|
|
||||||
|
|
||||||
IS_EXUBERANT=""
|
|
||||||
ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
|
ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
|
||||||
|
|
||||||
|
if [ "$EMACS_MODE" ]
|
||||||
|
then TAGS_FILE="TAGS"
|
||||||
|
if [ "$IS_EXUBERANT" ]
|
||||||
|
then PROG="ctags -e"
|
||||||
|
else (command -v etags >/dev/null) || \
|
||||||
|
{ echo "neither 'etags' nor exuberant 'ctags' program not found" 1>&2; exit 1; }
|
||||||
|
PROG="etags"
|
||||||
|
TAGS_OPT="-a -o"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# List of kinds supported by Exuberant Ctags 5.8
|
# List of kinds supported by Exuberant Ctags 5.8
|
||||||
# generated by ctags --list-kinds
|
# generated by ctags --list-kinds
|
||||||
# --c-kinds was called --c-types before 2003
|
# --c-kinds was called --c-types before 2003
|
||||||
@ -56,20 +69,23 @@ ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
|
|||||||
|
|
||||||
if [ "$IS_EXUBERANT" ]
|
if [ "$IS_EXUBERANT" ]
|
||||||
then FLAGS="--c-kinds=+dfmstuv"
|
then FLAGS="--c-kinds=+dfmstuv"
|
||||||
else FLAGS="-dt"
|
elif [ ! "$EMACS_MODE" ]
|
||||||
|
then FLAGS="-dt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use -I option to ignore a macro
|
# Use -I option to ignore a macro
|
||||||
if [ "$IS_EXUBERANT" ]
|
if [ "$IS_EXUBERANT" ]
|
||||||
then IGNORE_IDENTIFIES="-I pg_node_attr+"
|
then IGNORE_IDENTIFIES="-I pg_node_attr+"
|
||||||
else IGNORE_IDENTIFIES=
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
|
||||||
|
rm -f ./$TAGS_FILE
|
||||||
|
|
||||||
# this is outputting the tags into the file 'tags', and appending
|
# this is outputting the tags into the file 'tags', and appending
|
||||||
find `pwd`/ \( -name tmp_install -prune -o -name tmp_check -prune \) \
|
find `pwd`/ \( -name tmp_install -prune -o -name tmp_check -prune \) \
|
||||||
-o \( -name "*.[chly]" -o -iname "*makefile*" -o -name "*.mk" -o -name "*.in" \
|
-o \( -name "*.[chly]" -o -iname "*makefile*" -o -name "*.mk" -o -name "*.in" \
|
||||||
-o -name "*.sql" -o -name "*.p[lm]" \) -type f -print |
|
-o -name "*.sql" -o -name "*.p[lm]" \) -type f -print |
|
||||||
xargs ctags $MODE -a -f $TAGS_FILE "$FLAGS" "$IGNORE_IDENTIFIES"
|
xargs $PROG $TAGS_OPT $TAGS_FILE $FLAGS $IGNORE_IDENTIFIES
|
||||||
|
|
||||||
# Exuberant tags has a header that we cannot sort in with the other entries
|
# Exuberant tags has a header that we cannot sort in with the other entries
|
||||||
# so we skip the sort step
|
# so we skip the sort step
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# src/tools/make_etags
|
|
||||||
|
# src/tools/make_etags [-n]
|
||||||
|
|
||||||
|
if [ $# -gt 1 ] || ( [ $# -eq 1 ] && [ $1 != "-n" ] )
|
||||||
|
then echo "Usage: $0 [-n]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
cdir=`dirname $0`
|
cdir=`dirname $0`
|
||||||
dir=`(cd $cdir && pwd)`
|
dir=`(cd $cdir && pwd)`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user