Thanks for the detailed response. I'll have to take a stab at one of these methods, probably the scripting one for starters. nm... things I should have known yesterday :)
- Dylan On Fri, Nov 27, 2009 at 2:11 PM, Laurent Sansonetti <lsansone...@apple.com>wrote: > Hi Dylan, > > Sorry for the late response. > > > On Nov 25, 2009, at 10:21 AM, Dylan Bruzenak wrote: > > Hi all, >> >> First, great work with the 0.5b2 release. I'm starting to use this for >> more serious development and it does most of the things I need very well. >> After a brief struggle last night I managed to get the code for one of my >> projects compiling using the new macruby_deploy method and it works like a >> charm. >> >> However, I would like to include the .rbo files in the same executable >> inside the .app bundle as my objc files, rather than as separate files in >> the resources directory. >> >> To that end I defined a build rule that picks up .rb files and uses >> macrubyc to compile them. I moved the .rb files into the 'compile sources' >> build step, which causes the output .o files to be included in the >> excutable. >> >> I then ran into an obvious snag: the ruby environment isn't intialized and >> the classes are not being pulled in. After some investigation of the rubyc >> file I can see that you're creating a custom .mm file that calls a number of >> set up methods for the runtime and an MREP_UUID function for each class. A >> few questions: >> >> 1.) Is there a way that I can find these MREP function names and call them >> dynamically ? I was considering modifying the generator to output a .m file >> with a class that just has an init method that calls these, but it isn't >> compatible with the build rule approach above. >> > > You can use the nm(1) tool against every .o file to locate the MREP_ symbol > name. > > > 2.) Is there an easier way to set up this environment than the code below >> ? >> >> ruby_sysinit(&argc, &argv); >> if (argc > 0) { >> argc--; >> argv++; >> } >> >> ruby_init(); >> ruby_set_argv(argc, argv); >> rb_vm_init_compiler(); >> try { >> void *self = rb_vm_top_self(); >> //MREP FUNCTION CALLS GO HERE :) >> } >> catch (...) { >> rb_vm_print_current_exception(); >> rb_exit(1); >> } >> rb_exit(0); >> >> 3.) Am I nuts ? If there's a much easier way to do this, please let me >> know :) >> > > You're not nuts :) Having the ability to compile all the source code of an > application into the same executable is something we definitely want to > feature. Your approach should work but I would like to offer a solution that > doesn't require any change in MacRuby or the application code. I also want a > solution that works on non-Xcode projects (command-line tools). > > Basically, my plan is to add a global table in MacRuby core that would be > filled by macrubyc once you produce an executable based on .o Ruby files. > The table would be a simple "Ruby file path" to "MREP_ function name" > mapping. Then, at runtime, #require would look into that table and > appropriately run the initializers. > > I haven't had the time to implement this idea yet. I may do it for the > final 0.5. Hopefully this can be done in macruby_deploy. Any help would be > greatly appreciated :) > > Laurent > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel >
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel