RMagick ã®ãã¹ããéããªããã®ã調ã¹ãéã«ã©ã®ããã«ãããã°ããããã¨æã£ãã®ã§ãããDebugging Ruby C Extensions in XCode - Emil Soman's blog ã«æçãªãã¨ãæ¸ããã¦ããã¾ãããå ã®è¨äºã§ã¯ Xcode 5.1 ã使ããã¦ããã®ã§ææ°ã® Xcode ã®ã¹ã¯ãªã¼ã³ã·ã§ããã交ãã¤ã¤æé ãæ¸ãã¦ã¿ã¾ãã
ãã®è¨äºã§ã¯ Ruby C æ¡å¼µã©ã¤ãã©ãªã® C è¨èªã§æ¸ãããã³ã¼ãããããã°ããææ³ãè¨è¿°ãã¾ãã
ãããã°å¯¾è±¡ã®ã³ã¼ããå ¥æ
$ git clone https://github.com/rmagick/rmagick.git
Makefile ãä½æ
Ruby C æ¡å¼µã©ã¤ãã©ãªã® C è¨èªã®ã³ã¼ã㯠ext
ãã£ã¬ã¯ããªé
ä¸ã«ããã¾ããRMagick ã§ã¯ ext/RMagick
ã¨ãªãã¾ããããã¸ç§»åã Makefile ãä½æãã¾ãããããã°ããããããã« CFLAGS
ãéã㦠-O0
㨠-ggdb3
ãæå®ãã¾ãã
$ cd ext/RMagick $ CFLAGS="-O0 -ggdb3" LDFLAGS="-L`brew --prefix gmp`/lib" ruby extconf.rb
Xcode ãã make ãã㨠gmp
ã®ã©ã¤ãã©ãªãè¦ã¤ãããªãæ¨ã®ã¨ã©ã¼ãåºã¦ãã¾ã£ãã®ã§ãããã§ã¯ LDFLAGS
ã®è¨å®ãè¡ã£ã¦ãã¾ãã
Xcode ã®ããã¸ã§ã¯ããä½æ
Xcode èµ·åæã«è¡¨ç¤ºããã Welcome ç»é¢ããã§ãã¨ã赤æ ã§å²ãã é¨åãã¯ãªãã¯ãã¦æ°è¦ããã¸ã§ã¯ããä½æãã¾ãã
Cross-Platform
ã¿ãã«è¡¨ç¤ºããã External Build System
ã¨ãããã³ãã¬ã¼ããé¸æãã¾ãã
ããã¸ã§ã¯ãåãªã©ã¯é©å½ã«åãã¦ããã¾ãã
ããã¸ã§ã¯ãã®ä¿åå ´æã¯ããããããå ´æã«ãã¦ããã¨è¯ãã§ãããã
External Build Tool Configuration
make ã³ãã³ããã©ã®ãã£ã¬ã¯ããªã§å®è¡ãããæå®ãã¾ããext/RMagick
ãæå®ãã¾ãã
Ruby ã®å®è¡ãã¡ã¤ã«ãæºå
Xcode 㧠Ruby ã®å®è¡ãã¡ã¤ã«ãç°¡åã«æå®ã§ããããã«æºåãã¾ããã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
$ ln -sf `rbenv which ruby`
ãã㧠rbenv
ã§ã¤ã³ã¹ãã¼ã«ãã Ruby ã®å®è¡ãã¡ã¤ã«ã®ã·ã³ããªãã¯ãªã³ã¯ãã§ãã¾ããã
Ruby ã®è¨å®
Xcode 㧠Edit Scheme...
ãã¯ãªãã¯ãã¾ãã
Executable
ã®ã¨ãã㧠Other...
ãé¸æããå
ã»ã©æºåãã Ruby ã®å®è¡ãã¡ã¤ã«ã®ã·ã³ããªãã¯ãªã³ã¯ãé¸æãã¾ãã
次ã«ä½æ¥ãã£ã¬ã¯ããªã®è¨å®ãè¨å®ãã¾ããOptions
ã®ã¿ããé¸æã Working Directory
ã®ã¨ãããè¨å®ãã¾ãã
次㫠Arguments
ã®ã¿ãã«ç§»åãããã¹ãç¨ã® Ruby ãã¡ã¤ã«ãæå®ãã¾ãã
ãããã¬ãèµ·åãããéã«å®è¡ãããéã«æ¸¡ããã以ä¸ã®æ§ãªæãã§å±éããã¾ãã
lldb -- ruby test.rb
ãã¹ãç¨ã®ãã¡ã¤ã«ã«ã¯ä»¥ä¸ã®æ§ã«ããããã°ãããå
容ã«å¿ãã¦æ¸ã㦠ext/RMagick
ã«ç½®ãã¦ããã¾ãã
require './RMagick2.so' image = Magick::Image.new(20, 20) { self.background_color = 'gray50' } p image.gray?
ã½ã¼ã¹ã³ã¼ãã追å
Xcode å·¦ä¸ã«ãã +
ãã¿ã³ãã¯ãªãã¯ã Add Files to....
ãé¸æãã¾ãã
ext/RMagick
å
ã® C è¨èªãã¡ã¤ã«ã追å ãã¾ãã
以ä¸ã§ãããã°ã®æºåãå®äºã§ãããç²ãæ§ã§ãã
ãããã°
ãããã°ãããç®æã« Xcode ã§ãã¬ã¼ã¯ãã¤ã³ããè¨ç½®ããâ¶ãã¿ã³ãã¯ãªã㯠(or command
+ R
)ã§å®è¡ãã¾ãã
ãã¨ã¯ Xcode ãæä½ããããlldb ã®ã³ãã³ããå®è¡ãããããªãããããã°ãé²ãã¦è¡ãã¾ãã
ã¾ã¨ã
æºåãè¥å¹²é¢åã§ãããXcode ã®ã¤ã³ã¿ãã§ã¼ã¹ã§ãããã°ã§ããããã«ãªã£ã¦ä¾¿å©ã§ãã