Update CEDET from upstream.
[bpt/emacs.git] / lisp / cedet / ede / proj.el
index 40e6165..8d81b82 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ede/proj.el --- EDE Generic Project file driver
 
-;; Copyright (C) 1998-2003, 2007-2011  Free Software Foundation, Inc.
+;; Copyright (C) 1998-2003, 2007-2012  Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: project, make
 (autoload 'ede-proj-target-makefile-info "ede/proj-info"
   "Target class for info files." nil nil)
 
+(eieio-defclass-autoload 'ede-proj-target-aux '(ede-proj-target)
+  "ede/proj-aux"
+  "Target class for a group of lisp files.")
+(eieio-defclass-autoload 'ede-proj-target-elisp '(ede-proj-target-makefile)
+  "ede/proj-elisp"
+  "Target class for a group of lisp files.")
+(eieio-defclass-autoload 'ede-proj-target-elisp-autoloads '(ede-proj-target-elisp)
+  "ede/proj-elisp"
+  "Target class for generating autoload files.")
+(eieio-defclass-autoload 'ede-proj-target-scheme '(ede-proj-target)
+  "ede/proj-scheme"
+  "Target class for a group of lisp files.")
+(eieio-defclass-autoload 'ede-proj-target-makefile-miscelaneous '(ede-proj-target-makefile)
+  "ede/proj-misc"
+  "Target class for a group of miscellaneous w/ a special makefile.")
+(eieio-defclass-autoload 'ede-proj-target-makefile-program '(ede-proj-target-makefile-objectcode)
+  "ede/proj-prog"
+  "Target class for building a program.")
+(eieio-defclass-autoload 'ede-proj-target-makefile-archive '(ede-proj-target-makefile-objectcode)
+  "ede/proj-archive"
+  "Target class for building an archive of object code.")
+(eieio-defclass-autoload 'ede-proj-target-makefile-shared-object '(ede-proj-target-makefile-program)
+  "ede/proj-shared"
+  "Target class for building a shared object.")
+(eieio-defclass-autoload 'ede-proj-target-makefile-info '(ede-proj-target-makefile)
+  "ede/proj-info"
+  "Target class for info files.")
+
+;; Not in ede/ , but part of semantic.
+(eieio-defclass-autoload 'semantic-ede-proj-target-grammar '(ede-proj-target-elisp)
+  "semantic/ede-grammar"
+  "Target classfor Semantic grammar files.")
+
 ;;; Class Definitions:
 (defclass ede-proj-target (ede-target)
   ((auxsource :initarg :auxsource
@@ -181,8 +214,10 @@ This enables the creation of your target type."
       (setq ede-proj-target-alist
            (cons (cons name class) ede-proj-target-alist)))))
 
-(defclass ede-proj-project (ede-project)
-  ((makefile-type :initarg :makefile-type
+(defclass ede-proj-project (eieio-persistent ede-project)
+  ((extension :initform ".ede")
+   (file-header-line :initform ";; EDE Project Files are auto generated: Do Not Edit")
+   (makefile-type :initarg :makefile-type
                  :initform Makefile
                  :type symbol
                  :custom (choice (const Makefile)
@@ -259,23 +294,16 @@ If optional ROOTPROJ is provided then ROOTPROJ is the root project
 for the tree being read in.  If ROOTPROJ is nil, then assume that
 the PROJECT being read in is the root project."
   (save-excursion
-    (let ((ret nil)
+    (let ((ret (eieio-persistent-read (concat project "Project.ede")
+                                     ede-proj-project))
          (subdirs (directory-files project nil "[^.].*" nil)))
-      (set-buffer (get-buffer-create " *tmp proj read*"))
-      (unwind-protect
-         (progn
-           (insert-file-contents (concat project "Project.ede")
-                                 nil nil nil t)
-           (goto-char (point-min))
-           (setq ret (read (current-buffer)))
-           (if (not (eq (car ret) 'ede-proj-project))
-               (error "Corrupt project file"))
-           (setq ret (eval ret))
-           (oset ret file (concat project "Project.ede"))
-           (oset ret directory project)
-           (oset ret rootproject rootproj)
-           )
-       (kill-buffer " *tmp proj read*"))
+      (if (not (object-of-class-p ret 'ede-proj-project))
+         (error "Corrupt project file"))
+      (oset ret directory project)
+      (oset ret rootproject rootproj)
+
+      ;; Load the project file of each subdirectory containing a
+      ;; loadable Project.ede.
       (while subdirs
        (let ((sd (file-name-as-directory
                   (expand-file-name (car subdirs) project))))
@@ -291,22 +319,13 @@ the PROJECT being read in is the root project."
   "Write out object PROJECT into its file."
   (save-excursion
     (if (not project) (setq project (ede-current-project)))
-    (let ((b (set-buffer (get-buffer-create " *tmp proj write*")))
-         (cfn (oref project file))
-         (cdir (oref project directory)))
+    (let ((cdir (oref project directory)))
       (unwind-protect
-         (save-excursion
-           (erase-buffer)
-           (let ((standard-output (current-buffer)))
-             (oset project file (file-name-nondirectory cfn))
-             (slot-makeunbound project :directory)
-             (object-write project ";; EDE project file."))
-           (write-file cfn nil)
-           )
-       ;; Restore the :file on exit.
-       (oset project file cfn)
-       (oset project directory cdir)
-       (kill-buffer b)))))
+         (progn
+           (slot-makeunbound project :directory)
+           (eieio-persistent-save project))
+       ;; Restore the directory slot
+       (oset project directory cdir))) ))
 
 (defmethod ede-commit-local-variables ((proj ede-proj-project))
   "Commit change to local variables in PROJ."
@@ -546,7 +565,7 @@ You may need to add support for this type of file."
                       (file-name-extension (car sources))
                     "")))
          ))
-      ;; Return the disovered compilers
+      ;; Return the discovered compilers.
       comp)))
 
 (defmethod ede-proj-linkers ((obj ede-proj-target))
@@ -580,11 +599,11 @@ Converts all symbols into the objects to be used."
            (while (and avail (not (eieio-instance-inheritor-slot-boundp (car avail) 'sourcetype)))
              (setq avail (cdr avail)))
            (setq link (cdr avail)))))
-      ;; Return the disovered linkers
+      ;; Return the discovered linkers.
       link)))
 
 \f
-;;; Target type specific autogenerating gobbldegook.
+;;; Target type specific autogenerating gobbledygook.
 ;;
 
 (defun ede-proj-makefile-type (&optional proj)
@@ -642,7 +661,7 @@ MFILENAME is the makefile to generate."
 (defmethod ede-proj-setup-buildenvironment ((this ede-proj-project)
                                            &optional force)
   "Setup the build environment for project THIS.
-Handles the Makefile, or a Makefile.am configure.in combination.
+Handles the Makefile, or a Makefile.am configure.ac combination.
 Optional argument FORCE will force items to be regenerated."
   (if (not force)
       (ede-proj-makefile-create-maybe this (ede-proj-dist-makefile this))
@@ -670,6 +689,8 @@ Optional argument FORCE will force items to be regenerated."
   (let ((root (or (ede-project-root this) this))
        )
     (setq ede-projects (delq root ede-projects))
+    ;; NOTE : parent function double-checks that this dir was
+    ;; already in memory once.
     (ede-load-project-file (ede-project-root-directory root))
     ))