- 浏览: 831919 次
- 性别:
- 来自: lanzhou
文章分类
最新评论
-
liu346435400:
楼主讲了实话啊,中国程序员的现状,也是只见中国程序员拼死拼活的 ...
中国的程序员为什么这么辛苦 -
qw8226718:
国内ASP.NET下功能比较完善,优化比较好的Spacebui ...
国内外开源sns源码大全 -
dotjar:
敢问兰州的大哥,Prism 现在在12.04LTS上可用么?我 ...
最佳 Ubuntu 下 WebQQ 聊天体验 -
coralsea:
兄弟,卫星通信不是这么简单的,单向接收卫星广播信号不需要太大的 ...
Google 上网 -
txin0814:
我成功安装chrome frame后 在IE地址栏前加上cf: ...
IE中使用Google Chrome Frame运行HTML 5
MacRuby 0.5b1 and can be downloaded from here. The beta can only be used on Snow Leopard, which means its Intel-only. They switched from using YARV as the internal engine to using LLVM. The major side effect of this change is that Ruby code can now be compiled.
Compilation is still pretty rough though. Many simple programs won't work, so at this point it's more of an example then a useful tool.
In order to get MacRuby to compile code, you need to have LLVM installed. It doesn't come as part of the MacRuby 0.5b1 download. I found directions at the Hatena::Diary blog. They're in Japanese. I don't speak the language and Google Translate butchers it, so I'm recreating it here with some additional notes.
The first thing to do is to download and install MacRuby. It's a zip file containing an OS/X install package. The package installs the MacRuby binaries to /usr/local/bin. Make sure it's in your PATH. All of the usual Ruby suspects are here, prefaced with 'mac'. So you have 'macruby', 'macgem', 'macirb', etc.
After you install it, you can run pretty much any Ruby program with macruby. This is still very much a work in progress, so don't be surprised when a program doesn't run or doesn't run correctly.
You use the 'macrubyc' command to compile code. But if you try to run it now, you'll get an error saying that it can't find 'llc'. That's because you don't have LLVM installed. And you need a very current copy.
Here's where Hatena's directions come into play.
$ svn co -r 82747 https://llvm.org/svn/llvm-project/llvm/trunk llvm-trunk $ cd llvm-trunk $ ./configure --prefix ~/opt $ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make -j2 $ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install
The 'svn' command will checkout revision 82747 of LLVM into the directory 'llvm-trunk'. Make sure you're in the directory you want the source checked out into when you run it.
The next two commands go down into the source code directory and set it up to install in an 'opt' directory under your home, e.g., '/Users/ctwise/opt'. This keeps the LLVM install local and won't conflict with any later system-wide installs. If you want LLVM installed to the same location as macruby then use the command './configure --prefix /usr/local'.
The fourth command compiles LLVM. It's setup to run two compiles simultaneously. If you're using a tool that monitors CPU load, you'll see both CPUs pegged. This compile step takes a long time.
The last command installs LLVM into the location you specified. If you want LLVM installed to '/usr/local', then you'll need to change the install command slightly to use sudo.
$ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install
Once you add '~/opt/bin' to your PATH, you can start compiling Ruby.
This small test program compiles and runs fine.
puts "Hello, World!" 'abc'.each_char do |str| puts str.upcase end
When run with 'macruby', it produces this output:
$ macruby test.rb
Hello, World!
A
B
C
To compile the program you use 'macrubyc'.
$ macrubyc -o test test.rb
This will create an executable named 'test' as well as a 'test.o' object file.
-rwxr-xr-x 1 ctwise staff 14784568 Oct 8 09:28 test* -rw-r--r-- 1 ctwise staff 2408 Oct 8 09:28 test.o -rw-r--r-- 1 ctwise staff 69 Oct 8 09:27 test.rb
If you want, you can use the 'file' command to see what the files are.
$ file test* test: Mach-O 64-bit executable x86_64 test.o: Mach-O 64-bit object x86_64 test.rb: ASCII text $ ./test Hello, World! A B C
And when you run 'test', you'll see the same output as running 'macruby test.rb'.
When I tried slightly more complex projects using gems, the compile went through cleanly but the resulting executable exited with an error code. YMMV.
The help file for 'macrubyc' states that it supports 'normal' and 'full' compilation. But setting it to 'full' gives you a message that 'full' mode isn't supported yet. A more interesting option is the '-V' or '--verbose' option. This will show you the actual commands being run to compile the code.
发表评论
-
Ruby 1.8 and 1.9 living in harmony
2010-02-22 07:54 856I’m running on OSX, and using M ... -
Metaprogramming in Ruby: It’s All About the Self
2009-11-16 11:28 878After writing my last post on R ... -
Perl vs. Python vs. Ruby
2009-11-07 21:05 1128I’m evaluating Python and Rub ... -
A Teenage Boy Improved Ruby 1.9 Performance Up to 63%
2009-11-06 18:26 869Japanese online magazine, @IT J ... -
Ruby Best Practices - The Complete Class
2009-11-04 16:21 1021A remark: we enabled comment mo ... -
调查显示Ruby北美地区用户量上升
2009-10-30 07:38 566据Evans Data最近针对400名开发用户的调查表明,R ... -
RubyForge将停止工作,RubyGems.org接替Gem hosting服务
2009-10-28 14:14 1824Ruby Gem维护者请注意,数周前,GitHubGitHub ... -
有关Ruby企业版1.8.7的一些介绍
2009-10-18 08:54 1276前几周,Ruby企业版(Rub ... -
3 Ruby Quirks You Have to Love
2009-10-16 10:50 625Ruby’s a fantastic language; we ... -
Distilling JRuby: The JIT Compiler
2009-10-09 08:40 1115The JIT compiler in JRuby is a ... -
10月编程语言排行榜:Ruby稳步提升
2009-10-08 08:07 980新闻来源:51CTO.COMTIOBE今日公布了2009年10 ... -
为你的.NET应用程序添加一个REPL控制台
2009-10-07 12:45 749微软开始推广IronPython和IronRuby,希望它们可 ... -
Installing Ruby 1.8 and 1.9 on Ubuntu from Source
2009-10-05 14:18 896$ sudo apt-get build-dep ru ... -
Compiling Ruby 1.9.1 (stable) on Ubuntu
2009-10-05 14:13 728I found the default ruby inst ... -
JRuby综述:1.4的新特性、JRubyConf议程及MLVM
2009-10-02 08:25 857JRuby 1.4 RC1即将发布,我们来看看新版本都有哪些新 ... -
Ruby Enterprise Edition 1.8.7-20090928 released
2009-09-30 08:09 1160In the not so distant past we l ... -
Ruby DCamp,低迷经济下别开生面的会议
2009-09-22 08:47 974经济的低迷不仅影响了 ... -
Ruby静态分析工具检视:metric_fu, Simian, Saikuro以及其他
2009-09-17 08:59 1460代码质量构成了软件质 ... -
Ruby 1.9.1程序库兼容性纵览
2009-09-15 09:38 1088ruby.1.9.1是1.9.x系列第一 ... -
ruby 1.9 真有这么快吗?
2009-09-14 18:26 1158早在今年2月份,Antonio Cangiano 发表过一份关 ...
相关推荐
Compiling with Continuations ANDREW W. APPEL CAMBRIDGE UNIVERSITY PRESS 1992
Hosek-Compiling cross-toolchains with CMake and runtimes build.pdf
Advanced C and C++ Compiling
Aho and Ullman - The Theory of Parsing, Translation, and Compiling - Vol. 1 (1972).djvu Aho and Ullman - The Theory of Parsing, Translation, and Compiling - Vol. 2 (1973).djvu
Advanced C and C++ Compiling.pdf
VC调试出现“Compiling... ,Error spawning cl.exe”错误的解决办法
android反编译过程需要的一些工具 mac下的一些工具 包括apktool dex2jar jd-jui
vs6.0安装及运行 和解决 Compiling... error spawning cl.exe 的问题
超级经典的C++编译器解析,全部pdf格式,超清晰,内容详细,教程经典!
C++ Compiler for compiling c++ program
Compiling the Linux kernel
Your one-stop guide to the common patterns and practices, showing you how to apply these using the Go programming languageAbout This Book* This short, concise, and practical guide is packed with real-...
This book focuses on pure Python whenever possible to minimize compiling platform-dependent binaries, so that you don't become bogged down in just getting ready to do analysis., 'Learning Geospatial ...
Compiling and Installing
JorenB-quantum-compiling.zip
As the first guide to focus on Mono for Android, this must-have resource dives into writing applications against Mono with C# and compiling executables that run on the Android family of devices. ...
PyBuilder是在Windows上用于将python脚本编译为exe格式的构建工具。 它具有易于使用的界面,并使用py2exe进行编译。 不再需要弄乱命令提示符或安装脚本。 PyBuilder会为您完成。