change 'configure-runtime to produce a list of module-spcifying vectors instead of a single vector
svn: r18763
This commit is contained in:
parent
8fbd16261f
commit
bebf513aa7
|
@ -781,18 +781,20 @@
|
||||||
[__
|
[__
|
||||||
;; Load all code:
|
;; Load all code:
|
||||||
(for-each get-code-at files collapsed-mps)]
|
(for-each get-code-at files collapsed-mps)]
|
||||||
[config-info (and config?
|
[config-infos (if config?
|
||||||
(let ([a (assoc (car files) (unbox codes))])
|
(let ([a (assoc (car files) (unbox codes))])
|
||||||
(let ([info (module-compiled-language-info (mod-code a))])
|
(let ([info (module-compiled-language-info (mod-code a))])
|
||||||
(when info
|
(when info
|
||||||
(let ([get-info ((dynamic-require (vector-ref info 0) (vector-ref info 1))
|
(let ([get-info ((dynamic-require (vector-ref info 0) (vector-ref info 1))
|
||||||
(vector-ref info 2))])
|
(vector-ref info 2))])
|
||||||
(get-info 'configure-runtime #f))))))])
|
(get-info 'configure-runtime null)))))
|
||||||
|
null)])
|
||||||
;; Add module for runtime configuration:
|
;; Add module for runtime configuration:
|
||||||
(when config-info
|
(when config-infos
|
||||||
|
(for ([config-info (in-list config-infos)])
|
||||||
(let ([mp (vector-ref config-info 0)])
|
(let ([mp (vector-ref config-info 0)])
|
||||||
(get-code-at (resolve-one-path mp)
|
(get-code-at (resolve-one-path mp)
|
||||||
(collapse-one mp))))
|
(collapse-one mp)))))
|
||||||
;; Drop elements of `codes' that just record copied libs:
|
;; Drop elements of `codes' that just record copied libs:
|
||||||
(set-box! codes (filter mod-code (unbox codes)))
|
(set-box! codes (filter mod-code (unbox codes)))
|
||||||
;; Bind `module' to get started:
|
;; Bind `module' to get started:
|
||||||
|
@ -929,12 +931,13 @@
|
||||||
(write (compile-using-kernel '(namespace-set-variable-value! 'module #f #t)) outp)
|
(write (compile-using-kernel '(namespace-set-variable-value! 'module #f #t)) outp)
|
||||||
(write (compile-using-kernel '(namespace-undefine-variable! 'module)) outp)
|
(write (compile-using-kernel '(namespace-undefine-variable! 'module)) outp)
|
||||||
(newline outp)
|
(newline outp)
|
||||||
(when config-info
|
(when config-infos
|
||||||
|
(for ([config-info (in-list config-infos)])
|
||||||
(let ([a (assoc (resolve-one-path (vector-ref config-info 0)) (unbox codes))])
|
(let ([a (assoc (resolve-one-path (vector-ref config-info 0)) (unbox codes))])
|
||||||
(write (compile-using-kernel `((dynamic-require '',(mod-full-name a)
|
(write (compile-using-kernel `((dynamic-require '',(mod-full-name a)
|
||||||
',(vector-ref config-info 1))
|
',(vector-ref config-info 1))
|
||||||
',(vector-ref config-info 2)))
|
',(vector-ref config-info 2)))
|
||||||
outp)))
|
outp))))
|
||||||
(for-each (lambda (f)
|
(for-each (lambda (f)
|
||||||
(when verbose?
|
(when verbose?
|
||||||
(fprintf (current-error-port) "Copying from ~s~n" f))
|
(fprintf (current-error-port) "Copying from ~s~n" f))
|
||||||
|
|
|
@ -322,8 +322,8 @@
|
||||||
((dynamic-require (vector-ref info 0)
|
((dynamic-require (vector-ref info 0)
|
||||||
(vector-ref info 1))
|
(vector-ref info 1))
|
||||||
(vector-ref info 2))])
|
(vector-ref info 2))])
|
||||||
(let ([config (get-info 'configure-runtime #f)])
|
(let ([configs (get-info 'configure-runtime null)])
|
||||||
(when config
|
(for ([config (in-list configs)])
|
||||||
((dynamic-require (vector-ref config 0)
|
((dynamic-require (vector-ref config 0)
|
||||||
(vector-ref config 1))
|
(vector-ref config 1))
|
||||||
(vector-ref config 2))))))))
|
(vector-ref config 2))))))))
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
(define ((module-info options) key default)
|
(define ((module-info options) key default)
|
||||||
(case key
|
(case key
|
||||||
[(configure-runtime) `#(htdp/bsl/runtime configure ,options)]
|
[(configure-runtime) `(#(htdp/bsl/runtime configure ,options))]
|
||||||
[else default]))
|
[else default]))
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
(lambda (key default)
|
(lambda (key default)
|
||||||
(case key
|
(case key
|
||||||
[(configure-runtime)
|
[(configure-runtime)
|
||||||
'#(racket/private/runtime configure #f)]
|
'(#(racket/private/runtime configure #f))]
|
||||||
[else default])))
|
[else default])))
|
||||||
|
|
|
@ -126,7 +126,8 @@ If the @scheme[#:configure-via-first-module?] argument is specified as
|
||||||
true, then the language of the first module in @scheme[mod-list] is
|
true, then the language of the first module in @scheme[mod-list] is
|
||||||
used to configure the run-time environment before the expressions
|
used to configure the run-time environment before the expressions
|
||||||
added by @scheme[#:literal-files] and @scheme[#:literal-expressions]
|
added by @scheme[#:literal-files] and @scheme[#:literal-expressions]
|
||||||
are evaluated.
|
are evaluated. See also @secref[#:doc '(lib
|
||||||
|
"scribblings/reference/reference.scrbl") "configure-runtime"].
|
||||||
|
|
||||||
The @scheme[#:cmdline] argument @scheme[cmdline] contains command-line
|
The @scheme[#:cmdline] argument @scheme[cmdline] contains command-line
|
||||||
strings that are prefixed onto any actual command-line arguments that
|
strings that are prefixed onto any actual command-line arguments that
|
||||||
|
|
|
@ -387,12 +387,13 @@ language specifies run-time configuration by
|
||||||
|
|
||||||
@item{having the function indicated by the @scheme['module-language]
|
@item{having the function indicated by the @scheme['module-language]
|
||||||
@tech{syntax property} recognize the
|
@tech{syntax property} recognize the
|
||||||
@scheme['configure-runtime] key, for which it returns another
|
@scheme['configure-runtime] key, for which it returns a list of
|
||||||
vector: @scheme[(vector _mp _name _val)] where @scheme[_mp] is
|
vectors; each vector must have the form @scheme[(vector _mp
|
||||||
a @tech{module path}, @scheme[_name] is a symbol, and
|
_name _val)] where @scheme[_mp] is a @tech{module path},
|
||||||
@scheme[_val] is an arbitrary value; and}
|
@scheme[_name] is a symbol, and @scheme[_val] is an arbitrary
|
||||||
|
value; and}
|
||||||
|
|
||||||
@item{having the function called as @scheme[((dynamic-require _mp
|
@item{having each function called as @scheme[((dynamic-require _mp
|
||||||
_name) _val)] configure the run-time environment, typically by
|
_name) _val)] configure the run-time environment, typically by
|
||||||
setting parameters such as @scheme[current-print].}
|
setting parameters such as @scheme[current-print].}
|
||||||
|
|
||||||
|
@ -400,3 +401,11 @@ language specifies run-time configuration by
|
||||||
|
|
||||||
The @schememodname[scheme/base] and @schememodname[scheme] languages
|
The @schememodname[scheme/base] and @schememodname[scheme] languages
|
||||||
do not currently specify a run-time configuration action.
|
do not currently specify a run-time configuration action.
|
||||||
|
|
||||||
|
A @scheme['configure-runtime] query returns a list of vectors, instead
|
||||||
|
of directly configuring the environment, so that the indicated modules
|
||||||
|
to be bundled with a program when creating a stand-alone
|
||||||
|
executable; see @secref[#:doc '(lib "scribblings/mzc/mzc.scrbl") "exe"].
|
||||||
|
|
||||||
|
For information on defining a new @hash-lang[] language, see
|
||||||
|
@schememodname[syntax/module-reader].
|
||||||
|
|
|
@ -168,14 +168,14 @@ typedef void (*Repl_Proc)(Scheme_Env *);
|
||||||
|
|
||||||
static void configure_environment(Scheme_Object *mod)
|
static void configure_environment(Scheme_Object *mod)
|
||||||
{
|
{
|
||||||
Scheme_Object *mli, *dyreq, *a[3], *gi, *v;
|
Scheme_Object *mli, *dyreq, *a[3], *gi, *v, *vs;
|
||||||
|
|
||||||
mli = scheme_builtin_value("module->language-info");
|
mli = scheme_builtin_value("module->language-info");
|
||||||
|
|
||||||
a[0] = mod;
|
a[0] = mod;
|
||||||
a[1] = scheme_make_true();
|
a[1] = scheme_make_true();
|
||||||
v = scheme_apply(mli, 2, a);
|
v = scheme_apply(mli, 2, a);
|
||||||
if (SCHEME_VECTORP(v)) {
|
if (SCHEME_VECTORP(v) && SCHEME_VEC_SIZE(v) == 3) {
|
||||||
dyreq = scheme_builtin_value("dynamic-require");
|
dyreq = scheme_builtin_value("dynamic-require");
|
||||||
|
|
||||||
a[0] = SCHEME_VEC_ELS(v)[0];
|
a[0] = SCHEME_VEC_ELS(v)[0];
|
||||||
|
@ -186,10 +186,28 @@ static void configure_environment(Scheme_Object *mod)
|
||||||
gi = scheme_apply(gi, 1, a);
|
gi = scheme_apply(gi, 1, a);
|
||||||
|
|
||||||
a[0] = scheme_intern_symbol("configure-runtime");
|
a[0] = scheme_intern_symbol("configure-runtime");
|
||||||
a[1] = scheme_make_false();
|
a[1] = scheme_make_null();
|
||||||
v = scheme_apply(gi, 2, a);
|
vs = scheme_apply(gi, 2, a);
|
||||||
if (!SAME_OBJ(v, scheme_make_false())) {
|
a[0] = vs;
|
||||||
|
while (SCHEME_PAIRP(vs)) {
|
||||||
|
v = SCHEME_CAR(vs);
|
||||||
|
vs = SCHEME_CDR(vs);
|
||||||
if (SCHEME_VECTORP(v) && SCHEME_VEC_SIZE(v) == 3) {
|
if (SCHEME_VECTORP(v) && SCHEME_VEC_SIZE(v) == 3) {
|
||||||
|
/* ok */
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!SCHEME_NULLP(vs)) {
|
||||||
|
scheme_wrong_type("runtime-configure", "list of vectors of three values",
|
||||||
|
-1, 0, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
vs = a[0];
|
||||||
|
while (SCHEME_PAIRP(vs)) {
|
||||||
|
v = SCHEME_CAR(vs);
|
||||||
|
vs = SCHEME_CDR(vs);
|
||||||
|
|
||||||
a[0] = SCHEME_VEC_ELS(v)[0];
|
a[0] = SCHEME_VEC_ELS(v)[0];
|
||||||
a[1] = SCHEME_VEC_ELS(v)[1];
|
a[1] = SCHEME_VEC_ELS(v)[1];
|
||||||
a[2] = SCHEME_VEC_ELS(v)[2];
|
a[2] = SCHEME_VEC_ELS(v)[2];
|
||||||
|
@ -197,11 +215,6 @@ static void configure_environment(Scheme_Object *mod)
|
||||||
|
|
||||||
a[0] = a[2];
|
a[0] = a[2];
|
||||||
scheme_apply_multi(v, 1, a);
|
scheme_apply_multi(v, 1, a);
|
||||||
} else {
|
|
||||||
a[0] = v;
|
|
||||||
scheme_wrong_type("current-print setup", "vector of three values",
|
|
||||||
-1, 0, a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user