From: Patrik Sundberg Date: 2001-12-18T20:09:16+09:00 Subject: [ruby-talk:28861] Re: [IDEA] creating stand-alone versions for easy distribution etc On Tue, Dec 18, 2001 at 07:30:27PM +0900, Robert Feldt wrote: > On Tue, 18 Dec 2001, Patrik Sundberg wrote: > > > i actually didn't look into your rbwrap since i recall it was windows only. at > > a closer look it might be a lot like what the python application does, in > > principle at least. > > > rbwrap is windows-specific but not very much. The README mentions what you > need to do to make it work on another platform: > > Here's what you need to do (I might have missed something...): > > * Make sure find_ruby_binaries identifies all ruby binaries needed > to run Ruby as a stand-alone app on your platform. Current impl. > is very Cygwin-specific (and ugly!). I plan to replace it as > soon > as possible. Any ideas you might have are welcomed. > > * Make sure compiler can be accessed. I currently do > system "gcc ..." > > * Make memunwrapper.c compilable, linkable and runnable. > > Check file separators. Currently assumes its "\". > > It currently uses some Windows- or Cygwin-specific API calls. > Nothing fancy and it's straightforward to find corresponding > calls on your platform: > GetModuleFileNameA - to get the name of the unwrapper exe > This is unnecessary and I plan to take it from > argv > instead. > GetTempPath - Get path to temp dir > > > a description of their approach is at: > > http://www.mcmillan-inc.com/standalones.html > > > I guess its more mature than rbwrap so probably focus on their stuff > first? probably. but for finding dependencies i don't know how much help their package is, but perhaps some ideas can be copied. I like their idea of creating an archive (CArchive), like a .jar file, and modifying the python 'import' somehow. Exactly how this works I don't know, but my understanding (as of 20min experience :)) is: 1. analyze your main script and recursivly loaded files etc to get a dependency list for your application 2. create an archive of these files. 3. create a exe which somehow executes your main script. at the end of this exe append the archive you created. (executing the main script probably also uses the method in 4 below) 4. modify require and load to be able to find files also in a archive. this is done by using the filename of the executable and opening this file and searching for the archive and creating a archive object from data (marshalling?) their are some comments on self-extraction not working with .so files under unix OS's but I don't quite get this yet. to me it seems doable =) my ruby solution would be: 1. create a good tool for analyzing dependencies. must also be able to fall back on explicitly named dependencies. 2. create an archive class for ruby. this would hold just about any file and have a table of contents to be able to find files. 3. create modified versions of require and load which can use a $ARCHIVEPATH and a $ARCHIVEARRAY for require/load. in $ARCHIVEPATH we list directories to search for arhivefiles (which are marshalled versions of archive objects) and in $ARCHIVEARRAY we put already created archive objects (like the one we will create from the data at the end of a executable). 4. write a tool which finds dependencies, creates a archive, creates a exe which will: - create a ruby interpreter (link staticly with libruby and we get the version used by the packager?) passing any arguments etc. - apply the require/load mods - read the archive from end of file (using argv[0] to find filename?) - create ruby object from data and stuff it into the $ARCHIVEARRAY - load the main script using the modified load (i.e from the archive at the end of the file) to me this at a glance seems doable and quite straigt forward :) any reflections? -- ---------------------------------------------------------------------------. Patrik Sundberg Address: Rydsv�gen 100C, 584 31 Link�ping, Sweden | Email: ps@raditex.se || ps@radiac.mine.nu | Phone: +46 13 178567 || +46 707 602240 | .---> Applied Physics and Electrical Engineering student | |-----> Master of Science in Business Administration and Economics student | |-------> UNIX/Programming consultant | `--------------------------------------------------------------------------'