>From dfb447708945eaf409833abd91ef6fc61855b97f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= <daniel@turtleware.eu>
Date: Fri, 9 Sep 2016 07:31:46 +0200
Subject: [PATCH 2/9] bundle: component-depends-on: simplify hairy code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Create a local function inject-system, which verifies, if the system can
be found, and if not – makes a library system.

This part of code was also buggy, because if it did found `uiop', it
didn't include `asdf', but if none was found, it included `uiop' *and*
`asdf' unconditionally. This inconsistent behaviour was fixed and now we
try to inject `uiop', and if not found – `asdf'.
---
 bundle.lisp | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/bundle.lisp b/bundle.lisp
index 30be996..b8bea09 100644
--- a/bundle.lisp
+++ b/bundle.lisp
@@ -540,17 +540,16 @@ for all the linkable object files associated with the system or its dependencies
 
   (defmethod component-depends-on :around ((o image-op) (c system))
     (destructuring-bind ((lib-op . deps)) (call-next-method)
-      (flet ((has-it-p (x) (find x deps :test 'equal :key 'coerce-name)))
+      (labels ((has-it-p (x) (find x deps :test 'equal :key 'coerce-name))
+               (inject-system (x) (unless (has-it-p x)
+                                    (if (system-source-directory x)
+                                        `(,(find-system x))
+                                        `(,(make-library-system x))))))
         `((,lib-op
-           ,@(unless (or (no-uiop c) (has-it-p "cmp"))
-               `(,(make-library-system "cmp")))
-           ,@(unless (or (no-uiop c) (has-it-p "uiop") (has-it-p "asdf"))
-               (cond
-                 ((system-source-directory :uiop) `(,(find-system :uiop)))
-                 ((system-source-directory :asdf) `(,(find-system :asdf)))
-                 (t `(,@(if-let (uiop (system-module-pathname "uiop"))
-                          `(,(make-library-system "uiop" uiop)))
-                      ,(make-library-system "asdf")))))
+           ,@(unless (no-uiop c)
+               (append (inject-system "cmp")
+                       (or (inject-system "uiop")
+                           (inject-system "asdf"))))
            ,@deps)))))
 
   (defmethod perform ((o link-op) (c system))
-- 
2.9.3

