요새 Web기술의 발전이 대단하다. Blog, wiki, social coding, github 등등 개발자에게 천국이 도래하는 것 같다. 아니 어쩌면 학습곡선의 기울기만 높이는 꼴인지도 모르겠다. 어째튼 이런 Web 기술의 발전과 함께 오늘은 opengrok에 대해서 알아보자. 기존에 source insight와 vim등을 소개했었는데, opengrok site에 보면 다음과 같은 글이 눈에 띈다. http://hub.opensolaris.org/bin/view/Project+opengrok/WebHome 참고
Comparison with Similar Tools
(Disclaimer: this table might be obsolete, if you think it needs adjusting, please send us a mail to opengrok-discuss@opensolaris.org)
Feature | LXR | ctags | cscope | ViewVC | GNU GLOBAL | OpenGrok |
Full text Search | Y |
| Y |
| Y | Y |
Definition Search | # | Y | Y |
| Y | Y |
Identifier Search | Y |
| Y |
| Y | Y |
Path search | Y |
| Y |
| Y | Y |
History Search |
|
|
|
|
| Y |
Caller/Callee Search |
|
| Y |
| # |
|
RegExp Search |
|
| Y |
| Y | # (only wildcards) |
Shows matching lines |
| Y | Y |
| Y | Y |
Hierarchical Search |
|
|
|
| Y | Y |
query syntax like AND, OR, field: |
|
|
|
|
| Y |
Incremental update |
|
| # |
| Y | Y |
RSS Feed |
|
|
| Y |
| Y |
Syntax highlighting-Xref | Y |
|
| # | Y | Y |
Interface for SCM |
|
|
| Y | Y | Y |
open source | Y | Y | Y | Y | Y | Y |
Usable URLs | Y | - | - |
| Y | Y |
Individual file download |
| - | - | Y | - | Y |
Changes at directory level |
| - | - | # | - | Y |
Multi language support | # | Y | # | - | Y | Y |
User interface | WEB | CLI | CLI | WEB | WEB / CLI | WEB / CLI |
Static HTML |
|
|
|
| Y | #(for xrefs) |
Input completion |
|
|
|
| Y | #(with greasemonkey script) |
Built-in parser |
| Y | Y |
| Y | #(lexical analysis) |
Plug-in parser |
|
|
|
| Y |
|
Integration with (exuberant) ctags |
| - |
|
| Y | Y |
Integration with cscope |
|
| - |
| Y |
|
Integration with emacs |
| Y | Y |
| Y |
|
Integration with vim |
| Y | Y |
| Y | |
Integration with doxygen |
|
|
|
| Y |
|
Integration with Netbeans |
|
|
|
|
|
|
Integration with less |
| Y |
|
| Y |
|
Integration with bash |
|
|
|
| Y |
|
Integration with idutils |
|
|
|
| Y |
|
Integration with Elvis |
| Y |
|
| Y |
|
Legend:
Y : Yes the feature is present
# : the feature may be partly present
- : not applicable
한마디로 좋다는 이야기다. Gnu global도 써봐야지.. 상세 설명은 http://hub.opensolaris.org/bin/view/Project+opengrok/story 에 나오는데, core engine이 lucene을 쓴다고 한다. Lucene은 general text search engine으로 속도가 장난이 아니라고 하며, 단지 2byte character 체계를 사용하는 영어가 아닌 국가의 string처리는 별도로 해줘야 한다고 한다.
그럼 본론으로 들어가 본다. (기본적으로 대/소문자를 가리진 않는다.)
먼저 오른쪽에 보이는
설정 (In Projects): 검색할 projects(즉 directory)를 선택한다.
검색: 다양한 검색 방법을 제공하며, 아래에서 2개 이상 선택되면 and로 찾아준다.
- Full Search: 모든 문서에서 찾는다. C, Java, asm, txt, jar 구분 없이 string으로 다 찾는다.
- Definition: symbol이 정의된 위치만을 찾는다. setOnSystemUiVisibilityChangeListener를 넣어보면 정의가 된 View.java를 정확히 찾아준다. 그런 후 android.jar까지 찾아주는데, android.jar에 포함된 android/view/View.class 까지 풀어서 검색을 해준다. 장난이 아닌데..
- Symbol: text, html, xml등의 아닌 source file에서는 모두 다 찾아준다.
- File Path: file및 dir에서 포함된 문자열에서 찾아준다.
- History: 연동된 SCCS의 log에서 찾아준다. 여기서는 git log에서 해당 log를 찾아준다. 예를 들어 JBQ를 찾아볼까?
정렬 (Sort by): 찾은 결과를 어떤 순서로 보여줄지 결정한다.
- Last modified time: 찾은 결과를 가진 file을 최신 시간 순으로 정렬하여 보여준다.
- Relevance: default 설정으로 관련성이 깊은 file부터 보여준다.
- Path: 찾은 파일이 존재하는 full path name을 ABC 순으로 정렬해준다.
이제 기본 사용법을 알았겠지. 그럼 고급으로 들어가 볼까?
고급 사용법을 Full Search 창에서만 동작한다.
Term: symbols
Phase: "public class"
Field: full, defs, refs, path, hist
parentheses: ()
operator: AND(&&), OR(||), NOT(!), +, -
regexp: ?, *(참고로 *로 시작하는 query는 -a로 index를 해 논 상태이어야 한다.), ~(비슷한 단어 찾기)
range: [A to B] 양끝범위 포함, {A to B} 양끝범위 제외
문자: "+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ " 검색시 \(escape)를 붙여야 한다.
Example)
Symbol 검색
"Symbol", +full:"symbol" --> symbol 검색
defs:"symbol" --> symbol definition 검색
refs:"sprintf" --> sprint 사용하는 모든 reference
path:"frameworks" --> frameworks가 들어가는 모든 path/file 명에서 검색
hist:"qualcomm" --> history log중 qualcomm 문자열 검색
"Variable=" --> assign 검색
Pattern 검색
"throw*" --> throw, throws, Throwable, throwClassName 등 throw로 시작되는 모든 것을 검색
"throw*e" --> Throwable, throwClassName 등 throw~e 검색
"ex??nd" --> expand, extend 검색
"ListActivity~" --> ListActivity와 유사한 string을 찾는다.
full:listactivity~0.1 (조금 이라도 유사하면 찾기), full:listactivity~0.9 (거의 비슷해야 찾기)
full:{2011 TO 2013} --> file에서 2012를 찾는다.
+full:main +path:". rc" --> 모든 .rc파일에서 main찾기
파일검색
file: path:". aidl" -->.aidl로 끝나는 파일 검색
복합 검색
"public class" --> space가 포함된 phase 검색
"public throws"~1 --> public과 throws 사이에 1개의 word만 들어간 line을 검색
ex) public EventLogTags() throws IOException {}
+full:"setOnSystemUiVisibilityChangeListener" +full:"new" --> symbol 2개가 포함 파일
+full:"setOnSystemUiVisibilityChangeListener" +full:"new" -full:"private"--> symbol 2개포함 1개 비 포함 파일
+full:"setOnSystemUiVisibilityChangeListener" +path:"HelloActivity" --> HelloActivity가 포함된 path/file에서 symbol검색
+full:"LOCAL_MODULE" +path:"mk" --> LOCAL_MODUEL이 포함된 모든 .mk(makefile)에서 검색
(full:"setOnSystemUiVisibilityChangeListener") OR (full:"OnSystemUiVisibilityChangeListener") --> 2개중 하나라도 존재하는 파일
합(OR, +, ||), 곱(AND,&&), 반대(NOT,!)
더 상세한 것은 Lucene manual 인 http://webhelp.esri.com/geoportal_extension/9.3.1/index.htm#srch_lucene.htm 를 참고 바란다.
추가내용
접속시 id/pwd 자동으로 넣기, 아래 붉은색글자를 자신의 정보로 변경하세요.
id와 pwd사이에 : 이 있어야 하고, site 주소 앞에 @을 넣어야 합니다. è 해당 사이트 접속시 사용할 계정정보 넣어주는 방식입니다.
http://id:pwd@opengrok.lge.com:8080/source/
접속시 특정 project 선택하기, 많은 project중 한곳을 미리 지정하는 방식...
http://opengrok.lge.com:8080/source/search?project=lap_kk_mr1_release
그리고 git web처럼 디렉토리로 접근하고 싶으면, 아래처럼 주소를 입력하거나,
http://opengrok.lge.com:8080/source/xref/lap_kk_mr1_release/
opengrok 접속상태에서 project를 double click하시면 됩니다
그리고 ctrl키 누르면 여러 project가 선택된답니다.