From 2fe53854308bac14c2d3d32db1791b1a1b6b85a3 Mon Sep 17 00:00:00 2001 From: zappo Date: Thu, 1 Oct 2009 00:30:30 +0000 Subject: [PATCH] (ede-proj-target-elisp): Add pre-load-packages slot. (ede-emacs-preload-compiler): New. (ede-proj-makefile-insert-preload-items): New. (ede-proj-target-elisp::ede-proj-makefile-insert-variables): Create ELISPPRELOAD variable. --- ede/ede-proj-elisp.el | 52 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/ede/ede-proj-elisp.el b/ede/ede-proj-elisp.el index 78ce6885b..75b5e51ad 100755 --- a/ede/ede-proj-elisp.el +++ b/ede/ede-proj-elisp.el @@ -4,7 +4,7 @@ ;; Author: Eric M. Ludlam ;; Keywords: project, make -;; RCS: $Id: ede-proj-elisp.el,v 1.38 2009/08/08 21:43:19 zappo Exp $ +;; RCS: $Id: ede-proj-elisp.el,v 1.39 2009/10/01 00:30:30 zappo Exp $ ;; This software is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -35,7 +35,9 @@ (keybindings :initform nil) (phony :initform t) (sourcetype :initform (ede-source-emacs)) - (availablecompilers :initform (ede-emacs-compiler ede-xemacs-compiler)) + (availablecompilers :initform (ede-emacs-compiler + ede-xemacs-compiler + ede-emacs-preload-compiler)) (aux-packages :initarg :aux-packages :initform nil :type list @@ -44,7 +46,15 @@ There should only be one toplevel package per auxiliary tool needed. These packages location is found, and added to the compile time load path." - )) + ) + (pre-load-packages :initarg :pre-load-packages + :initform nil + :type list + :custom (repeat string) + :documentation "Additional packages to pre-load. +Each package name will be loaded with `require'. +Each package's directory should also appear in :aux-packages via a package name.") + ) "This target consists of a group of lisp files. A lisp target may be one general program with many separate lisp files in it.") @@ -75,6 +85,23 @@ A lisp target may be one general program with many separate lisp files in it.") ) "Compile Emacs Lisp programs.") +(defvar ede-emacs-preload-compiler + (clone + ede-emacs-compiler "ede-emacs-preload-compiler" + :commands + '("@echo \"(add-to-list 'load-path nil)\" > $@-compile-script" + "for loadpath in . ${LOADPATH}; do \\" + " echo \"(add-to-list 'load-path \\\"$$loadpath\\\")\" >> $@-compile-script; \\" + "done;" + "for preload in ${ELISPPRELOAD}; do \\" + " echo \"(load \\\"$$preload\\\")\" >> $@-compile-script; \\" + "done;" + "@echo \"(setq debug-on-error t)\" >> $@-compile-script" + "\"$(EMACS)\" $(EMACSFLAGS) -l $@-compile-script -f batch-byte-compile $^" + )) + "Compile Emacs Lisp programs with preload libraries.") + + (defvar ede-xemacs-compiler (clone ede-emacs-compiler "ede-xemacs-compiler" :name "xemacs" @@ -186,13 +213,30 @@ is found, such as a `-version' variable, or the standard header." (setq items (cdr items))))) )) +(defun ede-proj-makefile-insert-preload-items (items) + "Insert a sequence of ITEMS into the Makefile ELISPPRELOAD variable." + (when items + (ede-pmake-insert-variable-shared "ELISPPRELOAD" + (let ((begin (save-excursion (re-search-backward "\\s-*=")))) + (while items + (when (not (save-excursion + (re-search-backward + (concat "\\s-" (regexp-quote (car items)) "[ \n\t\\]") + begin t))) + (insert " " (car items))) + (setq items (cdr items))))) + )) + (defmethod ede-proj-makefile-insert-variables :AFTER ((this ede-proj-target-elisp)) "Insert variables needed by target THIS." (let ((newitems (if (oref this aux-packages) (ede-proj-elisp-packages-to-loadpath (oref this aux-packages)))) + (newpreload (oref this pre-load-packages)) ) - (ede-proj-makefile-insert-loadpath-items newitems))) + (ede-proj-makefile-insert-loadpath-items newitems) + (when newpreload + (ede-proj-makefile-insert-preload-items newpreload)))) (defun ede-proj-elisp-add-path (path) "Add path PATH into the file if it isn't already there."