LoginSignup
0
0

More than 5 years have passed since last update.

Mac OS X 10.6 Snow Leopardでmruby

Last updated at Posted at 2016-08-19

PowerPCなアプリをメンテしている関係で、開発環境を10.6から移行できず、この環境でmrubyを使えるようしてみました。

まず10.6に元々入っているrubyは1.8でmrubyがビルドできないのでrubyをビルドします。2.3系が現時点では最新のようなので、ruby-2.3.1をダウンロードします。

Mac OS X 10.6でruby-2.3.1のconfigureを実行するとclangが無いって怒られます。

% ./configure 
checking for ruby... /usr/bin/ruby
downloader.rb:180: private method `class_variable_set' called for Downloader:Cla
ss (NoMethodError)
checking build system type... x86_64-apple-darwin10.8.0
checking host system type... x86_64-apple-darwin10.8.0
checking target system type... x86_64-apple-darwin10.8.0
checking for clang... clang
<stdin>:2:3: error: #error premature clang
        #error premature clang
         ^
1 error generated.
configure: error: clang version 3.0 or later is required

10.6で使えるXcode 3.2.xはclangではなくgccだったので以下のようにします。

% ./configure --with-gcc

これでmakeするとrubyが出来上がるので、sudo make installします。Cocoaなアプリも開発しているので、Mac OS Xでは依存で他の環境で動作しないなどの問題が起きるので、できる限り/usr/localにはインストールしないようにしているのですが、これはしかたがありません。

mruby-1.2.0のディレクトリに入って、以下を実行します。

% /usr/local/bin/ruby ./minirake

これでbuild/host/binの下にmrubyが出来上がります。

ついでにPowerPC版のmrubyもクロスビルドしてみました。10.4のSDKでビルドしたかったんですが、うまくいかず10.5のSDKでビルドしてみました。build_config.rbに追加した内容は以下のようになります。

MRuby::CrossBuild.new('ppc') do |conf|
   toolchain :gcc
   conf.cc.command = '/Developer/usr/bin/gcc-4.0'
   conf.cc.flags << "-arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk"
   conf.linker.flags << "-arch ppc -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
   conf.gembox 'default'
end

出来上がったバイナリはちゃんとMac OS X 10.5/PowerPC G4で動きました。我が家ではPowerPC G4もまだまだ現役です。

余談ですが、ビット・トレード・ワンさんの赤外線リモコンをコントロールするmrbgemを作ってみたのですが、PowerPC/10.5,Intel/10.6でちゃんと動きました。HIDの処理コードはKLabさんの方が作った物をそのままなんですが。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0