summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-12-03 15:24:51 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-12-03 16:13:57 +0000
commit50dce3c4225384cc3705bee4f8e55939f0885f73 (patch)
treed8cc4053a89e803b3ff6e6b8f0694abb019c1f06
parent67c6906a5f2e79ef771a1d7c8abeb29eb633c659 (diff)
downloademacs-50dce3c4225384cc3705bee4f8e55939f0885f73.tar.gz
* 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.
-rw-r--r--lisp/emacs-lisp/package.el11
-rw-r--r--test/automated/data/package/macro-problem-package-1.0/macro-aux.el31
-rw-r--r--test/automated/data/package/macro-problem-package-1.0/macro-problem.el40
-rw-r--r--test/automated/data/package/macro-problem-package-2.0/macro-aux.el35
-rw-r--r--test/automated/data/package/macro-problem-package-2.0/macro-problem.el49
-rw-r--r--test/automated/package-test.el14
6 files changed, 177 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index f94e7aaa741..6b5a2024958 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 00000000000..9d14a211639
--- /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 <emacs@endlessparentheses.com>
+
+;; 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 00000000000..a44074c4f87
--- /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 <emacs@endlessparentheses.com>
+;; 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 00000000000..4785cd78031
--- /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 <emacs@endlessparentheses.com>
+
+;; 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 00000000000..ead3d29dc3d
--- /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 <emacs@endlessparentheses.com>
+;; 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 de41c3bc8e4..8401d1879ae 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 ()