- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2022-12-15T16:21:43+09:00","","")
#author("2022-12-16T00:46:14+09:00","","")
#topicpath
///////////////////////////////////////////////////////////////////////////////
* 目次 [#d598aa76]
#contents();
///////////////////////////////////////////////////////////////////////////////
* rtags [#aded69fa]
- rtags は、llvm をバックエンドに使用したタグ検索システム。
//==============================================================================
** 環境構築(debian パッケージを使用) [#build-env-debian-package]
+ 必要な関連パッケージをインストールする
# apt-get install rtags
+ コマンド名はオリジナルから若干アレンジされているので注意(他パッケージとの名前の干渉を避ける為と思われる)。
|>|~コマンド名 |
|~オリジナル |~debian パッケージ版 |
|rc |rtags-rc |
|rdm |rtags-rdm |
|rp |rp |
//==============================================================================
** 環境構築(自前ビルド) [#build-env-build]
+ 必要な関連パッケージをインストールする
# apt-get install clang libclang-dev cmake
+ rtags をビルドする(rtags がディストリビューションでパッケージが用意されているなら、そちらを使うと良い)
++ コードを取得する
$ git clone --recursive https://github.com/Andersbakken/rtags
++ ビルドする
$ cd rtags
$ git submodule init
$ git submodule update
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
~
+ rtags をインストールする
-- ビルドすると rtags/build/bin に以下の実行形式が生成されるので、環境変数 PATH の通っているところに配置する。
$ ls rtags/build/bin
rc rdm rp
//==============================================================================
** タグを生成する [#u9c384fe]
+ まず、daemon を起動する
$ rdm --daemon
+ タグを生成する方法は2つある
- &color(red){注:clang を使うと、後述のコマンド '''"rc -J . "''' を実行したときに失敗する。その為、Makefile でコンパイラの指定は clang ではなく gcc を使うと良い。};
//------------------------------------------------------------------------------
*** 1. rc コマンドに直接渡す [#p77de85a]
- 実際に compile するときのコマンドを rc に渡す。
$ rc gcc $(CFLAGS) $(SRCS)
//------------------------------------------------------------------------------
*** 2. rc -Jコマンドで compile_commands.json を読み込ませる [#xa2d2a47]
- compile_commands.json は、cmake か bear で生成する。
-- bear を使う場合(cmake を使わない、Makefile のみのプロジェクトの場合)
--- bear コマンドがインストールされていない場合は、インストールする
# apt-get install bear
--- bear コマンドの実行
$ bear -- make
-- cmake で生成する場合
~
T.B.D.
- rc -Jコマンドで compile_commands.json を読み込ませる
$ rc -J .
//==============================================================================
** emacs から rtags を使う [#f3e74104]
- rtags.el を、 emacs の load-path の通っているところに置く。rtags.el は、rtag リポジトリの下記にある
build/src/rtags.el
- init.el
;;; rtags.el の設定
(require 'rtags)
(when (require 'rtags nil 'noerror)
(add-hook 'c-mode-common-hook
(lambda ()
(when (rtags-is-indexed)
(local-set-key (kbd "M-.") 'rtags-find-symbol-at-point)
(local-set-key (kbd "M-;") 'rtags-find-symbol)
(local-set-key (kbd "M-@") 'rtags-find-references)
(local-set-key (kbd "M-,") 'rtags-location-stack-back)))))
(provide 'rtags.conf)
//==============================================================================
** 参考リンク [#ib49a8ea]
- [[最強のC/C++インデクサー "Rtags" を本気で使う>https://qiita.com/kota65535/items/39aa4d6e8adf6ab5f98c]]
- [[Rtags で BitVisor の開発を楽になるか?>https://qiita.com/deep_tkkn/items/eb24cb2f0713c7fc4162]]