Can I get a clarification on what the Compilation build step does? GOAL: Compile a MacRuby app and remove unnecessary Ruby files in order to achieve the smallest app size possible. I have a MacRuby 0.6 application built with Xcode. I'm building it with the Compile option so I get .rbo files in my app bundle. I also deleted all the /usr/lib/ruby Ruby files in the built app in order to reduce the final size of the app (25 MB saved): https://gist.github.com/6af67e1927969b9a47c1 My app uses Ruby's File and Dir classes, but everything else is Cocoa. Surprisingly, it works on several different machines, even without MacRuby 0.6 installed. Do I understand correctly that the code of those files is compiled into the .rbo files in my app? Or is it getting File and Dir from my MRI Ruby installation? -- Geoffrey Grosenbach boss@topfunky.com ........................ PeepCode Screencasts http://peepcode.com
Hi Geoffrey, On Jun 28, 2010, at 11:43 AM, Geoffrey Grosenbach wrote:
Can I get a clarification on what the Compilation build step does?
GOAL: Compile a MacRuby app and remove unnecessary Ruby files in order to achieve the smallest app size possible.
I have a MacRuby 0.6 application built with Xcode. I'm building it with the Compile option so I get .rbo files in my app bundle. I also deleted all the /usr/lib/ruby Ruby files in the built app in order to reduce the final size of the app (25 MB saved):
This looks good, although you can also pass --no_stdlib to macruby_deploy to achieve the same effect (no need to add another target) :)
My app uses Ruby's File and Dir classes, but everything else is Cocoa.
Surprisingly, it works on several different machines, even without MacRuby 0.6 installed.
Do I understand correctly that the code of those files is compiled into the .rbo files in my app? Or is it getting File and Dir from my MRI Ruby installation?
It's because File and Dir are core / builtin classes (like Array and String), they are part of libmacruby.dylib which is still in your .app bundle. You deleted the standard library. HTH, Laurent
On Mon, Jun 28, 2010 at 1:20 PM, Laurent Sansonetti <lsansonetti@apple.com> wrote:
It's because File and Dir are core / builtin classes (like Array and String), they are part of libmacruby.dylib which is still in your .app bundle. You deleted the standard library.
That makes sense. I'll use the --no_stdlib flag as suggested, which cuts my app size in half. Thanks! -- Geoffrey Grosenbach ........................ PeepCode Screencasts http://peepcode.com
On Jun 28, 2010, at 5:56 PM, Geoffrey Grosenbach wrote:
On Mon, Jun 28, 2010 at 1:20 PM, Laurent Sansonetti <lsansonetti@apple.com> wrote:
It's because File and Dir are core / builtin classes (like Array and String), they are part of libmacruby.dylib which is still in your .app bundle. You deleted the standard library.
That makes sense. I'll use the --no_stdlib flag as suggested, which cuts my app size in half.
If you still want a cut out space, I recommend running `strip -x' on your main executable and .rbo files. Finally, if you only want to target 64-bit environments (even if there are still people using 32-bit only macs), you can trim out the 32-bit parts of each binary file, using `lipo -remove', which should cut in half the overall size too. In the upcoming 0.7 release static compilation will be permitted, you will be able to generate a standalone binary that contains both the MacRuby runtime (some features disabled) and your application code, in about 1.5MB for regular-size apps. Laurent
Hi!
In the upcoming 0.7 release static compilation will be permitted, you will be able to generate a standalone binary that contains both the MacRuby runtime (some features disabled) and your application code, in about 1.5MB for regular-size apps.
I tested that and it is looking great: only 1379704 bytes for my small app! That size makes MacRuby really useable for Quicklook and Spotlight plugins. But what about garbage collection? If Macruby.sharedRuntime.evaluateString could use memory of an enclosing NSAutoreleasePool it would be very easy: OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options) { if (QLPreviewRequestIsCancelled(preview)) return noErr; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; …; NSMutableString* html = [[MacRuby sharedRuntime] evaluateString ….]; QLPreviewRequestSetDataRepresentation(preview, (CFDataRef)[html dataUsingEncoding:NSUTF8StringEncoding], kUTTypeHTML, (CFDictionaryRef)props); [pool release]; return noErr; } - Bernd
participants (3)
-
B. Ohr
-
Geoffrey Grosenbach
-
Laurent Sansonetti