|
|
|
@ -61,20 +61,29 @@
|
|
|
|
|
|
|
|
|
|
(define-namespace-anchor cache-utils-module-ns)
|
|
|
|
|
|
|
|
|
|
(define my-caching-compile-proc (make-caching-managed-compile-zo))
|
|
|
|
|
;; check 'gc not 'vm because 'gc is supported before 6.7
|
|
|
|
|
(define running-on-cs? (eq? (system-type 'gc) 'cs))
|
|
|
|
|
;; faster than the usual `managed-compile-zo`
|
|
|
|
|
(define caching-zo-compiler (make-caching-managed-compile-zo))
|
|
|
|
|
|
|
|
|
|
(define (path->hash path)
|
|
|
|
|
(for ([p (in-list (or (get-directory-require-files path) null))])
|
|
|
|
|
(my-caching-compile-proc p))
|
|
|
|
|
(when running-on-cs?
|
|
|
|
|
;; this makes builds faster,
|
|
|
|
|
;; but a bytecode-caching bug in Racket BC
|
|
|
|
|
;; restricts it to CS for now
|
|
|
|
|
(my-caching-compile-proc path))
|
|
|
|
|
(apply hasheq
|
|
|
|
|
(let ([doc-key (setup:main-export)] [meta-key (setup:meta-export)])
|
|
|
|
|
(define compilation-namespace
|
|
|
|
|
(cond
|
|
|
|
|
[(current-session-interactive?)
|
|
|
|
|
;; in interactive mode, we need a fresh namespace every time
|
|
|
|
|
;; and can't use bytecode, because it's possible that path
|
|
|
|
|
;; or any dependency (say, "pollen.rkt") has changed
|
|
|
|
|
(define bns (make-base-namespace))
|
|
|
|
|
(define outer-ns (namespace-anchor->namespace cache-utils-module-ns))
|
|
|
|
|
;; bring in currently instantiated params (unlike namespace-require)
|
|
|
|
|
(namespace-attach-module outer-ns 'pollen/setup bns)
|
|
|
|
|
bns]
|
|
|
|
|
[else
|
|
|
|
|
;; make bytecode, because we know that in a non-interactive sesssion
|
|
|
|
|
;; the sources won't change in the midst
|
|
|
|
|
(for-each caching-zo-compiler (cons path (or (get-directory-require-files path) null)))
|
|
|
|
|
; recycle namespace
|
|
|
|
|
(current-namespace)]))
|
|
|
|
|
(define doc-key (setup:main-export))
|
|
|
|
|
(define meta-key (setup:meta-export))
|
|
|
|
|
(unless (and (symbol? doc-key) (symbol? meta-key))
|
|
|
|
|
(raise-argument-error 'path->hash "symbols for doc and meta key" (cons doc-key meta-key)))
|
|
|
|
|
;; I monkeyed around with using the metas submodule to pull out the metas (for speed)
|
|
|
|
@ -84,15 +93,12 @@
|
|
|
|
|
;; the benefit of not reloading doc when you just need metas.
|
|
|
|
|
;; new namespace forces `dynamic-require` to re-instantiate `path`
|
|
|
|
|
;; otherwise it gets cached in current namespace.
|
|
|
|
|
(parameterize ([current-namespace (make-base-namespace)]
|
|
|
|
|
[current-directory (dirname path)])
|
|
|
|
|
;; brings in currently instantiated params (unlike namespace-require)
|
|
|
|
|
(define outer-ns (namespace-anchor->namespace cache-utils-module-ns))
|
|
|
|
|
(namespace-attach-module outer-ns 'pollen/setup)
|
|
|
|
|
(define doc-missing-thunk (λ () ""))
|
|
|
|
|
(define metas-missing-thunk (λ () (hasheq)))
|
|
|
|
|
(list doc-key (dynamic-require path doc-key doc-missing-thunk)
|
|
|
|
|
meta-key (dynamic-require path meta-key metas-missing-thunk))))))
|
|
|
|
|
(parameterize ([current-namespace compilation-namespace]
|
|
|
|
|
[current-directory (dirname path)])
|
|
|
|
|
(hasheq doc-key (dynamic-require path doc-key doc-missing-thunk)
|
|
|
|
|
meta-key (dynamic-require path meta-key metas-missing-thunk))))
|
|
|
|
|
|
|
|
|
|
(define (my-make-directory* dir)
|
|
|
|
|
(define base (dirname dir))
|
|
|
|
|