[racket] Providing binary to third party

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Wed Jul 28 16:17:23 EDT 2010

Hello,

I need to provide a binary executable of my program of a third party
which shouldn't need to have any racket stuff installed. This turns
out seems to be harder than I initially predicted and it is not the
first time I face this
(http://article.gmane.org/gmane.lisp.scheme.plt/34633).

My program generates some racket code on the fly as a unit, and links
to it during runtime.
On the above thread, Matthew refers to two problems. The first is
solved with ++lib racket/base/lang/reader in the raco exe command
line.

The second was solved, in plt-scheme era, by putting all the files
under a development link in planet. However, now in racket, when I
start my program after compilation with the following:
$ ~/Applications/racket-5.0.1.1/bin/raco exe -o eboc --vv ++lib
racket/base/lang/reader main.rkt
$ ./eboc
 pmatos at mietzekatze:~/Code/eboc $  ./eboc
standard-module-name-resolver: collection not found: "planet" in any
of: (#<path:/home/pmatos/Code/collects>)

 === context ===
standard-module-name-resolver
standard-module-name-resolver
/home/pmatos/Code/eboc/modes/esmc-mode.rkt:23:0: esmc-mode
#%mzc:main: [running body]
loop

It seems that there is some problem in finding the planet collection.

I wanted to know two things:
- Is there a way to avoid planet links altogether and maybe rely
solely on a special path? Maybe have a collects directory just for my
libraries which are included in the executable when I compile it?
- When I generate the racket code as a unit and link it, is this code
then ran through the jit? Meaning, is it as fast as it can be?

You can still reproduce the problem with the code I sent on the
initial thread (which I duplicate to ease access to it):
Let me add that the problem this actually reproduces is quite wierd...
and I am not even sure I was expecting this but it is definitely
something I will face in the future so it is good to get it sorted.

test-sig.rkt
---------------
#lang racket
(define-signature test^
   (x))
(provide test^)

gen.rkt
----------
#lang racket

(require "test-sig.rkt")

(define (generate)
  (let ([filename (make-temporary-file)]
        [cdir (current-directory)])
    (call-with-output-file filename
      #:mode 'text
      #:exists 'replace
      (lambda (fp)
        (fprintf fp "#lang racket~n~n")
        (fprintf fp "(require (file \"~atest-sig.rkt\"))" (path->string cdir))
        (fprintf fp "(provide test@)")
        (fprintf fp "(define-unit test@ (import test^) (export)~n")
        (fprintf fp "(* x 2)")
        (fprintf fp ")"))); closes define-unit
    filename))

(let* ([file (generate)]
       [test@ (dynamic-require file 'test@)]
       [x 5]
       [result (invoke-unit test@ (import test^))])
  (printf "Result: ~a~n" result))



Interaction:
----------------
$  ~/Applications/racket-5.0.1.1/bin/raco exe ++lib racket/lang/reader
-o gen gen.rkt
$  ./gen
define-compound-unit: unit argument expects an untagged import with
signature test^, which this usage context does not supply

 === context ===
/home/pmatos/Applications/racket-5.0.1.1/collects/mzlib/private/unit-runtime.rkt:67:2:
loop
/home/pmatos/Applications/racket-5.0.1.1/collects/mzlib/private/unit-runtime.rkt:133:0:
check-sigs
#%mzc:gen: [running body]
loop


Cheers,
-- 
PMatos


Posted on the users mailing list.