emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 50dce3c 2/3: * lisp/emacs-lisp/package.el (packag


From: Artur Malabarba
Subject: [Emacs-diffs] emacs-25 50dce3c 2/3: * lisp/emacs-lisp/package.el (package-unpack): Load before compiling
Date: Thu, 03 Dec 2015 16:14:01 +0000

branch: emacs-25
commit 50dce3c4225384cc3705bee4f8e55939f0885f73
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    * lisp/emacs-lisp/package.el (package-unpack): Load before compiling
    
    Reload any previously loaded package files before compiling
    the package (also reload the same files after compiling).
    This ensures that we have the most recent definitions during
    compilation, and avoids generating bad elc files when a macro
    changes and it is used in a different file from the one it's
    defined in.
---
 lisp/emacs-lisp/package.el                         |   11 +++-
 .../package/macro-problem-package-1.0/macro-aux.el |   31 ++++++++++++
 .../macro-problem-package-1.0/macro-problem.el     |   40 ++++++++++++++++
 .../package/macro-problem-package-2.0/macro-aux.el |   35 ++++++++++++++
 .../macro-problem-package-2.0/macro-problem.el     |   49 ++++++++++++++++++++
 test/automated/package-test.el                     |   14 ++++++
 6 files changed, 177 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index f94e7aa..6b5a202 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -830,12 +830,17 @@ untar into a directory named DIR; otherwise, signal an 
error."
     ;; Update package-alist.
     (let ((new-desc (package-load-descriptor pkg-dir)))
       ;; FIXME: Check that `new-desc' matches `desc'!
+      ;; Activation has to be done before compilation, so that if we're
+      ;; upgrading and macros have changed we load the new definitions
+      ;; before compiling.
+      (package-activate-1 new-desc :reload :deps)
       ;; FIXME: Compilation should be done as a separate, optional, step.
       ;; E.g. for multi-package installs, we should first install all packages
       ;; and then compile them.
-      (package--compile new-desc))
-    ;; Try to activate it.
-    (package-activate name 'force)
+      (package--compile new-desc)
+      ;; After compilation, load again any files loaded by
+      ;; `activate-1', so that we use the byte-compiled definitions.
+      (package--load-files-for-activation new-desc :reload))
     pkg-dir))
 
 (defun package-generate-description-file (pkg-desc pkg-file)
diff --git a/test/automated/data/package/macro-problem-package-1.0/macro-aux.el 
b/test/automated/data/package/macro-problem-package-1.0/macro-aux.el
new file mode 100644
index 0000000..9d14a21
--- /dev/null
+++ b/test/automated/data/package/macro-problem-package-1.0/macro-aux.el
@@ -0,0 +1,31 @@
+;;; macro-aux.el --- laksd                                  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2015  Artur Malabarba
+
+;; Author: Artur Malabarba <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(defun macro-aux-1 ( &rest forms)
+  "Description"
+  `(progn ,@forms))
+
+(provide 'macro-aux)
+;;; macro-aux.el ends here
diff --git 
a/test/automated/data/package/macro-problem-package-1.0/macro-problem.el 
b/test/automated/data/package/macro-problem-package-1.0/macro-problem.el
new file mode 100644
index 0000000..a44074c
--- /dev/null
+++ b/test/automated/data/package/macro-problem-package-1.0/macro-problem.el
@@ -0,0 +1,40 @@
+;;; macro-problem.el --- laksd                                  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2015  Artur Malabarba
+
+;; Author: Artur Malabarba <address@hidden>
+;; Keywords: tools
+;; Version: 1.0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'macro-aux)
+
+(defmacro macro-problem-1 ( &rest forms)
+  "Description"
+  `(progn ,@forms))
+
+(defun macro-problem-func ()
+  ""
+  (macro-problem-1 'a 'b)
+  (macro-aux-1 'a 'b))
+
+(provide 'macro-problem)
+;;; macro-problem.el ends here
diff --git a/test/automated/data/package/macro-problem-package-2.0/macro-aux.el 
b/test/automated/data/package/macro-problem-package-2.0/macro-aux.el
new file mode 100644
index 0000000..4785cd7
--- /dev/null
+++ b/test/automated/data/package/macro-problem-package-2.0/macro-aux.el
@@ -0,0 +1,35 @@
+;;; macro-aux.el --- laksd                                  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2015  Artur Malabarba
+
+;; Author: Artur Malabarba <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(defmacro macro-aux-1 ( &rest forms)
+  "Description"
+  `(progn ,@forms))
+
+(defmacro macro-aux-3 ( &rest _)
+  "Description"
+  90)
+
+(provide 'macro-aux)
+;;; macro-aux.el ends here
diff --git 
a/test/automated/data/package/macro-problem-package-2.0/macro-problem.el 
b/test/automated/data/package/macro-problem-package-2.0/macro-problem.el
new file mode 100644
index 0000000..ead3d29
--- /dev/null
+++ b/test/automated/data/package/macro-problem-package-2.0/macro-problem.el
@@ -0,0 +1,49 @@
+;;; macro-problem.el --- laksd                                  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2015  Artur Malabarba
+
+;; Author: Artur Malabarba <address@hidden>
+;; Keywords: tools
+;; Version: 2.0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'macro-aux)
+
+(defmacro macro-problem-1 ( &rest forms)
+  "Description"
+  `(progn ,(cadr (car forms))))
+
+
+(defun macro-problem-func ()
+  ""
+  (list (macro-problem-1 '1 'b)
+        (macro-aux-1 'a 'b)))
+
+(defmacro macro-problem-3 (&rest _)
+  "Description"
+  10)
+
+(defun macro-problem-10-and-90 ()
+  ""
+  (list (macro-problem-3 haha) (macro-aux-3 hehe)))
+
+(provide 'macro-problem)
+;;; macro-problem.el ends here
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index de41c3b..8401d18 100644
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -242,6 +242,20 @@ Must called from within a `tar-mode' buffer."
     (should (package-installed-p 'simple-single))
     (should (package-installed-p 'simple-depend))))
 
+(ert-deftest package-test-macro-compilation ()
+  "Install a package which includes a dependency."
+  (with-package-test (:basedir "data/package")
+    (package-install-file (expand-file-name "macro-problem-package-1.0/"))
+    (require 'macro-problem)
+    ;; `macro-problem-func' uses a macro from `macro-aux'.
+    (should (equal (macro-problem-func) '(progn a b)))
+    (package-install-file (expand-file-name "macro-problem-package-2.0/"))
+    ;; After upgrading, `macro-problem-func' depends on a new version
+    ;; of the macro from `macro-aux'.
+    (should (equal (macro-problem-func) '(1 b)))
+    ;; `macro-problem-10-and-90' depends on an entirely new macro from 
`macro-aux'.
+    (should (equal (macro-problem-10-and-90) '(10 90)))))
+
 (ert-deftest package-test-install-two-dependencies ()
   "Install a package which includes a dependency."
   (with-package-test ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]