From 66e0b8508c825369b852b778a62931b107000e85 Mon Sep 17 00:00:00 2001
From: Francois-Rene Rideau <tunes@google.com>
Date: Mon, 1 Apr 2013 00:07:29 -0400
Subject: [PATCH] 2.32.36: debug and manually test binary-op after bug report
 by ehu.

---
 asdf.asd          |  2 +-
 bundle.lisp       | 73 +++++++++++++++++++++++++++--------------------
 header.lisp       |  2 +-
 upgrade.lisp      |  2 +-
 version.lisp-expr |  2 +-
 5 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/asdf.asd b/asdf.asd
index ad0fc3da..d16a3d16 100644
--- a/asdf.asd
+++ b/asdf.asd
@@ -74,7 +74,7 @@
   :licence "MIT"
   :description "Another System Definition Facility"
   :long-description "ASDF builds Common Lisp software organized into defined systems."
-  :version "2.32.35" ;; to be automatically updated by make bump-version
+  :version "2.32.36" ;; to be automatically updated by make bump-version
   :depends-on ()
   #+asdf3 :encoding #+asdf3 :utf-8
   ;; For most purposes, asdf itself specially counts as a builtin system.
diff --git a/bundle.lisp b/bundle.lisp
index 32392c11..568f894f 100644
--- a/bundle.lisp
+++ b/bundle.lisp
@@ -58,10 +58,9 @@
     ((bundle-type :initform :dll))
     (:documentation "Link together all the dynamic library used by this system into a single one."))
 
