]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/ede/proj.el
Update copyright year to 2016
[gnu-emacs] / lisp / cedet / ede / proj.el
index 40e6165251cba761078cac6f7e965e9ed515399b..d6f5210ec839ec7000fdc98867faa375aa358a4b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ede/proj.el --- EDE Generic Project file driver
 
-;; Copyright (C) 1998-2003, 2007-201 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2003, 2007-2016 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
@@ -71,6 +104,7 @@ distributed, and each should have a corresponding rule to build it.")
             :initform nil
             :type (or null symbol)
             :custom (choice (const :tag "None" nil)
+                            (symbol :tag "Custom Compiler Symbol")
                             :slotofchoices availablecompilers)
             :label "Compiler for building sources"
             :group make
@@ -83,6 +117,7 @@ of these compiler resources, and global customization thereof.")
             :initform nil
             :type (or null symbol)
             :custom (choice (const :tag "None" nil)
+                            (symbol :tag "Custom Linker Symbol")
                             :slotofchoices availablelinkers)
             :label "Linker for combining intermediate object files."
             :group make
@@ -127,12 +162,12 @@ These are the linkers the user can choose from when setting the
              :initform t
              :type boolean
              :custom boolean
-             :label "Part of `all:' target"
+             :label "Part of all: target"
              :group make
              :documentation
-             "Non nil means the rule created is part of the all target.
+             "Non nil means the rule created is part of the all: target.
 Setting this to nil creates the rule to build this item, but does not
-include it in the ALL`all:' rule.")
+include it in the all: rule.")
    (configuration-variables
     :initarg :configuration-variables
     :initform nil
@@ -181,8 +216,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,28 +296,21 @@ 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))))
          (if (and (file-directory-p sd)
-                  (ede-directory-project-p sd))
+                  (file-exists-p (expand-file-name "Project.ede" sd)))
              (oset ret subproj
                    (cons (ede-proj-load sd (or rootproj ret))
                          (oref ret subproj))))
@@ -291,44 +321,35 @@ 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)))))
-
-(defmethod ede-commit-local-variables ((proj ede-proj-project))
+         (progn
+           (slot-makeunbound project :directory)
+           (eieio-persistent-save project))
+       ;; Restore the directory slot
+       (oset project directory cdir))) ))
+
+(cl-defmethod ede-commit-local-variables ((proj ede-proj-project))
   "Commit change to local variables in PROJ."
   (ede-proj-save proj))
 
-(defmethod eieio-done-customizing ((proj ede-proj-project))
+(cl-defmethod eieio-done-customizing ((proj ede-proj-project))
   "Call this when a user finishes customizing this object.
 Argument PROJ is the project to save."
-  (call-next-method)
+  (cl-call-next-method)
   (ede-proj-save proj))
 
-(defmethod eieio-done-customizing ((target ede-proj-target))
+(cl-defmethod eieio-done-customizing ((target ede-proj-target))
   "Call this when a user finishes customizing this object.
 Argument TARGET is the project we are completing customization on."
-  (call-next-method)
+  (cl-call-next-method)
   (ede-proj-save (ede-current-project)))
 
-(defmethod ede-commit-project ((proj ede-proj-project))
+(cl-defmethod ede-commit-project ((proj ede-proj-project))
   "Commit any change to PROJ to its file."
   (ede-proj-save proj))
 
-(defmethod ede-buffer-mine ((this ede-proj-project) buffer)
+(cl-defmethod ede-buffer-mine ((this ede-proj-project) buffer)
   "Return t if object THIS lays claim to the file in BUFFER."
   (let ((f (ede-convert-path this (buffer-file-name buffer))))
     (or (string= (file-name-nondirectory (oref this file)) f)
@@ -339,9 +360,9 @@ Argument TARGET is the project we are completing customization on."
        (member f '("AUTHORS" "NEWS" "COPYING" "INSTALL" "README"))
        )))
 
-(defmethod ede-buffer-mine ((this ede-proj-target) buffer)
+(cl-defmethod ede-buffer-mine ((this ede-proj-target) buffer)
   "Return t if object THIS lays claim to the file in BUFFER."
-  (or (call-next-method)
+  (or (cl-call-next-method)
       (ede-target-buffer-in-sourcelist this buffer (oref this auxsource))))
 
 \f
@@ -350,7 +371,7 @@ Argument TARGET is the project we are completing customization on."
 (defvar ede-proj-target-history nil
   "History when querying for a target type.")
 
-(defmethod project-new-target ((this ede-proj-project)
+(cl-defmethod project-new-target ((this ede-proj-project)
                               &optional name type autoadd)
   "Create a new target in THIS based on the current buffer."
   (let* ((name (or name (read-string "Name: " "")))
@@ -388,7 +409,7 @@ Argument TARGET is the project we are completing customization on."
     ;; And save
     (ede-proj-save this)))
 
-(defmethod project-new-target-custom ((this ede-proj-project))
+(cl-defmethod project-new-target-custom ((this ede-proj-project))
   "Create a new target in THIS for custom."
   (let* ((name (read-string "Name: " ""))
         (type (completing-read "Type: " ede-proj-target-alist
@@ -397,7 +418,7 @@ Argument TARGET is the project we are completing customization on."
             :path (ede-convert-path this default-directory)
             :source nil)))
 
-(defmethod project-delete-target ((this ede-proj-target))
+(cl-defmethod project-delete-target ((this ede-proj-target))
   "Delete the current target THIS from its parent project."
   (let ((p (ede-current-project))
        (ts (oref this source)))
@@ -418,7 +439,7 @@ Argument TARGET is the project we are completing customization on."
     (oset p targets (delq this (oref p targets)))
     (ede-proj-save (ede-current-project))))
 
-(defmethod project-add-file ((this ede-proj-target) file)
+(cl-defmethod project-add-file ((this ede-proj-target) file)
   "Add to target THIS the current buffer represented as FILE."
   (let ((file (ede-convert-path this file))
        (src (ede-target-sourcecode this)))
@@ -433,7 +454,7 @@ Argument TARGET is the project we are completing customization on."
            (t (error "`project-add-file(ede-target)' source mismatch error")))
       (ede-proj-save))))
 
