目次
LXR(Linux X-Reference)LXRを使いたいのだが、対象がC/C++では無く、 Javaのコードがメインだったので、0.3系ではなく、0.9系を使う必要があった。Googleで探してみると、0.3系は情報がある程度あるのだが、 0.9系に関しては添付のINSTALL以外に無いので、うまく動かなかった。 このため環境構築までの作業をメモっておくことにした。 構築対象環境
Perl関連事前に入れておいたほうがいいもの
CPAN経由で物を拾うときに、Digest::SHAモジュールで使うので、 Perlを入れる前にinstallしたほうがいい。 build適当にどうぞ。4個ぐらいテスト失敗するが、問答無用でmake install。あと、DynaLoader?はLXR(のモジュールで使ってる MySQLのDBI)で必須なのでoffにしないように。Solarisの場合は、dlopenです。 Perlのコンパイルの際にはMT化しない方がいい気がしたので、 thread未対応(ithreads使用不可)にしました。 きっと、そうしておいた方がいいでしょう。;-) MySQL関連0.3系ではgenxrefのデータベースがファイルベースだったのが、 0.9系ではRDBになったため、今までいろいろと避けて通ってきたRDBMSを知らんと いかん(ぐらい動かない^^;)ため、とりあえずMySQLを使ってみた。mysqlのbinにあるコマンド
mysql interpreterコマンドコマンドの末尾は ; でterminateすること。
Perl用modulePerlからMySQLに接続する場合は、DBI.pmでwrapしてあるMySQL用の ドライバを利用する必要がある。で、必要なモジュールは以下2点。
[修正前] [, I<\@title_formats [, I<\@data_formats [, I<$table_attrs> ] ] ] ] ] ] ]; [修正後] [, I<\@title_formats> [, I<\@data_formats> [, I<$table_attrs> ] ] ] ] ] ] ];
[ソースファイルから] perl Makefile.PL;make;make test;make install ソースからコンパイル基本はenter進行で。注意点があれば、ログに埋めてます。% perl Makefile.PL Which drivers do you want to install? 1) MySQL only 2) mSQL only (either of mSQL 1 or mSQL 2) 3) MySQL and mSQL (either of mSQL 1 or mSQL 2) 4) mSQL 1 and mSQL 2 5) MySQL, mSQL 1 and mSQL 2 Enter the appropriate number: [3] 1 <-MySQLのDBIだけがあればいいので、1にした。 Do you want to install the MysqlPerl emulation? You might keep your old Mysql module (to be distinguished from DBD::mysql!) if you are concerned about compatibility to existing applications! [n] n Where is your MySQL installed? Please tell me the directory that contains the subdir 'include'. [/usr/local/mysql] Which database should I use for testing the MySQL drivers? [test] On which host is database test running (hostname, ip address or host:port) [localhost] User name for connecting to database test? [undef] test Password for connecting to database test? [undef] <- パスワード未設定なので、空 Creating files for MySQL .................... WARNING: PL_FILES takes a hash reference not a array reference. Please inform the author. Checking if your kit is complete... Looks good Note (probably harmless): No library found for -lgz Using DBI 1.50 (for perl 5.008005 on sun4-solaris) installed in /usr/local/lib/perl5/site_perl/5.8.5/sun4-solaris/auto/DBI/ Writing Makefile for DBD::mysql Writing Makefile for Msql-Mysql-modules
LXRの設定MySQLの設定mysqlの場合、同梱の initdb-mysql を使えば、必要なDB/table等を作ってくれます。これに先立って、OSのユーザとMySQLのユーザにlxrを作ってます。 配備展開したら、手動でcopy。展開したままの状態で、lxrのディレクトリを作った方が よいです。genxrefとその他(find,diff,ident,search,source)を別々のディレクトリに 置くと、Local.pmやlxr.confをgenxrefの方に置いたり、@INCの設定のためにgenxrefを 書き直したりする必要があるので、面倒です。lxr.conf書き今回はcvs,swish-eを使わない、localファイル + glimpseなので、こんな感じにしました。# -*- mode: perl -*- ( { # Global configuration 'glimpsebin' => '/usr/local/glimpse-4.18.5/bin/glimpse', 'glimpseindex' => '/usr/local/glimpse-4.18.5/bin/glimpseindex', # Path to Exuberant Ctags executable 'ectagsbin' => '/usr/local/bin/ctags', # Place where lxr can write temporary files 'tmpdir' => '/tmp', # Location of the Generic.pm config file 'genericconf' => '/usr/local/lxr-0.9/http/lib/LXR/Lang/generic.conf', # Location of the ectags.conf file 'ectagsconf' => '/usr/local/lxr-0.9/http/lib/LXR/Lang/ectags.conf', }, { # Configuration for http://192.168.1.3/lxr. # ここは書かないですが・・ # baseurlとbaseurl_aliasesは呼ばれる可能性のある全てのパターンの形式 # [IPアドレス]:[port番号]とか # [FQDN]:[port番号]、[省略名]:[port番号]とか # を書いておく必要があります。 'baseurl' => 'http://[サーバの呼ばれる可能性のある名前]/lxr/', 'baseurl_aliases' => [ 'http://localhost:[port]/lxr', 'http://[FQDN]:[port]/lxr', 'http://[省略名]:[port]/lxr' ], 'virtroot' => '/lxr', 'variables' => { 'v' => { 'name' => 'Version', # 0.3におけるversionsファイルをここで指定します 'range' => [ readfile('/usr/local/lxr-0.9/srcroot/versions') ], 'default' => '1.0.6' }, # Define typed variable "a". First value is default. 'a' => { 'name' => 'Architecture', 'range' => [qw(i386 alpha arm m68k mips ppc sparc sparc64)] }, }, # These do funky things to paths in the system - # you probably don't need them. (まさにその通り) 'maps' => { '/include/asm[^\/]*/' => '/include/asm-$a/', '/arch/[^\/]+/' => '/arch/$a/', }, # Templates used for headers and footers # ここは配置にあわせて書き直し 'htmlhead' => 'templates/html-head.html', 'htmltail' => 'templates/html-tail.html', 'htmldir' => 'templates/html-dir.html', 'htmlident' => 'templates/html-ident.html', 'htmlident_refs' => 'templates/html-ident-refs.html', 'htmlfind' => 'templates/html-find.html', 'htmlsearch' => 'templates/html-search-swish.html', 'sourcehead' => 'templates/html-head.html', 'sourcedirhead' => 'templates/html-head.html', 'stylesheet' => 'templates/lxr.css', # sourceroot - where to get the source files from # ソース置き場の root directoryのパスを書く 'sourceroot' => '/usr/local/lxr-0.9/srcroot', # The name to display for this source tree 'sourcerootname' => 'お好きな名前をどうぞ', 'sourceparams' => '', 'dbname' => 'dbi:mysql:dbname=lxr', # ここは事前に作っておくと、glimpseのindexができます 'glimpsedir' => '/usr/local/lxr-0.9/glimpse/databases', # where to look for include files inside the sourcetree. # ここから下はさわってないので省略 index生成以下でindexを生成できる。% genxref --url=[baseurlに書いたどれか] [対象ディレクトリ]これで終わり。 後で結局、swish-eを入れて再度index張り直してみたのだけど、 手順は上記のまま。(re-indexは無いっぽ。それとswish-e用のdb用ディレクトリは 作って必要あり) 0からやるより時間は短かったのですが、ちゃんと 動いているのかは相当怪しいw
http.conf書きこれは同梱のINSTALLにある通りのままでok。 ちなみに配備ができた時点で、index生成しないでもソースナビゲーションは 可能なので、lxrのdebugはこの時点で行った方が経済的。参考情報
OpenGrokざっくり別ページに移しました。 |