-  (defclass binary-op (bundle-op basic-compile-op selfward-operation)
-    ((selfward-operation :initform '(lib-op fasl-op)))
-    (:documentation #+(or ecl mkcl) "produce lib and fasl for the system."
-     #-(or ecl mkcl) "produce a fasl for the system"))
+  (defclass binary-op (basic-compile-op selfward-operation)
+    ((selfward-operation :initform '(fasl-op lib-op)))
+    (:documentation "produce fasl and asd files for the system"))
 
   (defclass monolithic-op (operation) ()) ;; operation on a system and its dependencies
 
@@ -73,17 +72,15 @@
     ()
     (:documentation "Abstract operation for ways to bundle the outputs of compiling *Lisp* files over all systems"))
 
-  (defclass monolithic-binary-op (monolithic-bundle-compile-op sideway-operation selfward-operation)
+  (defclass monolithic-binary-op (monolithic-op binary-op)
     ((selfward-operation :initform '(monolithic-fasl-op monolithic-lib-op)))
-    (:documentation
-     #+ecl "produce lib and fasl for combined system and dependencies."
-     #-ecl "produce an image file from system and dependencies (not implemented)."))
-     
+    (:documentation "produce fasl and asd files for combined system and dependencies."))
+
   (defclass monolithic-fasl-op (monolithic-bundle-compile-op basic-fasl-op) ()
     (:documentation "Create a single fasl for the system and its dependencies."))
 
   (defclass monolithic-lib-op (monolithic-bundle-compile-op basic-compile-op)
-    ((bundle-type :initform :lib))
+    ((bundle-type :initform #+(or ecl mkcl) :lib #-(or ecl mkcl) :no-output-file))
     (:documentation #+(or ecl mkcl) "Create a single linkable library for the system and its dependencies."
      #-(or ecl mkcl) "Compile a system and its dependencies."))
 
@@ -100,7 +97,7 @@
 
   (defun bundle-pathname-type (bundle-type)
     (etypecase bundle-type
-      ((eql :no-output-file) nil) ;; should we error out instead?    
+      ((eql :no-output-file) nil) ;; should we error out instead?
       ((or null string) bundle-type)
       ((eql :fasl) #-(or ecl mkcl) (compile-file-type) #+(or ecl mkcl) "fasb")
       #+ecl
@@ -125,15 +122,10 @@
     (bundle-output-files o c))
 
   #-(or ecl mkcl)
-  (progn
-    (defmethod perform ((o program-op) (c system))
-      (let ((output-file (output-file o c)))
-        (setf *image-entry-point* (ensure-function (component-entry-point c)))
-        (dump-image output-file :executable t)))
-
-    (defmethod perform ((o monolithic-binary-op) (c system))
-      (let ((output-file (output-file o c)))
-        (dump-image output-file))))
+  (defmethod perform ((o program-op) (c system))
+    (let ((output-file (output-file o c)))
+      (setf *image-entry-point* (ensure-function (component-entry-point c)))
+      (dump-image output-file :executable t)))
 
   (defclass compiled-file (file-component)
     ((type :initform #-(or ecl mkcl) (compile-file-type) #+(or ecl mkcl) "fasb")))
@@ -242,7 +234,8 @@
                      :when (funcall test f) :do (collect f))))))
 
   (defmethod input-files ((o bundle-compile-op) (c system))
-    (direct-dependency-files o c :test 'bundlable-file-p :key 'output-files))
+    (unless (eq (bundle-type o) :no-output-file)
+      (direct-dependency-files o c :test 'bundlable-file-p :key 'output-files)))
 
   (defun select-bundle-operation (type &optional monolithic)
     (ecase type
@@ -365,27 +358,45 @@
                          :defaults (component-pathname s))))
 
   (defmethod perform ((o binary-op) (s system))
-    (let* ((dependencies (component-depends-on o s))
-           (fasl (first (apply #'output-files (first dependencies))))
-           (library (first (apply #'output-files (second dependencies))))
+    (let* ((inputs (input-files o s))
+           (fasl (first inputs))
+           (library (second inputs))
            (asd (first (output-files o s)))
            (name (pathname-name asd))
-           (name-keyword (intern (string name) (find-package :keyword))))
+           (dependencies
+             (if (operation-monolithic-p o)
+                 (remove-if-not 'builtin-system-p
+                                (required-components s :component-type 'system
+                                                       :keep-operation 'load-op))
+                 (while-collecting (x) ;; resolve the sideway-dependencies of s
+                   (map-direct-dependencies
+                    'load-op s
+                    #'(lambda (o c)
+                        (when (and (typep o 'load-op) (typep c 'system))
+                          (x c)))))))
+           (depends-on (mapcar 'coerce-name dependencies)))
+      (when (pathname-equal asd (system-source-file s))
+        (cerror "overwrite the asd file"
+                "~/asdf-action:format-action/ is going to overwrite the system definition file ~S which is probably not what you want; you probably need to tweak your output translations."
+                (cons o s) asd))
       (with-open-file (s asd :direction :output :if-exists :supersede
                              :if-does-not-exist :create)
-        (format s ";;; Prebuilt ASDF definition for system ~A" name)
-        (format s ";;; Built for ~A ~A on a ~A/~A ~A"
+        (format s ";;; Prebuilt~:[~; monolithic~] ASDF definition for system ~A~%"
+                (operation-monolithic-p o) name)
+        (format s ";;; Built for ~A ~A on a ~A/~A ~A~%"
                 (lisp-implementation-type)
                 (lisp-implementation-version)
                 (software-type)
                 (machine-type)
                 (software-version))
-        (let ((*package* (find-package :keyword)))
-          (pprint `(defsystem ,name-keyword
+        (let ((*package* (find-package :asdf-user)))
+          (pprint `(defsystem ,name
                      :class prebuilt-system
+                     :depends-on ,depends-on
                      :components ((:compiled-file ,(pathname-name fasl)))
-                     :lib ,(and library (file-namestring library)))
-                  s)))))
+                     ,@(when library `(:lib ,(file-namestring library))))
+                  s)
+          (terpri s)))))
 
   #-(or ecl mkcl)
   (defmethod perform ((o bundle-compile-op) (c system))
diff --git a/header.lisp b/header.lisp
index 4d5c725f..3f2c8e20 100644
--- a/header.lisp
+++ b/header.lisp
@@ -1,5 +1,5 @@
 ;;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp -*-
-;;; This is ASDF 2.32.35: Another System Definition Facility.
+;;; This is ASDF 2.32.36: Another System Definition Facility.
 ;;;
 ;;; Feedback, bug reports, and patches are all welcome:
 ;;; please mail to <asdf-devel@common-lisp.net>.
diff --git a/upgrade.lisp b/upgrade.lisp
index f17a179d..6fdc0c2a 100644
--- a/upgrade.lisp
+++ b/upgrade.lisp
@@ -52,7 +52,7 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
          ;; "3.4.5.67" would be a development version in the official upstream of 3.4.5.
          ;; "3.4.5.0.8" would be your eighth local modification of official release 3.4.5
          ;; "3.4.5.67.8" would be your eighth local modification of development version 3.4.5.67
-         (asdf-version "2.32.35")
+         (asdf-version "2.32.36")
          (existing-version (asdf-version)))
     (setf *asdf-version* asdf-version)
     (when (and existing-version (not (equal asdf-version existing-version)))
diff --git a/version.lisp-expr b/version.lisp-expr
index 13be416e..a883aead 100644
--- a/version.lisp-expr
+++ b/version.lisp-expr
@@ -1 +1 @@
-"2.32.35"
+"2.32.36"
-- 
GitLab