-(defmethod project-remove-file ((target ede-proj-target) file)
+(cl-defmethod project-remove-file ((target ede-proj-target) file)
   "For TARGET, remove FILE.
 FILE must be massaged by `ede-convert-path'."
   ;; Speedy delete should be safe.
@@ -441,11 +462,11 @@ FILE must be massaged by `ede-convert-path'."
   (object-remove-from-list target 'auxsource (ede-convert-path target file))
   (ede-proj-save))
 
-(defmethod project-update-version ((this ede-proj-project))
+(cl-defmethod project-update-version ((this ede-proj-project))
   "The :version of project THIS has changed."
   (ede-proj-save))
 
-(defmethod project-make-dist ((this ede-proj-project))
+(cl-defmethod project-make-dist ((this ede-proj-project))
   "Build a distribution for the project based on THIS target."
   (let ((pm (ede-proj-dist-makefile this))
        (df (project-dist-files this)))
@@ -458,14 +479,14 @@ FILE must be massaged by `ede-convert-path'."
                                   (file-name-directory pm))))
     (compile (concat ede-make-command " -f " pm " dist"))))
 
-(defmethod project-dist-files ((this ede-proj-project))
+(cl-defmethod project-dist-files ((this ede-proj-project))
   "Return a list of files that constitutes a distribution of THIS project."
   (list
    ;; Note to self, keep this first for the above fn to check against.
    (concat (oref this name) "-" (oref this version) ".tar.gz")
    ))
 
-(defmethod project-compile-project ((proj ede-proj-project) &optional command)
+(cl-defmethod project-compile-project ((proj ede-proj-project) &optional command)
   "Compile the entire current project PROJ.
 Argument COMMAND is the command to use when compiling."
   (let ((pm (ede-proj-dist-makefile proj))
@@ -478,12 +499,12 @@ Argument COMMAND is the command to use when compiling."
 
 ;;; Target type specific compilations/debug
 ;;
-(defmethod project-compile-target ((obj ede-proj-target) &optional command)
+(cl-defmethod project-compile-target ((obj ede-proj-target) &optional command)
   "Compile the current target OBJ.
 Argument COMMAND is the command to use for compiling the target."
   (project-compile-project (ede-current-project) command))
 
-(defmethod project-compile-target ((obj ede-proj-target-makefile)
+(cl-defmethod project-compile-target ((obj ede-proj-target-makefile)
                                   &optional command)
   "Compile the current target program OBJ.
 Optional argument COMMAND is the s the alternate command to use."
@@ -491,21 +512,21 @@ Optional argument COMMAND is the s the alternate command to use."
   (compile (concat ede-make-command " -f " (oref obj makefile) " "
                   (ede-proj-makefile-target-name obj))))
 
-(defmethod project-debug-target ((obj ede-proj-target))
+(cl-defmethod project-debug-target ((obj ede-proj-target))
   "Run the current project target OBJ in a debugger."
-  (error "Debug-target not supported by %s" (object-name obj)))
+  (error "Debug-target not supported by %s" (eieio-object-name obj)))
 
-(defmethod project-run-target ((obj ede-proj-target))
+(cl-defmethod project-run-target ((obj ede-proj-target))
   "Run the current project target OBJ."
-  (error "Run-target not supported by %s" (object-name obj)))
+  (error "Run-target not supported by %s" (eieio-object-name obj)))
 
-(defmethod ede-proj-makefile-target-name ((this ede-proj-target))
+(cl-defmethod ede-proj-makefile-target-name ((this ede-proj-target))
   "Return the name of the main target for THIS target."
   (ede-name this))
 \f
 ;;; Compiler and source code generators
 ;;
-(defmethod ede-want-file-auxiliary-p ((this ede-target) file)
+(cl-defmethod ede-want-file-auxiliary-p ((this ede-target) file)
   "Return non-nil if THIS target wants FILE."
   ;; By default, all targets reference the source object, and let it decide.
   (let ((src (ede-target-sourcecode this)))
@@ -513,7 +534,7 @@ Optional argument COMMAND is the s the alternate command to use."
       (setq src (cdr src)))
     src))
 
-(defmethod ede-proj-compilers ((obj ede-proj-target))
+(cl-defmethod ede-proj-compilers ((obj ede-proj-target))
   "List of compilers being used by OBJ.
 If the `compiler' slot is empty, concoct one on a first match found
 basis for any given type from the `availablecompilers' slot.
@@ -546,10 +567,10 @@ 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))
+(cl-defmethod ede-proj-linkers ((obj ede-proj-target))
   "List of linkers being used by OBJ.
 If the `linker' slot is empty, concoct one on a first match found
 basis for any given type from the `availablelinkers' slot.
@@ -580,11 +601,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)
@@ -603,7 +624,7 @@ Converts all symbols into the objects to be used."
   "Return non-nil if the current project PROJ is automake mode."
   (eq (ede-proj-makefile-type proj) 'Makefile))
 
-(defmethod ede-proj-dist-makefile ((this ede-proj-project))
+(cl-defmethod ede-proj-dist-makefile ((this ede-proj-project))
   "Return the name of the Makefile with the DIST target in it for THIS."
   (cond ((eq (oref this makefile-type) 'Makefile.am)
         (concat (file-name-directory (oref this file))
@@ -630,7 +651,7 @@ Converts all symbols into the objects to be used."
   (interactive)
   (ede-proj-setup-buildenvironment (ede-current-project) t))
 
-(defmethod ede-proj-makefile-create-maybe ((this ede-proj-project) mfilename)
+(cl-defmethod ede-proj-makefile-create-maybe ((this ede-proj-project) mfilename)
   "Create a Makefile for all Makefile targets in THIS if needed.
 MFILENAME is the makefile to generate."
   ;; For now, pass through until dirty is implemented.
@@ -639,10 +660,10 @@ MFILENAME is the makefile to generate."
          (file-newer-than-file-p (oref this file) mfilename))
       (ede-proj-makefile-create this mfilename)))
 
-(defmethod ede-proj-setup-buildenvironment ((this ede-proj-project)
+(cl-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))
@@ -665,11 +686,16 @@ Optional argument FORCE will force items to be regenerated."
 \f
 ;;; Lower level overloads
 ;;
-(defmethod project-rescan ((this ede-proj-project))
+(cl-defmethod project-rescan ((this ede-proj-project))
   "Rescan the EDE proj project THIS."
   (let ((root (or (ede-project-root this) this))
        )
-    (setq ede-projects (delq root ede-projects))
+    ;; @TODO - VERIFY THE BELOW WORKS
+    (ede-project-directory-remove-hash
+     (file-name-directory (ede-project-root-directory root)))
+    (ede-delete-project-from-global-list root)
+    ;; NOTE : parent function double-checks that this dir was
+    ;; already in memory once.
     (ede-load-project-file (ede-project-root-directory root))
     ))