From 847520da96836aaff641c4c82b87511fc65770c9 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 20 Mar 2021 14:03:34 -0700 Subject: add and export WITH-PRESERVE-HOSTATTRS Signed-off-by: Sean Whitton --- src/host.lisp | 8 ++++++++ src/package.lisp | 1 + src/propspec.lisp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/host.lisp b/src/host.lisp index 1eae634..b58c023 100644 --- a/src/host.lisp +++ b/src/host.lisp @@ -48,6 +48,14 @@ :hostattrs (copy-list (hostattrs host)) :propspec (host-propspec host))) +(defmacro with-preserve-hostattrs (&body forms) + "Evaluate FORMS then throw away any newly added hostattrs. +Useful in property combinators when you need to run some :HOSTATTRS +subroutines but ignore any new hostattrs they may push. Shouldn't be used in +properties." + `(let ((*host* (shallow-copy-host *host*))) + ,@forms)) + (defgeneric preprocess-host (host) (:documentation "Convert a host into a fresh preprocessed host if necessary, and diff --git a/src/package.lisp b/src/package.lisp index 1d1281e..2c802ad 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -132,6 +132,7 @@ #:make-child-host #:hostattrs #:preprocess-host + #:with-preserve-hostattrs ;; deployment.lisp #:defdeploy diff --git a/src/propspec.lisp b/src/propspec.lisp index 99eaa4f..67e8c18 100644 --- a/src/propspec.lisp +++ b/src/propspec.lisp @@ -343,7 +343,7 @@ apply the elements of REQUIREMENTS in reverse order." ;; run the :HOSTATTRS subroutine but throw away any ;; new hostattrs; when unapplying, the :HOSTATTRS ;; subroutine is only to check compatibility - (let ((*host* (shallow-copy-host *host*))) + (with-preserve-hostattrs (apply #'propattrs psym args))) :apply (get psym 'unapply) :unapply (get psym 'papply) -- cgit v1.2.3