[plt-scheme] standalone exes
At Sun, 14 Mar 2004 10:19:54 -0500, Pedro Pinto wrote:
> Matthew Flatt wrote:
> >Actually, I'm not sure how to handle them. One solution, I think, is to
> >copy an extension with the executable, and then redirect `require's to
> >use the extension relative to the executable.
>
> I am not sure I understand your suggestion, can you elaborate a little?
> mzc refuses to create the exe in the first place, do you suggest
> replacing the extension with a dummy scheme module to get over this?
Yes...
I meant the paragraph as a sketch of how mzc should probably work, but
I'll try to elaborate it into a suggestion. It's complicated enough
that I'll probably miss an important detail.
If I understand correctly, you currently have
<somewhere>/compiled/native/<platform>/ext.{so,dll}
and you access it with
(require "ext.ss" <somewhere>)
One possibility is that you move the extension and create
<somewhere>/ext.ss
which uses `load-extension' directly to load the extension. While
loading the extension, "ext.ss" will need to a prefix for the
extension-based module with `current-module-name-prefix' to avoid
module-name collisions. The "ext.ss" module will also uses
`dynamic-require' to extract exports from the extension, and then
re-export them with `provide':
(module ext mzscheme
...
(parameterize ([current-module-name-prefix <prefix>])
(load-extension ...))
(define x (dynamic-require <extension-name> 'x))
...
(provide x ...))
where <extension-name> depends on <prefix>.
The `load-extension' part will need to search for the extension so that
it finds it whether the program is in stand-alone mode or not.
Among the problems with this approach: If the extension exports many
names, keeping "ext.ss" in sync manually will be a pain. Perhaps
"ext.ss" can be generated from the extension's source, though.
Matthew