As a packaging issue, it seems we should choose one form or another.
While it makes sense for us to do it from the top level, simplifying
individual tool Makefiles, different users who download cedet may opt
to turn off parts, such as EDE or COGRE.
From a build perspective, having autoloads in the tools makes sense
for maintenance. (No need to build all of cedet when one semantic
file is updated.) From an install perspective, I don't think it
makes much difference.
If I understand rightly, your updated script can do both using the
same code. I guess the next question is which is the best plan of
action. If all tools are grouped under one CEDET package, I still
feel that individual autoload files is the best bet, though I could be
convinced otherwise.
I'll look into having EDE support the autoload generator. That way
the EDE compile command C-c . c can also get that work done.
Note: Perhaps we should make the -al.el extension a default. I think
emacs uses 'loaddefs.el' and 'custdefs.el'. The distinction between
semantic-al.el and a possibly renamed semantic-defs.el is that we
support more than just defun and defvar.
Eric
>>> David PONCE <david.ponce@...> seems to think that:
>Hi Eric,
>
>> That seems like a great idea. I'm not sure how that works out
>> individually though. Each tool may want to construct it's own
>> auto load file even though everything is grouped together. That way
>> when I run "make" in semantic, the semantic Makefile can update the
>> semantic autoloads w/out having to know about CEDET.
>[...]
>
>That's a good point. Here is a new version that should be more
>general.
>
>I split the function `cedet-hack-autoloads' into two new functions:
>
>- `cedet-update-autoloads', a command:
>
> "(cedet-update-autoloads LOADDEFS &optional DIRECTORY)
>
> Update autoloads in file LOADDEFS from sources.
> Optional argument DIRECTORY, specifies the directory to scan for
> autoloads. It defaults to the current directory.
> Also scan sub directories of DIRECTORY where exists a
> `cedet-autogen-tagfile' file."
>
>- `cedet-batch-update-autoloads', a batch function:
>
> "(cedet-batch-update-autoloads)
>
> Update autoloads in batch mode.
> Usage: emacs -batch -f cedet-batch-update-autoloads LOADDEFS [DIRECTORY]
> See the command `cedet-update-autoloads' for the meaning of the
> LOADDEFS and DIRECTORY arguments."
>
>Thus, it is now possible to update any autoloads file from any
>directory.
>
>For example, to update all CEDET's autoloads, one can use:
>
>emacs -batch -f cedet-batch-update-autoloads \
> <cedet-install-dir>/common/cedet-al.el \
> <cedet-install-dir>
>
>And to update only semantic autoloads, one can use:
>
>emacs -batch -f cedet-batch-update-autoloads \
> <cedet-install-dir>/semantic/semantic-al.el \
> <cedet-install-dir>/semantic
>
>What do you think?
>
>David
>
>;;; cedet-autogen.el --- Generate autoloads for CEDET libraries
>
>;; Copyright (C) 2003 David Ponce
>
>;; Author: David Ponce <david@...>
>;; Created: 22 Aug 2003
>;; Keywords: maint
>;; X-CVS: $Id$
>
>;; This file is not part of GNU Emacs.
>
>;; 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 2, or (at your option)
>;; any later version.
>
>;; This software 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 GNU Emacs; see the file COPYING. If not, write to the
>;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
>;; Boston, MA 02111-1307, USA.
>
>;;; Commentary:
>;;
>;; Automatically generate autoloads for CEDET libraries.
>;;
>
>;;; History:
>;;
>
>;;; Code:
>;;
>
>(require 'autoload)
>(eval-when-compile (require 'cl))
>
>;;; Compatibility
>(defun cedet-autogen-noninteractive ()
> "Return non-nil if running non-interactively."
> (if (featurep 'xemacs)
> (noninteractive)
> noninteractive))
>
>(if (fboundp 'keywordp)
> (defalias 'cedet-autogen-keywordp 'keywordp)
> (defun cedet-autogen-keywordp (object)
> "Return t if OBJECT is a keyword.
>This means that it is a symbol with a print name beginning with `:'
>interned in the initial obarray."
> (and (symbolp object)
> (char-equal ?: (aref 0 (symbol-name object)))))
> )
>=0C
>(when (cedet-autogen-noninteractive)
> ;; If the user is doing this non-interactively, we need to set up
> ;; these conveniences.
> (add-to-list 'load-path nil)
> (setq find-file-hooks nil
> find-file-suppress-same-file-warnings t)
> )
>
>(defadvice make-autoload (before cedet-make-autoload activate)
> "Extend `make-autoload' with support for particular CEDET forms.
>When a such form, like defclass, defmethod, etc., is recognized, it is
>replaced with side effect by an equivalent known form before calling
>the true `make-autoload' function."
> (if (consp (ad-get-arg 0))
> (let* ((form (ad-get-arg 0))
> (car (car-safe form))
> name args doc
> )
> (cond
> ((eq car 'define-overload)
> (setcar form 'defun)
> )
> ((eq car 'defmethod)
> (setq name (nth 1 form)
> args (nthcdr 2 form))
> (if (cedet-autogen-keywordp (car args))
> (setq args (cdr args)))
> (setq doc (nth 1 args)
> args (car args))
> (setcar form 'defun)
> (setcdr form (list name args (if (stringp doc) doc)))
> )
> ((eq car 'defclass)
> (setq name (nth 1 form)
> args (nth 2 form)
> doc (nth 4 form))
> (setcar form 'defun)
> (setcdr form (list name args (if (stringp doc) doc)))
> ))
> )))
>
>(defconst cedet-autogen-header
> "Auto-generated CEDET autoloads"
> "Header of the auto-generated autoloads file.")
>
>(defconst cedet-autogen-tagfile ".cedet-lisp"
> "Dummy file that indicates to scan this directory for autoloads.")
>
>(defun cedet-autogen-kill-xemacs-autoloads-feature ()
> "Remove Xemacs autoloads feature from this buffer."
> (save-excursion
> (goto-char (point-min))
> (while (re-search-forward "cedet-autoloads" nil t)
> (condition-case nil
> (while t (up-list -1))
> (error nil))
> (kill-region (point) (save-excursion (forward-list) (point)))
> )))
>
>(defun cedet-autogen-update-header ()
> "Update header of the auto-generated autoloads file.
>Run as `write-contents-hooks'."
> (when (string-equal generated-autoload-file (buffer-file-name))
> (let ((tag (format ";;; %s ---" (file-name-nondirectory
> (buffer-file-name)))))
> (message "Updating header...")
> (goto-char (point-min))
> (cond
> ;; Replace existing header line
> ((re-search-forward (concat "^" (regexp-quote tag)) nil t)
> (beginning-of-line)
> (kill-line 1)
> )
> ;; Insert header before first ^L encountered (XEmacs)
> ((re-search-forward "^=0C" nil t)
> (beginning-of-line)
> ))
> (insert tag " " cedet-autogen-header)
> (newline)
> (when (featurep 'xemacs)
> (cedet-autogen-kill-xemacs-autoloads-feature))
> (message "Updating header...done")
> nil ;; Say not already written.
> )))
>
>(defun cedet-autogen-subdirs (root-dir)
> "Return autoload candidate sub directories of ROOT-DIR.
>That is, those where a `cedet-autogen-tagfile' file is found.
>Return a list of directory names, relative to ROOT-DIR."
> (let (dirs)
> (dolist (dir (directory-files default-directory))
> (and (file-directory-p dir) (not (string-match dir "\\`..?\\'"))
> (let* ((default-directory (expand-file-name dir))
> (subdirs (cedet-autogen-subdirs root-dir)))
> (when (file-exists-p cedet-autogen-tagfile)
> (push (file-relative-name default-directory root-dir)
> subdirs))
> (setq dirs (nconc dirs subdirs)))))
> dirs))
>
>(defun cedet-update-autoloads (loaddefs &optional directory)
> "Update autoloads in file LOADDEFS from sources.
>Optional argument DIRECTORY, specifies the directory to scan for
>autoloads. It defaults to the current directory.
>Also scan sub directories of DIRECTORY where exists a
>`cedet-autogen-tagfile' file."
> (interactive "FLoaddefs file: \nDDirectory: ")
> (let* ((generated-autoload-file (expand-file-name loaddefs))
> (default-directory
> (file-name-as-directory
> (expand-file-name (or directory default-directory))))
> (subdirs (cedet-autogen-subdirs default-directory))
> (write-contents-hooks '(cedet-autogen-update-header))
> (command-line-args-left (cons default-directory subdirs))
> )
> ;; If file don't exist, and is not automatically created...
> (unless (or (file-exists-p generated-autoload-file)
> (fboundp 'autoload-ensure-default-file))
> ;; Create a file buffer.
> (find-file generated-autoload-file)
> ;; Use Unix EOLs, so that the file is portable to all platforms.
> (setq buffer-file-coding-system 'raw-text-unix)
> ;; Insert the header so that the buffer is not empty.
> (cedet-autogen-update-header))
> (batch-update-autoloads)))
>
>(defun cedet-batch-update-autoloads ()
> "Update autoloads in batch mode.
>Usage: emacs -batch -f cedet-batch-update-autoloads LOADDEFS [DIRECTORY]
>See the command `cedet-update-autoloads' for the meaning of the
>LOADDEFS and DIRECTORY arguments."
> (unless (cedet-autogen-noninteractive)
> (error "\
>`cedet-batch-update-autoloads' is to be used only with -batch"))
> (condition-case nil
> (apply 'cedet-update-autoloads command-line-args-left)
> (error
> (error "\
>Usage: emacs -batch -f cedet-batch-update-autoloads LOADDEFS [DIRECTORY]"))
> ))
>
>(provide 'cedet-autogen)
>
>;;; cedet-autogen.el ends here
>
|