summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2018-07-03 12:30:19 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2018-07-19 07:42:48 +0200
commit8a7db4c3208057f04d6af9f28c7b1e542e899343 (patch)
treecf10e422e4cef56c6b5048c785aa9349b821672a
parent394be4f1d53b2c246cc7b5c429c3b83ebb64da1c (diff)
downloadmariadb-git-8a7db4c3208057f04d6af9f28c7b1e542e899343.tar.gz
Bug#28200422 USE CTAGS RATHER THAN ETAGS FOR GENERATING TAGS FILE
Switch to Exuberant Ctags when generating TAGS, since it is much better at parsing modern C++ Change-Id: I9652012708df7e7edf93161097a547f60fb0cf79 (cherry picked from commit 125b2804fbbb8662632f761f39aeef0a7f9cebb3)
-rw-r--r--cmake/tags.cmake35
-rwxr-xr-xsupport-files/build-tags41
2 files changed, 61 insertions, 15 deletions
diff --git a/cmake/tags.cmake b/cmake/tags.cmake
index 07c1411a1d6..fdbe61694a3 100644
--- a/cmake/tags.cmake
+++ b/cmake/tags.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,12 +15,29 @@
# Generate tag files
IF(UNIX)
- ADD_CUSTOM_TARGET (tags
- COMMAND support-files/build-tags
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- )
- ADD_CUSTOM_TARGET (ctags
- COMMAND ctags -R -f CTAGS
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- )
+ FIND_PROGRAM(CTAGS_EXECUTABLE ctags)
+ IF(NOT CTAGS_EXECUTABLE)
+ RETURN()
+ ENDIF()
+ EXEC_PROGRAM(${CTAGS_EXECUTABLE} ARGS --version OUTPUT_VARIABLE CTAGS_VERSION)
+
+ IF(CTAGS_VERSION MATCHES "Exuberant")
+ ADD_CUSTOM_TARGET(tags
+ COMMAND support-files/build-tags
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+ ADD_CUSTOM_TARGET(ctags
+ COMMAND support-files/build-tags ctags
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+ ELSE()
+ ADD_CUSTOM_TARGET (tags
+ COMMAND exit 1
+ COMMENT "Please install Exuberant Ctags"
+ )
+ ADD_CUSTOM_TARGET (ctags
+ COMMAND exit 1
+ COMMENT "Please install Exuberant Ctags"
+ )
+ ENDIF()
ENDIF()
diff --git a/support-files/build-tags b/support-files/build-tags
index c37485e32f9..14af22b3ef1 100755
--- a/support-files/build-tags
+++ b/support-files/build-tags
@@ -1,12 +1,41 @@
-#! /bin/sh
+#! /bin/bash
-rm -f TAGS
+# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+tagstyle=${1:-etags}
+
+common_opts="--langmap=C++:+.ic,YACC:+.yy -I MY_ATTRIBUTE+"
+case $tagstyle in
+ "etags") tagfile=TAGS
+ tagopt="-e $common_opts"
+ ;;
+ "ctags") tagfile=tags
+ tagopt="--fields=+l $common_opts"
+ ;;
+ *) echo "$0 [etags|ctags]"
+ exit 1
+ ;;
+esac
+
+rm -f $tagfile
filter='\.cpp$\|\.cc$\|\.c$\|\.h$\|sql_yacc\.yy$\|\.hpp$\|\.ic$'
list="find . -type f"
git rev-parse >/dev/null 2>/dev/null && list="git ls-files"
-$list |grep $filter |while read f;
-do
- etags -o TAGS --append $f
-done
+ctags $tagopt -o $tagfile $( $list | grep $filter )
+
+echo "wrote file `pwd`/$tagfile"