add `configure-runtime' submodule support

A language can now introduce a `configure-runtime' submodule that
is `dynamic-require'd before the enclosing module.

This new submodule protocol provides a more general and
easier-to-understand way of configuring the run-time environment for
a module's language, as compared to the `module->language-info'
path (through a `get-info' function, via a 'configure-runtime value,
and finally loading the specified module).

The `module->language-info' path remains in place, and it is
checked after a `configure-runtime' submodule is run, since
that order is likely to be the most backward compatible.

original commit: 27f1b39294
This commit is contained in:
Matthew Flatt 2013-05-05 11:36:56 -06:00
parent 0416b4a5ff
commit 8254cd3d98
3 changed files with 28 additions and 7 deletions

View File

@ -101,22 +101,29 @@
dest
(exe-aux)))]
[else
(define mod-sym (string->symbol
(format "#%mzc:~a"
(let-values ([(base name dir?)
(split-path source-file)])
(path->bytes (path-replace-suffix name #""))))))
(mzc:create-embedding-executable
dest
#:mred? (gui)
#:variant (if (3m) '3m 'cgc)
#:verbose? (very-verbose)
#:modules (cons `(#%mzc: (file ,source-file) (main))
#:modules (cons `(#%mzc: (file ,source-file) (main configure-runtime))
(map (lambda (l) `(#t (lib ,l)))
(exe-embedded-libraries)))
#:configure-via-first-module? #t
#:early-literal-expressions
(parameterize ([current-namespace (make-base-namespace)])
(define cr-sym (string->symbol (format "~a(configure-runtime)" mod-sym)))
(list
(compile
`(when (module-declared? '',cr-sym)
(dynamic-require '',cr-sym #f)))))
#:literal-expression
(parameterize ([current-namespace (make-base-namespace)])
(define mod-sym (string->symbol
(format "#%mzc:~a"
(let-values ([(base name dir?)
(split-path source-file)])
(path->bytes (path-replace-suffix name #""))))))
(define main-sym (string->symbol (format "~a(main)" mod-sym)))
(compile
`(begin

View File

@ -0,0 +1,6 @@
#lang racket/kernel
(printf "This is 22.\n")
(module configure-runtime racket/kernel
(printf "Configure!\n"))

View File

@ -304,7 +304,15 @@
(path->string (build-path (collection-path "tests" "racket") "embed-me20.rkt")))
(try-exe (mk-dest mred?) "This is 20.\n" mred?)
;;raco exe --launcher
;; raco exe on a module with a `configure-runtime' submodule
(system* raco
"exe"
"-o" (path->string (mk-dest mred?))
(if mred? "--gui" "--")
(path->string (build-path (collection-path "tests" "racket") "embed-me22.rkt")))
(try-exe (mk-dest mred?) "Configure!\nThis is 22.\n" mred?)
;; raco exe --launcher
(system* raco
"exe"
"--launcher"