Commit f5973546 authored by Francois-Rene Rideau's avatar Francois-Rene Rideau

2.017.18: implement and document the :around-compile feature.

parent 32dfef21
......@@ -14,7 +14,7 @@
:licence "MIT"
:description "Another System Definition Facility"
:long-description "ASDF builds Common Lisp software organized into defined systems."
:version "2.017.17" ;; to be automatically updated by bin/bump-revision
:version "2.017.18" ;; 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.017.17: Another System Definition Facility.
;;; This is ASDF 2.017.18: Another System Definition Facility.
;;; Feedback, bug reports, and patches are all welcome:
;;; please mail to <>.
......@@ -115,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.017.17")
(asdf-version "2.017.18")
(existing-asdf (find-class 'component nil))
(existing-version *asdf-version*)
(already-there (equal asdf-version existing-version)))
......@@ -1175,6 +1175,7 @@ processed in order by OPERATE."))
(operation-times :initform (make-hash-table)
:accessor component-operation-times)
(around-compile :initarg :around-compile)
;; XXX we should provide some atomic interface for updating the
;; component properties
(properties :accessor component-properties :initarg :properties
......@@ -2249,6 +2250,22 @@ recursive calls to traverse.")
(defmethod perform :after ((operation operation) (c component))
(mark-operation-done operation c))
(defgeneric* call-with-around-compile-hook (component thunk))
(defgeneric* around-compile-hook (component))
(defmethod around-compile-hook ((c component))
((slot-boundp c 'around-compile)
(slot-value c 'around-compile))
((component-parent c)
(around-compile-hook (component-parent c)))))
(defmethod call-with-around-compile-hook ((c component) thunk)
(let ((hook (around-compile-hook c)))
(if hook
(funcall hook thunk)
(funcall thunk))))
(defvar *compile-op-compile-file-function* 'compile-file*
"Function used to compile lisp files.")
......@@ -2263,8 +2280,10 @@ recursive calls to traverse.")
(*compile-file-warnings-behaviour* (operation-on-warnings operation))
(*compile-file-failure-behaviour* (operation-on-failure operation)))
(multiple-value-bind (output warnings-p failure-p)
(apply *compile-op-compile-file-function* source-file
:output-file output-file (compile-op-flags operation))
c (lambda ()
(apply *compile-op-compile-file-function* source-file
:output-file output-file (compile-op-flags operation))))
(unless output
(error 'compile-error :component c :operation operation))
(when failure-p
......@@ -2825,7 +2825,36 @@ The valid values for these variables are
@chapter Miscellaneous additional functionality
ASDF includes several additional features that are generally
useful for system definition and development. These include:
useful for system definition and development.
@section Controlling file compilation
When declaring a component (system, module, file),
you can specify a keyword argument @code{:around-compile some-symbol}.
If left unspecified, the value will be inherited from the parent component if any,
or with a default of @code{nil} if no value is specified in any transitive parent.
The argument must be a either fbound symbol or @code{nil}.
@code{nil} means the normal compile-file function will be called.
A symbol means the function fbound to it will be called with a single argument,
a thunk that calls the compile-file function;
the function you specify must then funcall that thunk
inside whatever wrapping you want.
Using this hook, you may achieve such effects as:
locally renaming packages,
binding @var{*readtables*} and other syntax-controlling variables,
handling warnings and other conditions,
proclaiming consistent optimization settings,
saving code coverage information,
maintaining meta-data about compilation timings,
setting gensym counters and PRNG seeds and other sources of non-determinism,
overriding the source-location and/or timestamping systems,
checking that some compile-time side-effects were properly balanced,
@section Miscellaneous Exported Functions
@defun coerce-pathname name @&key type defaults
;;; -*- Lisp -*-
(in-package :asdf)
(defun call-in-base-2 (thunk)
(let ((*read-base* 2))
(funcall thunk)))
(defsystem test-around-compile
:around-compile call-in-base-2
:depends-on ((:version :asdf "2.017.18")) ; no :around-compile before that.
:components ((:file "test")))
;;; -*- Lisp -*-
(load "script-support.lisp")
(setf asdf:*central-registry* '(*default-pathname-defaults*))
(asdf:load-system 'test-around-compile :force t)
(assert (= 3 (add10 1)))) ;; add10 must have been compiled in base 2
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment