define-runtime-path: add a #:runtime?-id
option
The expression in a `define-runtime-path` form is used in both a run-time context and a compile-time context. The latter is used for `raco exe`. In a cross-build context, you might need to load OpenSSL support for Linux (say) at build time while generating executables that refer to Windows (say) OpenSSL support. In that case, `#:runtime?-id` lets you choose between `(cross-system-type)` and `(system-type)`. Merge to v6.4
This commit is contained in:
parent
0d3066d8db
commit
417d9b0e73
|
@ -641,13 +641,18 @@ In addition to the bindings described below,
|
|||
@tech{phase level} 1, since string constants are often used as
|
||||
compile-time expressions with @racket[define-runtime-path].
|
||||
|
||||
@defform[(define-runtime-path id expr)]{
|
||||
@defform[(define-runtime-path id maybe-runtime?-id expr)
|
||||
#:grammar ([maybe-runtime? code:blank
|
||||
(code:line #:runtime?-id runtime?-id)])]{
|
||||
|
||||
Uses @racket[expr] as both a compile-time (i.e., @tech{phase} 1)
|
||||
expression and a run-time (i.e., @tech{phase} 0) expression. In either
|
||||
context, @racket[expr] should produce a path, a string that represents
|
||||
a path, a list of the form @racket[(list 'lib _str ...+)], or a list
|
||||
of the form @racket[(list 'so _str)] or @racket[(list 'so _str _vers)].
|
||||
If @racket[runtime?-id] is provided, then it is bound in the context
|
||||
of @racket[expr] to @racket[#f] for the compile-time instance of
|
||||
@racket[expr] and @racket[#t] for the run-time instance of @racket[expr].
|
||||
|
||||
For run time, @racket[id] is bound to a path that is based on the
|
||||
result of @racket[expr]. The path is normally computed by taking a
|
||||
|
@ -781,23 +786,25 @@ Examples:
|
|||
[(windows) '(so "ssleay32")]
|
||||
[else '(so "libssl")]))
|
||||
(define libssl (ffi-lib libssl-so))
|
||||
]}
|
||||
]
|
||||
|
||||
@history[#:changed "6.4" @elem{Added @racket[#:runtime?-id].}]}
|
||||
|
||||
|
||||
@defform[(define-runtime-paths (id ...) expr)]{
|
||||
@defform[(define-runtime-paths (id ...) maybe-runtime?-id expr)]{
|
||||
|
||||
Like @racket[define-runtime-path], but declares and binds multiple
|
||||
paths at once. The @racket[expr] should produce as many values as
|
||||
@racket[id]s.}
|
||||
|
||||
|
||||
@defform[(define-runtime-path-list id expr)]{
|
||||
@defform[(define-runtime-path-list id maybe-runtime?-id expr)]{
|
||||
|
||||
Like @racket[define-runtime-path], but @racket[expr] should produce a
|
||||
list of paths.}
|
||||
|
||||
|
||||
@defform[(define-runtime-module-path-index id module-path-expr)]{
|
||||
@defform[(define-runtime-module-path-index id maybe-runtime?-id module-path-expr)]{
|
||||
|
||||
Similar to @racket[define-runtime-path], but @racket[id] is bound to a
|
||||
@tech{module path index} that encapsulates the result of
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
;; raco distribute should include Racket's sqlite3 if present
|
||||
(define-runtime-path sqlite-so
|
||||
(case (cross-system-type)
|
||||
#:runtime?-id runtime?
|
||||
(case (if runtime? (system-type) (cross-system-type))
|
||||
[(windows) '(so "sqlite3")]
|
||||
[else '(so "libsqlite3" ("0" #f))]))
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
;; We need to declare because they might be distributed with Racket,
|
||||
;; in which case they should get bundled with stand-alone executables:
|
||||
(define-runtime-path libcrypto-so
|
||||
(case (cross-system-type)
|
||||
#:runtime?-id runtime?
|
||||
(case (if runtime? (system-type) (cross-system-type))
|
||||
[(windows) '(so "libeay32")]
|
||||
[(macosx)
|
||||
;; Version "1.0.0" is bundled with Racket
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
;; We need to declare because they might be distributed with PLT Scheme
|
||||
;; in which case they should get bundled with stand-alone executables:
|
||||
(define-runtime-path libssl-so
|
||||
(case (cross-system-type)
|
||||
#:runtime?-id runtime?
|
||||
(case (if runtime? (system-type) (cross-system-type))
|
||||
[(windows) '(so "ssleay32")]
|
||||
[(macosx)
|
||||
;; Version "1.0.0" is bundled with Racket
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
|
||||
(define-syntax (-define-runtime-path stx)
|
||||
(syntax-case stx ()
|
||||
[(_ orig-stx (id ...) expr to-list to-values need-dir?)
|
||||
[(_ orig-stx (id ...) expr to-list to-values need-dir? runtime?-id)
|
||||
(let ([ids (syntax->list #'(id ...))])
|
||||
(unless (memq (syntax-local-context) '(module module-begin top-level))
|
||||
(raise-syntax-error #f "allowed only at the top level" #'orig-stx))
|
||||
|
@ -180,7 +180,7 @@
|
|||
#'orig-stx)))
|
||||
#`(begin
|
||||
(define-values (id ...)
|
||||
(let-values ([(id ...) expr])
|
||||
(let-values ([(id ...) (let ([runtime?-id #t]) expr)])
|
||||
(let ([get-dir #,(if (syntax-e #'need-dir?)
|
||||
#`(lambda ()
|
||||
(path-of
|
||||
|
@ -195,24 +195,28 @@
|
|||
(begin-for-syntax
|
||||
(register-ext-files
|
||||
(#%variable-reference)
|
||||
(let-values ([(id ...) expr])
|
||||
(let-values ([(id ...) (let ([runtime?-id #f]) expr)])
|
||||
(to-list id ...))))))]))
|
||||
|
||||
(define-syntax (define-runtime-path stx)
|
||||
(syntax-case stx ()
|
||||
[(_ id expr) #`(-define-runtime-path #,stx (id) expr list values #t)]))
|
||||
[(_ id expr) #`(-define-runtime-path #,stx (id) expr list values #t runtime?)]
|
||||
[(_ id #:runtime?-id runtime?-id expr) #`(-define-runtime-path #,stx (id) expr list values #t runtime?-id)]))
|
||||
|
||||
(define-syntax (define-runtime-paths stx)
|
||||
(syntax-case stx ()
|
||||
[(_ (id ...) expr) #`(-define-runtime-path #,stx (id ...) expr list values #t)]))
|
||||
[(_ (id ...) expr) #`(-define-runtime-path #,stx (id ...) expr list values #t runtime?)]
|
||||
[(_ (id ...) #:runtime?-id runtime?-id expr) #`(-define-runtime-path #,stx (id ...) expr list values #t runtime?-id)]))
|
||||
|
||||
(define-syntax (define-runtime-path-list stx)
|
||||
(syntax-case stx ()
|
||||
[(_ id expr) #`(-define-runtime-path #,stx (id) expr values list #t)]))
|
||||
[(_ id expr) #`(-define-runtime-path #,stx (id) expr values list #t runtime?)]
|
||||
[(_ id #:runtime?-id runtime?-id expr) #`(-define-runtime-path #,stx (id) expr values list #t runtime?-id)]))
|
||||
|
||||
(define-syntax (define-runtime-module-path-index stx)
|
||||
(syntax-case stx ()
|
||||
[(_ id expr) #`(-define-runtime-path #,stx (id) `(module ,expr ,(#%variable-reference)) list values #f)]))
|
||||
[(_ id expr) #`(-define-runtime-path #,stx (id) `(module ,expr ,(#%variable-reference)) list values #f runtime?)]
|
||||
[(_ id #:runtime?-id runtime?-id expr) #`(-define-runtime-path #,stx (id) `(module ,expr ,(#%variable-reference)) list values #f runtime?-id)]))
|
||||
|
||||
(define-for-syntax required-module-paths (make-hash))
|
||||
(define-syntax (runtime-require stx)
|
||||
|
|
Loading…
Reference in New Issue
Block a user