From 1cb16c0440aea723ca1bc615a8b7ec363a76d3d6 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 20 Jan 2018 17:54:10 -0500 Subject: [PATCH] add `compile-cache-watchlist` (fixes #168) --- pollen/private/cache-utils.rkt | 4 +++- pollen/private/ts.rktd | 2 +- pollen/scribblings/setup.scrbl | 19 ++++++++++++++++++- pollen/setup.rkt | 2 ++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pollen/private/cache-utils.rkt b/pollen/private/cache-utils.rkt index 66186e0..441a099 100644 --- a/pollen/private/cache-utils.rkt +++ b/pollen/private/cache-utils.rkt @@ -24,7 +24,9 @@ ;; if template has a source file, track that instead (and template-path (or (get-source template-path) template-path)) ;; is either list of files or (list #f) - (->list (get-directory-require-files source-path)))) + (append (->list (get-directory-require-files source-path)) + ;; user-designated files to track + (map ->string (setup:compile-cache-watchlist source-path))))) (define pollen-env (getenv default-env-name)) (define poly-flag (and (has-inner-poly-ext? source-path) (current-poly-target))) (define path+mod-time-pairs diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index d8070c9..012ae0f 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1516080512 +1516488850 diff --git a/pollen/scribblings/setup.scrbl b/pollen/scribblings/setup.scrbl index 6b968dd..8ae4a37 100644 --- a/pollen/scribblings/setup.scrbl +++ b/pollen/scribblings/setup.scrbl @@ -1,6 +1,6 @@ #lang scribble/manual @(require "mb-tools.rkt") -@(require scribble/eval pollen/setup racket/string (for-label racket (except-in pollen #%module-begin) pollen/setup)) +@(require scribble/eval pollen/setup racket/string (for-label racket syntax/modresolve (except-in pollen #%module-begin) pollen/setup)) @(define my-eval (make-base-eval)) @(my-eval `(require pollen pollen/setup)) @@ -106,6 +106,21 @@ Default separators used in decoding. @defoverridable[compile-cache-max-size exact-positive-integer?]{Maximum size of the compile cache.} +@defoverridable[compile-cache-watchlist (listof (or/c path? path-string?))]{List of extra files that the compile cache watches during a project-server session. If one of the files on the watchlist changes, the compile cache is invalidated (just as it would be if @racket["pollen.rkt"] changed). + +If the compile cache can't find a certain file on the watchlist, it will be ignored. Therefore, to avoid unexpected behavior, the best policy is to pass in complete paths (or path strings). An easy way to convert a module name into a complete path is with @racket[resolve-module-path]: + +@fileblock["pollen.rkt" +@codeblock{ +(module+ setup + (require syntax/modresolve) + (provide (all-defined-out)) + (define compile-cache-watchlist (map resolve-module-path '("my-module.rkt")))) +}] + +} + + @defoverridable[publish-directory (or/c path-string? path-for-some-system?)]{Default target for @secref{raco_pollen_publish}. A complete path is used as is; a relative path is published to the desktop.. @pollen-history[#:added "1.1"]} @defoverridable[unpublished-path? (path? . -> . boolean?)]{@pollen-history[#:changed "1.1" @elem{Deprecated. Please use @racket[setup:omitted-path?].}]} @@ -133,6 +148,8 @@ Default separators used in decoding. @defoverridable[index-pages (listof string?)]{List of strings that the project server will use as directory default pages, in order of priority. Has no effect on command-line rendering operations. Also has no effect on your live web server (usually that's a setting you need to make in an @tt{.htaccess} configuration file).} But with this setting, you can simulate the behavior of your live server, so that internal index-page URLs work correctly. + + @section{Parameters} diff --git a/pollen/setup.rkt b/pollen/setup.rkt index d7f8859..9ac7220 100644 --- a/pollen/setup.rkt +++ b/pollen/setup.rkt @@ -46,6 +46,8 @@ (with-handlers ([exn:fail? NAME-FAIL-THUNKED]) (dynamic-require `(submod ,(apply get-path-to-override get-path-args) WORLD-SUBMOD) 'NAME NAME-FAIL-THUNKED))))))])) +(define-settable compile-cache-watchlist null) + (define-settable preproc-source-ext 'pp) (define-settable markup-source-ext 'pm) (define-settable markdown-source-ext 'pmd)