|
|
@ -18,6 +18,10 @@
|
|
|
|
;; between development sessions (prob a worthless optimization)
|
|
|
|
;; between development sessions (prob a worthless optimization)
|
|
|
|
(define mod-dates (make-hash))
|
|
|
|
(define mod-dates (make-hash))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (make-mod-dates-key paths)
|
|
|
|
|
|
|
|
((listof path?) . -> . (listof path?))
|
|
|
|
|
|
|
|
(define project-require-files (or (get-project-require-files) empty))
|
|
|
|
|
|
|
|
(flatten (append paths project-require-files)))
|
|
|
|
|
|
|
|
|
|
|
|
;; convert a path to a modification date value
|
|
|
|
;; convert a path to a modification date value
|
|
|
|
(define/contract (path->mod-date-value path)
|
|
|
|
(define/contract (path->mod-date-value path)
|
|
|
@ -36,11 +40,16 @@
|
|
|
|
;; therefore, use function by just listing out the paths
|
|
|
|
;; therefore, use function by just listing out the paths
|
|
|
|
(define/contract (store-refresh-in-mod-dates . rest-paths)
|
|
|
|
(define/contract (store-refresh-in-mod-dates . rest-paths)
|
|
|
|
(() #:rest (listof path?) . ->* . void?)
|
|
|
|
(() #:rest (listof path?) . ->* . void?)
|
|
|
|
(report (current-directory))
|
|
|
|
;; project require files are appended to the mod-date key.
|
|
|
|
;; todo next: make this work
|
|
|
|
;; Why? So a change in a require file will trigger a refresh
|
|
|
|
(let* ([project-require-files (or (get-project-require-files) empty)]
|
|
|
|
;; (which is the right thing to do, since pollen files are
|
|
|
|
[all-files-used-in-key (append rest-paths project-require-files)])
|
|
|
|
;; dependent on those requires)
|
|
|
|
(hash-set! mod-dates (report all-files-used-in-key) (map path->mod-date-value all-files-used-in-key))))
|
|
|
|
;; It's convenient for development, because otherwise
|
|
|
|
|
|
|
|
;; you'd need to restart the server when you change a require
|
|
|
|
|
|
|
|
;; or explicitly use the force parameter.
|
|
|
|
|
|
|
|
;; This way, require files and pollen files have the same behavior.
|
|
|
|
|
|
|
|
(define key (make-mod-dates-key rest-paths))
|
|
|
|
|
|
|
|
(hash-set! mod-dates key (map path->mod-date-value key)))
|
|
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
(module+ test
|
|
|
|
(reset-mod-dates)
|
|
|
|
(reset-mod-dates)
|
|
|
@ -65,8 +74,9 @@
|
|
|
|
;; use rest argument here so calling pattern matches store-refresh
|
|
|
|
;; use rest argument here so calling pattern matches store-refresh
|
|
|
|
(define/contract (mod-date-expired? . rest-paths)
|
|
|
|
(define/contract (mod-date-expired? . rest-paths)
|
|
|
|
(() #:rest (listof path?) . ->* . boolean?)
|
|
|
|
(() #:rest (listof path?) . ->* . boolean?)
|
|
|
|
(or (not (rest-paths . in? . mod-dates)) ; no stored mod date
|
|
|
|
(define key (make-mod-dates-key rest-paths))
|
|
|
|
(not (equal? (map path->mod-date-value rest-paths) (get mod-dates rest-paths))))) ; data has changed
|
|
|
|
(or (not (key . in? . mod-dates)) ; no stored mod date
|
|
|
|
|
|
|
|
(not (equal? (map path->mod-date-value key) (get mod-dates key))))) ; data has changed
|
|
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
(module+ test
|
|
|
|
(reset-mod-dates)
|
|
|
|
(reset-mod-dates)
|
|
|
@ -106,7 +116,7 @@
|
|
|
|
(regenerate-with-pmap pmap #:force force))]
|
|
|
|
(regenerate-with-pmap pmap #:force force))]
|
|
|
|
[(equal? FALLBACK_TEMPLATE_NAME (->string (file-name-from-path path)))
|
|
|
|
[(equal? FALLBACK_TEMPLATE_NAME (->string (file-name-from-path path)))
|
|
|
|
(message "Regenerate: using fallback template")]
|
|
|
|
(message "Regenerate: using fallback template")]
|
|
|
|
[(file-exists? path) (message "Regenerate: nothing to be done with" (->string (file-name-from-path path)))]
|
|
|
|
[(file-exists? path) 'pass-through]
|
|
|
|
[else (error "Regenerate couldn't find" (->string (file-name-from-path path)))])))
|
|
|
|
[else (error "Regenerate couldn't find" (->string (file-name-from-path path)))])))
|
|
|
|
(for-each ®enerate xs))
|
|
|
|
(for-each ®enerate xs))
|
|
|
|
|
|
|
|
|
|
|
@ -159,9 +169,9 @@
|
|
|
|
;; 2) output file doesn't exist (so it definitely won't appear in mod-dates)
|
|
|
|
;; 2) output file doesn't exist (so it definitely won't appear in mod-dates)
|
|
|
|
;; also, this is convenient for development:
|
|
|
|
;; also, this is convenient for development:
|
|
|
|
;; you can trigger a refresh just by deleting the file
|
|
|
|
;; you can trigger a refresh just by deleting the file
|
|
|
|
(not (file-exists? output-path))
|
|
|
|
(not (file-exists? output-path))
|
|
|
|
;; 3) file otherwise needs refresh (e.g., it changed)
|
|
|
|
;; 3) file otherwise needs refresh (e.g., it changed)
|
|
|
|
(mod-date-expired? source-path))
|
|
|
|
(mod-date-expired? source-path))
|
|
|
|
;; use single quotes to escape spaces in pathnames
|
|
|
|
;; use single quotes to escape spaces in pathnames
|
|
|
|
(let ([command (format "~a '~a' > '~a'" RACKET_PATH source-path output-path)])
|
|
|
|
(let ([command (format "~a '~a' > '~a'" RACKET_PATH source-path output-path)])
|
|
|
|
(regenerating-message (format "~a from ~a"
|
|
|
|
(regenerating-message (format "~a from ~a"
|
|
|
|