Make it so that DrRacket deletes .zo files when the corresponding source file isn't present anymore
(when in the DrRAcket-compiles-my-zo-files mode)
This commit is contained in:
parent
5e51b7f335
commit
ede60de584
|
@ -540,7 +540,8 @@
|
||||||
(lambda (src)
|
(lambda (src)
|
||||||
(parameterize ([current-load/use-compiled
|
(parameterize ([current-load/use-compiled
|
||||||
(make-compilation-manager-load/use-compiled-handler/table
|
(make-compilation-manager-load/use-compiled-handler/table
|
||||||
cache)])
|
cache
|
||||||
|
#f)])
|
||||||
(compile-root (car (use-compiled-file-paths))
|
(compile-root (car (use-compiled-file-paths))
|
||||||
(path->complete-path src)
|
(path->complete-path src)
|
||||||
cache
|
cache
|
||||||
|
@ -548,10 +549,10 @@
|
||||||
#f)
|
#f)
|
||||||
(void)))))
|
(void)))))
|
||||||
|
|
||||||
(define (make-compilation-manager-load/use-compiled-handler)
|
(define (make-compilation-manager-load/use-compiled-handler [delete-zos-when-rkt-file-does-not-exist? #f])
|
||||||
(make-compilation-manager-load/use-compiled-handler/table (make-hash)))
|
(make-compilation-manager-load/use-compiled-handler/table (make-hash) delete-zos-when-rkt-file-does-not-exist?))
|
||||||
|
|
||||||
(define (make-compilation-manager-load/use-compiled-handler/table cache)
|
(define (make-compilation-manager-load/use-compiled-handler/table cache delete-zos-when-rkt-file-does-not-exist?)
|
||||||
(let ([orig-eval (current-eval)]
|
(let ([orig-eval (current-eval)]
|
||||||
[orig-load (current-load)]
|
[orig-load (current-load)]
|
||||||
[orig-registry (namespace-module-registry (current-namespace))]
|
[orig-registry (namespace-module-registry (current-namespace))]
|
||||||
|
@ -564,7 +565,13 @@
|
||||||
(let ([p2 (rkt->ss path)])
|
(let ([p2 (rkt->ss path)])
|
||||||
(and (not (eq? path p2))
|
(and (not (eq? path p2))
|
||||||
(file-exists? p2)))))
|
(file-exists? p2)))))
|
||||||
(trace-printf "skipping: ~a file does not exist" path)]
|
(trace-printf "skipping: ~a file does not exist" path)
|
||||||
|
(when delete-zos-when-rkt-file-does-not-exist?
|
||||||
|
(unless (null? modes)
|
||||||
|
(define to-delete (path-add-suffix (get-compilation-path (car modes) path) #".zo"))
|
||||||
|
(when (file-exists? to-delete)
|
||||||
|
(trace-printf "deleting: ~s" to-delete)
|
||||||
|
(delete-file to-delete))))]
|
||||||
[(or (null? (use-compiled-file-paths))
|
[(or (null? (use-compiled-file-paths))
|
||||||
(not (equal? (car modes)
|
(not (equal? (car modes)
|
||||||
(car (use-compiled-file-paths)))))
|
(car (use-compiled-file-paths)))))
|
||||||
|
|
|
@ -247,7 +247,7 @@
|
||||||
(cons (build-path "compiled" "drracket" "errortrace")
|
(cons (build-path "compiled" "drracket" "errortrace")
|
||||||
(use-compiled-file-paths)))]))
|
(use-compiled-file-paths)))]))
|
||||||
|
|
||||||
(current-load/use-compiled (make-compilation-manager-load/use-compiled-handler))
|
(current-load/use-compiled (make-compilation-manager-load/use-compiled-handler #t))
|
||||||
(let* ([cd (find-system-path 'collects-dir)]
|
(let* ([cd (find-system-path 'collects-dir)]
|
||||||
[no-dirs (list (CACHE-DIR)
|
[no-dirs (list (CACHE-DIR)
|
||||||
(if (relative-path? cd)
|
(if (relative-path? cd)
|
||||||
|
|
|
@ -117,7 +117,8 @@ and files as @exec{raco make}, so the two tools can be used together.
|
||||||
implements the compilation and dependency management used by
|
implements the compilation and dependency management used by
|
||||||
@exec{raco make} and @exec{raco setup}.}
|
@exec{raco make} and @exec{raco setup}.}
|
||||||
|
|
||||||
@defproc[(make-compilation-manager-load/use-compiled-handler)
|
@defproc[(make-compilation-manager-load/use-compiled-handler
|
||||||
|
[delete-zos-when-rkt-file-does-not-exist? any/c #f])
|
||||||
(path? (or/c symbol? false/c) . -> . any)]{
|
(path? (or/c symbol? false/c) . -> . any)]{
|
||||||
|
|
||||||
Returns a procedure suitable as a value for the
|
Returns a procedure suitable as a value for the
|
||||||
|
@ -200,6 +201,10 @@ If @racket[use-compiled-file-paths] contains an empty list when
|
||||||
@racket[make-compilation-manager-load/use-compiled-handler] is called,
|
@racket[make-compilation-manager-load/use-compiled-handler] is called,
|
||||||
then @racket[exn:fail:contract] exception is raised.
|
then @racket[exn:fail:contract] exception is raised.
|
||||||
|
|
||||||
|
If the @racket[delete-zos-when-rkt-file-does-not-exist?] argument is a true
|
||||||
|
value, then the returned handler will delete @filepath{.zo} files
|
||||||
|
when there is no corresponding original source file.
|
||||||
|
|
||||||
@emph{Do not} install the result of
|
@emph{Do not} install the result of
|
||||||
@racket[make-compilation-manager-load/use-compiled-handler] when the
|
@racket[make-compilation-manager-load/use-compiled-handler] when the
|
||||||
current namespace contains already-loaded versions of modules that may
|
current namespace contains already-loaded versions of modules that may
|
||||||
|
|
Loading…
Reference in New Issue
Block a user