branch: elpa-admin commit dcc3222a50a5423ec43d716cb708a1b0656d2101 Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
Fix various problems when compiling packages in place * GNUmakefile (packages/%-autoloads.el): Move the code to `elpa.admin.el`. ($(PKG_DESCS_MK)): Recompute when the `packages` dir is modified. (packages): New target. (FILE-files): Remove unused function. (TRACE): New function. (FILE-deps): Don't include PKG-pkg.el and PKG-autoloads.el when the directory doesn't exist yet. * elpa-admin.el (elpaa--get-package-spec): Clean up error message. (elpaa-batch-pkg-spec-make-dependencies): Only include dependencies for packages currently deployed. (elpaa-batch-generate-autoloads): New function. --- GNUmakefile | 66 +++++++++++++---------------------------------------------- README | 4 ++++ elpa-admin.el | 59 +++++++++++++++++++++++++++++++++------------------- 3 files changed, 56 insertions(+), 73 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 291b0ec..3059222 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -83,14 +83,10 @@ autoloads := $(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-autoloads.el) # packages/aggressive-indent/aggressive-indent-autoloads.el: \ # packages/names/names-autoloads.el -packages/%-autoloads.el: +packages/%-autoloads.el: elpa-packages @#echo 'Generating autoloads for $@' - @cd $(dir $@) && \ - $(EMACS) -l $(CURDIR)/admin/elpa-admin.el \ - --eval "(require 'package)" \ - --eval "(load (expand-file-name \"../names/names-autoloads.el\") t t)" \ - --eval "(package-generate-autoloads \"$$(basename $$(pwd))\" \ - \"$$(pwd)\")" + $(EMACS) -l admin/elpa-admin.el \ + -f elpaa-batch-generate-autoloads $@ # Put into elcs the set of elc files we need to keep up-to-date. # I.e. one for each .el file in each package root, except for the -pkg.el, @@ -134,9 +130,11 @@ packages/%.elc: packages/%.el .PHONY: $(extra_elcs) # $(extra_elcs):; rm $@ +packages: + mkdir $@ include $(PKG_DESCS_MK) -$(PKG_DESCS_MK): elpa-packages +$(PKG_DESCS_MK): elpa-packages packages $(EMACS) -Q -l admin/elpa-admin.el \ -f elpaa-batch-pkg-spec-make-dependencies $@ @@ -153,23 +151,6 @@ packages/%-pkg.el: # Use order-only prerequisites, so that autoloads are done first. all-in-place: | $(autoloads) $(pkg_descs) $(pkgs) #$(extra_elcs) -# arg1 is the % of packages/%, returns the list of .el and .elc files -define FILE-files -$(if $(findstring /, $(1)), \ - $(if $(patsubst %.elc,,$(1)), \ - $(patsubst %.elc, %.el, $(1))), \ - $(shell [ -d packages/$(1) ] && { \ - echo packages/$(1)/$(1)-pkg.el; \ - echo packages/$(1)/$(1)-autoloads.el; \ - tar -cvhf /dev/null \ - --exclude-ignore=.elpaignore \ - --exclude='*-pkg.el' \ - --exclude='*-autoloads.el' \ - --exclude='.dir-locals.el' \ - --exclude-vcs packages/$(1) 2>&1 \ - | sed -ne 's/\(\.elc*\)$$/\1/p';})) -endef - define FILE-els $(filter %.el, $(1)) endef @@ -205,15 +186,20 @@ define FILE-computeddeps1 $(call FILE-computeddeps2, $(call FILE-els, $(1)), $(call FILE-elcs, $(1))) endef +define TRACE +$(info TRACE($(1)): $(2))$(2) +endef + # Compute the dependencies for a file packages/%. # The main case is for the `packages/[PKGNAME]` directory. # FIXME: Remove outdated .elc files with no matching .el file! define FILE-deps -$(if $(findstring /, $(1)), \ +$(if $(findstring /, $(1)), \ $(if $(patsubst %.elc,,$(1)), \ $(patsubst %.elc, %.el, $(1))), \ - packages/$(1)/$(1)-pkg.el \ - packages/$(1)/$(1)-autoloads.el \ + $(if $(wildcard packages/$(1)/*), \ + packages/$(1)/$(1)-pkg.el \ + packages/$(1)/$(1)-autoloads.el) \ $(call FILE-computeddeps1, \ $(shell [ -d packages/$(1) ] && { \ tar -cvhf /dev/null \ @@ -225,30 +211,6 @@ $(if $(findstring /, $(1)), \ | sed -ne 's/\(\.elc*\)$$/\1/p';}))) endef -# define FILE-cmd -# $(if $(findstring /, $(1)), \ -# $(if $(patsubst %.elc,,$(1)), \ -# $(EMACS) \ -# --eval "(setq package-directory-list nil \ -# load-prefer-newer t \ -# package-user-dir \"$(abspath packages)\")" \ -# -f package-initialize \ -# -L $(dir $@) -f batch-byte-compile $<, \ -# echo YUP: $(1)), \ -# [ -d packages/$(1) ] || \ -# $(EMACS) -l admin/elpa-admin.el \ -# -f elpaa-batch-archive-update-worktrees "$(@F)") -# endef - -# define EMACS-update-tree-cmd -# $(EMACS) -l admin/elpa-admin.el \ -# -f elpaa-batch-archive-update-worktrees "$(@F)" -# endef -# define EMACS-update-tree-cmd -# $(shell echo $(call EMACS-update-tree-cmd,$(1))) \ -# $(call EMACS-update-tree-cmd,$(1)) -# endef - .PHONY: dummy dummy: # # echo Making dummies diff --git a/README b/README index 1f5ddef..d8d1a76 100644 --- a/README +++ b/README @@ -111,6 +111,10 @@ Name of the documentation file for the package. It can be either an Info file, a Texinfo file, or an Org file. FILE can also be a list of those. +** =:lisp-dir= +Subdirectory in which the main ELisp found are found. +Defaults to the top-level directory. + ** =:make TARGET= Indicates that we should run ~make TARGET~ in order to build some files. This is run before processing =:doc=, so it can be used to generate diff --git a/elpa-admin.el b/elpa-admin.el index f9d0950..e56e4a7 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -446,7 +446,7 @@ Return non-nil if a new tarball was created." (let* ((specs (elpaa--get-specs)) (spec (assoc pkgname specs))) (if (null spec) - (error "Unknown package `%S`" pkgname) + (error "Unknown package %S" pkgname) spec))) (defun elpaa-batch-make-all-packages (&rest _) @@ -1652,27 +1652,44 @@ More at " (elpaa--default-url pkgname)) (let ((dst (pop command-line-args-left))) (with-temp-buffer (dolist (pkg-spec (elpaa--get-specs)) - (let ((pkgname (car pkg-spec))) - (insert - (format "packages/%s/%s-pkg.el: packages/%s/%s\n" - pkgname pkgname pkgname (elpaa--main-file pkg-spec))) - (let ((make-targets (elpaa--spec-get pkg-spec :make))) - (when (consp make-targets) - (dolist (target make-targets) - (insert (format "packages/%s: packages/%s/%s\n" - pkgname pkgname target)) - (insert (format "packages/%s/%s: -\tcd packages/%s; $(MAKE) %s\n" - pkgname target pkgname target))) - (insert (format "clean-submake/%s:\n\t$(RM) %s\n" - pkgname - (mapconcat (lambda (f) - (concat "packages/" pkgname "/" f)) - make-targets - " "))) - (insert (format "clean clean/%s: clean-submake/%s\n" - pkgname pkgname)))))) + (let* ((pkgname (car pkg-spec)) + (dir (concat "packages/" pkgname))) + (when (file-directory-p dir) + (insert + (format "%s/%s-pkg.el: %s/%s\n" + dir pkgname dir (elpaa--main-file pkg-spec))) + (let ((make-targets (elpaa--spec-get pkg-spec :make))) + (when (consp make-targets) + (dolist (target make-targets) + (insert (format "%s: %s/%s\n" dir dir target)) + (insert (format "%s/%s:\n\tcd %s; $(MAKE) %s\n" + dir target dir target))) + (insert (format "clean-submake/%s:\n\t$(RM) %s\n" + pkgname + (mapconcat (lambda (f) (concat dir "/" f)) + make-targets + " "))) + (insert (format "clean clean/%s: clean-submake/%s\n" + pkgname pkgname))))))) (write-region (point-min) (point-max) dst nil 'silent)))) +;; Generate autoloads for in-place use + +(defun elpaa-batch-generate-autoloads (&rest _) + (let* ((alf (pop command-line-args-left)) + (dir (file-name-directory alf)) + (pkgname (file-name-nondirectory (directory-file-name dir))) + (pkg-spec (elpaa--get-package-spec pkgname)) + (lisp-dir (elpaa--spec-get pkg-spec :lisp-dir))) + (require 'package) + (if (null lisp-dir) + (progn + (cl-assert (equal alf (concat dir pkgname "-autoloads.el"))) + (package-generate-autoloads pkgname dir)) + (package-generate-autoloads pkgname (concat dir lisp-dir)) + (write-region (format "(load (concat (file-name-directory #$) %S))\n" + (concat lisp-dir "/" pkgname "-autoloads.el")) + nil alf nil 'silent)))) + (provide 'elpa-admin) ;;; elpa-admin.el ends here