Commit e306a7ef authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

More tweaking of encodings, based on excellent discussion with Orivej Desh.

Minimal documentation.
parent a1c0827b
......@@ -14,7 +14,7 @@
:licence "MIT"
:description "Another System Definition Facility"
:long-description "ASDF builds Common Lisp software organized into defined systems."
:version "2.20.6" ;; to be automatically updated by bin/bump-revision
:version "2.20.7" ;; to be automatically updated by bin/bump-revision
:depends-on ()
((:file "asdf")
;;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp -*-
;;; This is ASDF 2.20.6: Another System Definition Facility.
;;; This is ASDF 2.20.7: Another System Definition Facility.
;;; Feedback, bug reports, and patches are all welcome:
;;; please mail to <>.
......@@ -70,6 +70,9 @@
(and (= system::*gcl-major-version* 2)
(< system::*gcl-minor-version* 7)))
(pushnew :gcl-pre2.7 *features*))
#+(or abcl (and allegro ics) (and clisp unicode) clozure (and cmu unicode)
(and ecl unicode) lispworks (and sbcl sb-unicode) scl)
(pushnew :asdf-unicode *features*)
;;; make package if it doesn't exist yet.
;;; DEFPACKAGE may cause errors on discrepancies, so we avoid it.
(unless (find-package :asdf)
......@@ -112,7 +115,7 @@
;; "2.345.6" would be a development version in the official upstream
;; "2.345.0.7" would be your seventh local modification of official release 2.345
;; "2.345.6.7" would be your seventh local modification of development version 2.345.6
(asdf-version "2.20.6")
(asdf-version "2.20.7")
(existing-asdf (find-class 'component nil))
(existing-version *asdf-version*)
(already-there (equal asdf-version existing-version)))
......@@ -955,9 +958,9 @@ another pathname in a degenerate way."))
(defgeneric* (setf component-property) (new-value component property))
(defgeneric* component-encoding (component))
(defgeneric* component-external-format (component))
(defgeneric* (setf component-encoding) (new-value component))
(defgeneric* component-encoding (component))
(eval-when (#-gcl :compile-toplevel :load-toplevel :execute)
(defgeneric* (setf module-components-by-name) (new-value module)))
......@@ -1293,11 +1296,9 @@ processed in order by OPERATE."))
(defparameter *utf-8-external-format*
(progn ;; (or ... :default) triggers a warning on acl. Sigh.
#+(or abcl (and allegro ics) clozure (and cmu unicode)
(and ecl unicode) lispworks (and sbcl sb-unicode) scl) :utf-8
#+(and clisp unicode) charset:utf-8)
#+(and asdf-unicode (not clisp)) :utf-8
#+(and asdf-unicode clisp) charset:utf-8
#-asdf-unicode :default
"Default :external-format argument to pass to CL:OPEN and also
CL:LOAD or CL:COMPILE-FILE to best process a UTF-8 encoded file.
On modern implementations, this will decode UTF-8 code points as CL characters.
......@@ -1311,22 +1312,25 @@ hopefully, if done consistently, it won't affect program behavior too much.")
(component-encoding it)
(defmethod (setf component-encoding) (new-value (c component))
(setf (%component-encoding c) new-value))
(defun default-encoding-external-format-hook (encoding)
(unless (eq encoding :utf-8)
(warn (compatfmt "~@<Your ASDF component is using encoding ~S but it isn't recognized. Your system should :defsystem-depends-on (:asdf-encodings). Falling back to UTF-8.~:>") encoding))
(defun default-encoding-external-format (encoding)
(case encoding
(:utf-8 *utf-8-external-format*)
(:default :default) ;; for backwards compatibility only. Usage discouraged.
(cerror "Continue using :external-format :default" (compatfmt "~@<Your ASDF component is using encoding ~S but it isn't recognized. Your system should :defsystem-depends-on (:asdf-encodings).~:>") encoding)
(defvar *encoding-external-format-hook*
"Hook for an extension to define a mapping between non-default encodings
and implementation-defined external-format's")
(defun encoding-external-format (encoding)
(funcall *encoding-external-format-hook* encoding))
(defmethod component-external-format ((c component))
(encoding-external-format (component-encoding c)))
(defclass proto-system () ; slots to keep when resetting a system
;; To preserve identity for all objects, we'd need keep the components slots
;; but also to modify parse-component-form to reset the recycled objects.
......@@ -2393,7 +2397,6 @@ recursive calls to traverse.")
(defmethod perform ((operation compile-op) (c cl-source-file))
(let ((source-file (component-pathname c))
(external-format (encoding-external-format (component-encoding c)))
;; on some implementations, there are more than one output-file,
;; but the first one should always be the primary fasl that gets loaded.
(output-file (first (output-files operation c)))
......@@ -2404,7 +2407,7 @@ recursive calls to traverse.")
c #'(lambda ()
(apply *compile-op-compile-file-function* source-file
:output-file output-file
:external-format external-format
:external-format (component-external-format c)
(compile-op-flags operation))))
(unless output
(error 'compile-error :component c :operation operation))
......@@ -2509,11 +2512,10 @@ recursive calls to traverse.")
(defmethod perform ((o load-source-op) (c cl-source-file))
(declare (ignorable o))
(let ((source (component-pathname c))
(external-format (encoding-external-format (component-encoding c))))
(let ((source (component-pathname c)))
(setf (component-property c 'last-loaded-as-source)
(and (call-with-around-compile-hook
c #'(lambda () (load source :external-format external-format)))
c #'(lambda () (load source :external-format (component-external-format c))))
(defmethod perform ((operation load-source-op) (c static-file))
......@@ -222,7 +222,8 @@ the following implementations provide ASDF 2 this way:
abcl allegro ccl clisp cmucl ecl sbcl xcl.
The following implementations don't provide it yet but will in a future release:
lispworks scl.
The following implementations are obsolete and most probably will never bundle it:
The following implementations are obsolete, not actively maintained,
and most probably will never bundle it:
cormancl gcl genera mcl.
If the implementation you are using doesn't provide ASDF 2,
......@@ -2904,6 +2905,69 @@ overriding the source-location and/or timestamping systems,
checking that some compile-time side-effects were properly balanced,
Note that there is no around-load hook. This is on purpose.
Some implementations such as ECL or GCL link object files,
which allows for no such hook.
Other implementations allow for concatenating FASL files,
which doesn't allow for such a hook either.
We aim to discourage something that's not portable,
and has some dubious impact on performance and semantics
even when it is possible.
Things you might want to do with an around-load hook
are better done around-compile,
though it may at times require some creativity
(see e.g. the @code{package-renaming} system).
@section Controlling source file character encoding
Starting with ASDF 2.21, components accept a @code{:encoding} option.
By default, only @code{:utf-8} is accepted, and
utf-8 is assumed for all source code processed by ASDF.
Source code that only use the ASCII subset is of course
directly supported without modification.
Source code that uses more than the ASCII character set
wasn't portably supported previously, although in practice,
utf-8 worked everywhere and was backhandedly enforced by
a lot of people using SBCL and utf-8 and sending reports to authors
so they make their packages compatible.
This change therefore only formalizes a de facto standard,
and allows for extension and customization
where no such thing was previously possible.
On implementations that do not support unicode,
the @code{:default} external-format is used to read source files.
Non-ASCII characters intended to be read as one CL character
may end up being read as multiple CL characters on these implementations.
In most cases, this shouldn't affect the software's semantics:
comments will be skipped just the same, strings with be read and printed
with slightly different lengths, symbol names will be accordingly longer,
but none of it should matter.
But a few systems may fail to work properly, that actually depend
on unicode characters (for instance @code{lambda-reader}).
The @code{#+asdf-unicode} feature tells you if unicode was detected.
In the future, there will be a @code{asdf-encoding} extension system,
that will register support for more encodings using the
@code{*encoding-external-format-hook*} facility.
If you need such an extension already,
you may contact the authors of ASDF for support.
For backwards compatibility with users who insist on a non-UTF-8 encoding,
but cannot immediately transition to using @code{asdf-encoding}
(maybe because it isn't ready), the @code{:encoding :default} option
used in your @code{defsystem} form will restore
the behavior of ASDF 2.20 and earlier.
This shouldn't be required in libraries,
because user pressure as mentioned above will already have pushed
library authors towards using UTF-8;
but authors of end-user programs might care.
Finally, since this feature depends on ASDF 2.21,
you may want to wait for ASDF 2.21 or later being widely available
(hopefully later in 2012) before you start using this feature.
@section Miscellaneous Exported Functions
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment