|
@@ -44,6 +44,10 @@
|
|
|
(define default-warning-level (make-parameter 1 level-validator))
|
|
|
(define default-optimization-level (make-parameter 2 level-validator))
|
|
|
|
|
|
+;;; This parameter is used by `include' to locate the true source when
|
|
|
+;;; 'relative canonicalization strips a leading part of the source file.
|
|
|
+(define compilation-source-file-name (make-parameter #f))
|
|
|
+
|
|
|
;;;
|
|
|
;;; Compiler
|
|
|
;;;
|
|
@@ -175,25 +179,26 @@
|
|
|
(canonicalization 'relative))
|
|
|
(validate-options opts)
|
|
|
(with-fluids ((%file-port-name-canonicalization canonicalization))
|
|
|
- (let* ((comp (or output-file (compiled-file-name file)
|
|
|
- (error "failed to create path for auto-compiled file"
|
|
|
- file)))
|
|
|
- (in (open-input-file file))
|
|
|
- (enc (file-encoding in)))
|
|
|
- ;; Choose the input encoding deterministically.
|
|
|
- (set-port-encoding! in (or enc "UTF-8"))
|
|
|
-
|
|
|
- (ensure-directory (dirname comp))
|
|
|
- (call-with-output-file/atomic comp
|
|
|
- (lambda (port)
|
|
|
- ((language-printer (ensure-language to))
|
|
|
- (read-and-compile in #:env env #:from from #:to to
|
|
|
- #:optimization-level optimization-level
|
|
|
- #:warning-level warning-level
|
|
|
- #:opts (cons* #:to-file? #t opts))
|
|
|
- port))
|
|
|
- file)
|
|
|
- comp)))
|
|
|
+ (parameterize ((compilation-source-file-name file))
|
|
|
+ (let* ((comp (or output-file (compiled-file-name file)
|
|
|
+ (error "failed to create path for auto-compiled file"
|
|
|
+ file)))
|
|
|
+ (in (open-input-file file))
|
|
|
+ (enc (file-encoding in)))
|
|
|
+ ;; Choose the input encoding deterministically.
|
|
|
+ (set-port-encoding! in (or enc "UTF-8"))
|
|
|
+
|
|
|
+ (ensure-directory (dirname comp))
|
|
|
+ (call-with-output-file/atomic comp
|
|
|
+ (lambda (port)
|
|
|
+ ((language-printer (ensure-language to))
|
|
|
+ (read-and-compile in #:env env #:from from #:to to
|
|
|
+ #:optimization-level optimization-level
|
|
|
+ #:warning-level warning-level
|
|
|
+ #:opts (cons* #:to-file? #t opts))
|
|
|
+ port))
|
|
|
+ file)
|
|
|
+ comp))))
|
|
|
|
|
|
(define* (compile-and-load file #:key (from (current-language)) (to 'value)
|
|
|
(env (current-module))
|
|
@@ -203,11 +208,12 @@
|
|
|
(canonicalization 'relative))
|
|
|
(validate-options opts)
|
|
|
(with-fluids ((%file-port-name-canonicalization canonicalization))
|
|
|
- (read-and-compile (open-input-file file)
|
|
|
- #:from from #:to to #:opts opts
|
|
|
- #:optimization-level optimization-level
|
|
|
- #:warning-level warning-level
|
|
|
- #:env env)))
|
|
|
+ (parameterize ((compilation-source-file-name file))
|
|
|
+ (read-and-compile (open-input-file file)
|
|
|
+ #:from from #:to to #:opts opts
|
|
|
+ #:optimization-level optimization-level
|
|
|
+ #:warning-level warning-level
|
|
|
+ #:env env))))
|
|
|
|
|
|
|
|
|
;;;
|