Windows環境用にrcovをビルドしなおす手順
参考サイト
先に結論
Windows環境ではWindows用に自力でビルドしなければならない!
- rcov | RubyGems.org | your community gem hostよりgemをDL
- Microsoft Visual Studio ExpressからVisual C++ 2010 Express Editionを入手しインストール
- 全てのプログラム -> Microsoft Visual Studio 2010 Express -> Visual Studio コマンド プロンプト (2010)を起動。以後ビルドはこのプロンプトで実施する
- %RUBY_HOME%\lib\ruby\1.8\i386-mswin32\のconfig.hのMSC_VERの記述を一旦消す
#if _MSC_VER != 1200 #error MSC version unmatch: _MSC_VER: 1200 is expected. #endif
- env.hのFRAMEを以下のように編集
extern struct FRAME {
extern __declspec(dllimport) struct FRAME {
- gem install!!
以下は四苦八苦した記録の残骸。
手順(本当に順番をメモっているのでいらない操作が多い)
rcovインストール
BundlerでGemを管理するのでGemfileにrcovを追加。
gem 'rcov'
追加後、インストール……
$ bundle install
するとエラーが。
C:/rubies/Ruby/bin/ruby.exe extconf.rb creating Makefile nmake 'nmake' は、内部コマンドまたは外部コマンド、 操作可能なプログラムまたはバッチ ファイルとして認識されていません。 Gem files will remain installed in C:/project/excel_for_ruby/vendor/bundle/ruby/1.8/gemsResults logged to C:/project/excel_for_ruby/vendor/bundle/ruby/1.8/gems/rcov-1.0.0/ext/rAn error occured while installing rcov (1.0.0), and Bundler cannot continue. Make sure that `gem install rcov -v '1.0.0'` succeeds before bundling.
bundlingする前にgem install rcov -v '1.0.0'してくれと? Bundler管理下にはおけないのだろうか。
じゃあGemfileから記述を消して、ターミナルからgem installするか。
$ gem install rcov -v '1.0.0' nmake 'nmake' は、内部コマンドまたは外部コマンド、 操作可能なプログラムまたはバッチ ファイルとして認識されていません。
結局nmakeがないといわれているので、まずnmakeを落とすか。
nmakeインストール
Make for Microsoft Windows: NMake のページにyou have to download NMake 1.5 from the Microsoft Knowledge Base, article 132084 page.と記載されているのでリンクをたどりnmakeをDLし、パスが通っているフォルダへ突っ込む。(デフォルトだとnmake15.exeのようにバージョンがファイル名にくっついているっぽいのでnmake.exeにリネームしておく)
再度。
$ gem install rcov -v '1.0.0' Building native extensions. This could take a while... ERROR: Error installing rcov: ERROR: Failed to build gem native extension. C:/rubies/Ruby/bin/ruby.exe extconf.rb creating Makefile nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cl -nologo -I. -IC:/rubies/Ruby/lib/ruby/1.8/i386-mswin32 -IC:/rubies/Ru by/lib/ruby/1.8/i386-mswin32 -I1.8/ -MD -Zi -O2b2xg- -G6 -c -Tc1.8//callsite.c 'cl' は、内部コマンドまたは外部コマンド、 操作可能なプログラムまたはバッチ ファイルとして認識されていません。 NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. Gem files will remain installed in C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1. 0.0 for inspection. Results logged to C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1.0.0/ext/rcovrt/ge m_make.out
まだ駄目? clとはC Compilerの事らしい。手に入れるにはMicrosoft Visual Studio ExpressからVisual C++ 2010 Express Editionをインストールするくらいしか方法がないみたい。
......インストール中.......3時間くらいかかった
で、インストールフォルダにcl.exeが作成されるので、これを実行!
$ cd C:\Program Files\Microsoft Visual Studio 10.0\VC\bin $ cl mspdb100.dllが見つからなかったため、このアプリケーションを開始できませんでした。
なん……だと……やはりコマンドラインから実行するのは無理?
とりあえずmspdb100.dllを探してみる…と、C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDEにあった。これをclと同じフォルダに持ってくると……。
$ cl Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. 使い方: cl [ オプション... ] ファイル名... [ /link リンク オプション... ]
きたー! じゃあこのcl.exeとmspdb100.dllをパスの通ってる場所にコピーして……再度gem!
$ gem install rcov -v '1.0.0' Building native extensions. This could take a while... ERROR: Error installing rcov: ERROR: Failed to build gem native extension. C:/rubies/Ruby/bin/ruby.exe extconf.rb creating Makefile nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cl -nologo -I. -IC:/rubies/Ruby/lib/ruby/1.8/i386-mswin32 -IC:/rubies/Ruby/lib/ruby/1.8/i386-mswin32 -I1.8/ -MD -Zi -O2b2xg- -G6c -Tc1.8//callsite.c fatal error C1510: Cannot load language resource clui.dll. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x4' Stop. Gem files will remain installed in C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1.0.0 for inspection. Results logged to C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1.0.0/ext/rcovrt/gem_make.ou
エラった! っけど一歩進んだ?clui.dllがないと。うーん。
ここで全てのプログラムにMicrosoft Visual Studio 2010 Express -> Visual Studio コマンド プロンプト (2010)というメニューが増えている事に気づく。きちんとVisual Studio用の設定がなされていなかったから失敗したんだ多分! 再度挑戦。
C:\rubies\Ruby\lib\ruby\gems\1.8\cache>gem install --local rcov-1.0.0.gem Building native extensions. This could take a while... ERROR: Error installing rcov-1.0.0.gem: ERROR: Failed to build gem native extension. C:/rubies/Ruby/bin/ruby.exe extconf.rb creating Makefile nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cl -nologo -I. -IC:/rubies/Ruby/lib/ruby/1.8/i386-mswin32 -IC:/rubies/Ruby/lib/ruby/1.8/i386-mswin32 -I1.8/ -MD -Zi -O2b2xg- -G6 -c -Tc1.8//callsite.c cl : コマンド ライン warning D9035 : オプション 'Og-' の使用は現在推奨されていません。今後のバージョンからは削除されます。 cl : コマンド ライン warning D9002 : 不明なオプション '-G6' を無視します callsite.c c:\rubies\ruby\lib\ruby\1.8\i386-mswin32\config.h(2) : fatal error C1189: #error : MSC version unmatch: _MSC_VER: 1200 is expected. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. Gem files will remain installed in C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1.0.0 for inspection. Results logged to C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1.0.0/ext/rcovrt/gem_make.out
お! ちょっと進んだ。MSC_VERがアンマッチになっているようなので、これをなおす。c:\rubies\ruby\lib\ruby\1.8\i386-mswin32\のconfig.hを開き編集。
#if _MSC_VER != 1200 #error MSC version unmatch: _MSC_VER: 1200 is expected. #endif
これを一時的に退避させる。んで、再度。
cl -nologo -LD -Fercovrt.so callsite.obj rcovrt.obj msvcrt-ruby18.lib oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib -link -incremental:no -debug -opt:ref -opt:icf -dll -libpath:"." -libpath:"C:/rubies/Ruby/lib" -implib:rcovrt-i386-mswin32.lib -pdb:rcovrt-i386-mswin32.pdb -def:rcovrt-i386-mswin32.def ライブラリ rcovrt-i386-mswin32.lib とオブジェクト rcovrt-i386-mswin32.exp を作成中 callsite.obj : error LNK2001: 外部シンボル "_ruby_frame" は未解決です。 rcovrt.obj : error LNK2019: 未解決の外部シンボル _ruby_frame が関数 _coverage_in crease_counter_uncached で参照されました。 rcovrt.so : fatal error LNK1120: 外部参照 1 が未解決です。 NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. Gem files will remain installed in C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1.0.0 for inspection. Results logged to C:/rubies/Ruby/lib/ruby/gems/1.8/gems/rcov-1.0.0/ext/rcovrt/gem_make.out
おおおなんか見つからないって出てきた……。
2011/09/06 Rubyのrcov-0.9.8 for Windows のビルド - 清水川Webという事らしいので、env.hを編集。
extern struct FRAME {
extern __declspec(dllimport) struct FRAME {
に。いざ!
C:\rubies\Ruby\lib\ruby\gems\1.8\cache>gem install --local rcov-1.0.0.gem Building native extensions. This could take a while... Successfully installed rcov-1.0.0 1 gem installed Installing ri documentation for rcov-1.0.0... Installing RDoc documentation for rcov-1.0.0...
きたーーー!
が、なんかカバレッジの表示のされかたがおかしい? メソッドの一行目しかグリーンにならないから網羅率が超低くなる。。オプションとかなのかなー。これは早々にRuby1.9でSimplecov使えという事なのだろうか。