ctags 팁 : ctagsignore

서론

ctags는 아직 구닥다리 개발자에게 소중한 툴입니다. 다만 ignore 기능이 있는지 모르고 사용하다보니 꽤 불편했었는데, 날잡아서 찾아봤습니다.

RTFM (Read the fxxking manual)

진작 좀 man 페이지 볼껄.. 결론은 아래에 있습니다.

exclude 옵션


       --exclude=[pattern]
            Add  pattern  to  a list of excluded files and directories. This option may be specified as many times as desired. For each file name considered by ctags, each pattern specified using this option will be compared against both the complete path (e.g. some/path/base.ext) and the base name (e.g. base.ext) of the file, thus allowing patterns which match a
            given file name irrespective of its path, or match only a specific path. If appropriate support is available from the runtime library of your C compiler, then pattern may contain the usual shell wildcards (not regular expressions) common on Unix (be sure to quote the option parameter to protect the wildcards from being expanded by the shell before be‐
            ing passed to ctags; also be aware that wildcards can match the slash character, '/'). You can determine if shell wildcards are available on your platform by examining the output of the --version option, which will include "+wildcards" in the compiled feature list; otherwise, pattern is matched against file names using a simple textual comparison.

            If  pattern  begins with the character '@', then the rest of the string is interpreted as a file name from which to read exclusion patterns, one per line. If pattern is empty, the list of excluded patterns is cleared.  Note that at program startup, the default exclude list contains "EIFGEN", "SCCS", "RCS", and "CVS", which are names of directories for
            which it is generally not desirable to descend while processing the --recurse option.

그러게요. 매뉴얼 좀 읽을껄...deepl 번역!

--제외=[패턴]
            제외된 파일 및 디렉터리 목록에 패턴을 추가합니다. 이 옵션은 원하는 만큼 지정할 수 있습니다. 이 옵션을 사용하여 지정한 각 패턴은 ctag에서 고려하는 각 파일 이름에 대해 파일의 전체 경로(예: 일부/경로/base.ext)와 기본 이름(예: base.ext) 모두와 비교되므로 경로에 관계없이 지정된 파일 이름과 일치하는 패턴은
            지정된 파일 이름과 일치하거나 특정 경로에만 일치하는 패턴을 허용합니다. C 컴파일러의 런타임 라이브러리에서 적절한 지원을 사용할 수 있는 경우 패턴에는 유닉스에서 일반적으로 사용되는 셸 와일드카드(정규식이 아님)가 포함될 수 있습니다(와일드카드가 셸에 의해 확장되는 것을 방지하기 위해 옵션 매개변수를 반드시 따옴표로 묶어야 합니다).
            와일드카드가 슬래시 문자 '/'와 일치할 수 있다는 점에 유의하세요). 버전 옵션의 출력을 검사하여 플랫폼에서 셸 와일드카드를 사용할 수 있는지 확인하면 컴파일된 기능 목록에 "+와일드카드"가 포함되며, 그렇지 않으면 간단한 텍스트 비교를 사용하여 파일 이름과 패턴이 일치합니다.
            패턴이 문자 '@'로 시작하면 나머지 문자열은 제외 패턴을 읽을 수 있는 파일 이름으로 해석되며, 한 줄에 하나씩 해석됩니다. 패턴이 비어 있으면 제외 패턴 목록이 지워집니다.  프로그램 시작 시 기본 제외 목록에는 일반적으로 바람직하지 않은 디렉터리 이름인 "EIFGEN", "SCCS", "RCS" 및 "CVS"가 포함되어 있습니다.
            일반적으로 --recurse 옵션을 처리하는 동안 하강하는 것은 바람직하지 않습니다.

.ctagsignore

gitignore처럼 만들어줍니다. (ctagsignore가 먼저일것 같지만..)
제 경우는 프로젝트 안에 커널 소스가 있어서 제거해줬습니다.

**/kernel
.bashrc 에 다음과 같이 alias를 만들어줍니다. 다른 옵션은 무시해도 됩니다.

alias ctags='/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --exclude=@.ctagsignore '
어디서 봤던 옵션들을 그대로 가져왔는데 어딘지 모르겠네요...스택오버플로우 형님들꺼겠죠 뭐.
source ~/.bashrc 하고 ctags 테스트해보면 잘 동작합니다!

댓글

이 블로그의 인기 게시물

WSL2 Ubuntu 20.04 및 네트워크 설정

git pull 을 했더니 branch가 갈라지는 경우

리눅스 멀티코어를 사용하는 tar 압축/해제