]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/ede/generic.el
Fix some declarations
[gnu-emacs] / lisp / cedet / ede / generic.el
index c2d31f56a1357ae1f9434d2237233bc56443e05b..fedf0ffc7c6119c40c7f98bbca983e9fa29f4daf 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ede/generic.el --- Base Support for generic build systems
 
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
@@ -22,7 +22,7 @@
 ;;; Commentary:
 ;;
 ;; There are a lot of build systems out there, and EDE can't support
-;; them all fully.  The ede-generic.el system is the base for
+;; them all fully.  The ede/generic.el system is the base for
 ;; supporting alternate build systems in a simple way, automatically.
 ;;
 ;; The structure is for the ede-generic baseclass, which is augmented
 ;;
 ;; Customization:
 ;;
-;; Since these projects are all so increadibly generic, a user will
+;; Since these projects are all so incredibly generic, a user will
 ;; need to configure some aspects of the project by hand.  In order to
 ;; enable this without configuring the project objects directly (which
-;; are auto-generated) a special ede-generic-confg object is defined to
+;; are auto-generated) a special ede-generic-config object is defined to
 ;; hold the basics.  Generic projects will identify and use these
 ;; config files.
 ;;
@@ -70,7 +70,7 @@
 ;; subclasses `ede-generic-target'.  The slots `shortname' and
 ;; `extension' should be given new initial values.
 ;;
-;; Optionally, any target method used by EDE can then be overriden.
+;; Optionally, any target method used by EDE can then be overridden.
 ;; The ede-generic-target-c-cpp has some example methods setting up
 ;; the pre-processor map and system include path.
 ;;
@@ -79,6 +79,7 @@
 
 (require 'eieio-opt)
 (require 'ede)
+(require 'ede/shell)
 (require 'semantic/db)
 
 ;;; Code:
                  :group (default build)
                  :documentation
                  "Command used for debugging this project.")
-   ;; C target customixations
+   (run-command :initarg :run-command
+               :initform nil
+               :type (or null string)
+               :custom string
+               :group (default build)
+               :documentation
+               "Command used to run something related to this project.")
+   ;; C target customizations
    (c-include-path :initarg :c-include-path
                   :initform nil
                   :type list
 Return nil if there isn't one.
 Argument DIR is the directory it is created for.
 ROOTPROJ is nil, since there is only one project."
-  ;; Doesn't already exist, so lets make one.
+  ;; Doesn't already exist, so let's make one.
   (let* ((alobj ede-constructing)
         (this nil))
     (when (not alobj) (error "Cannot load generic project without the autoload instance"))
@@ -196,7 +204,7 @@ The class allocated value is replace by different sub classes.")
                                     (oref proj :directory))))
        (if (file-exists-p fname)
            ;; Load in the configuration
-           (setq config (eieio-persistent-read fname))
+           (setq config (eieio-persistent-read fname 'ede-generic-config))
          ;; Create a new one.
          (setq config (ede-generic-config
                        "Configuration"
@@ -249,7 +257,7 @@ All directories need at least one target.")
   "EDE Generic Project target for Misc files.
 All directories need at least one target.")
 
-;;; Automatic target aquisition.
+;;; Automatic target acquisition.
 (defun ede-generic-find-matching-target (class dir targets)
   "Find a target that is a CLASS and is in DIR in the list of TARGETS."
   (let ((match nil))
@@ -321,6 +329,44 @@ If one doesn't exist, create a new one for this directory."
        (config (ede-generic-get-configuration proj)))
     (oref config c-include-path)))
 
+;;; Commands
+;;
+(defmethod project-compile-project ((proj ede-generic-project) &optional command)
+  "Compile the entire current project PROJ.
+Argument COMMAND is the command to use when compiling."
+  (let* ((config (ede-generic-get-configuration proj))
+        (comp (oref config :build-command)))
+    (compile comp)))
+
+(defmethod project-compile-target ((obj ede-generic-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-debug-target ((target ede-generic-target))
+  "Run the current project derived from TARGET in a debugger."
+  (let* ((proj (ede-target-parent target))
+        (config (ede-generic-get-configuration proj))
+        (debug (oref config :debug-command))
+        (cmd (read-from-minibuffer
+              "Debug Command: "
+              debug))
+        (cmdsplit (split-string cmd " " t))
+        ;; @TODO - this depends on the user always typing in something good
+        ;;  like "gdb" or "dbx" which also exists as a useful Emacs command.
+        ;;  Is there a better way?
+        (cmdsym (intern-soft (car cmdsplit))))
+    (call-interactively cmdsym t)))
+
+(defmethod project-run-target ((target ede-generic-target))
+  "Run the current project derived from TARGET."
+  (require 'ede-shell)
+  (let* ((proj (ede-target-parent target))
+        (config (ede-generic-get-configuration proj))
+        (run (concat "./" (oref config :run-command)))
+        (cmd (read-from-minibuffer "Run (like this): " run)))
+    (ede-shell-run-something target cmd)))
+
 ;;; Customization
 ;;
 (defmethod ede-customize ((proj ede-generic-project))
@@ -359,33 +405,37 @@ the new configuration."
 (defun ede-generic-new-autoloader (internal-name external-name
                                                 projectfile class)
   "Add a new EDE Autoload instance for identifying a generic project.
-INTERNAL-NAME is a long name that identifies thsi project type.
+INTERNAL-NAME is a long name that identifies this project type.
 EXTERNAL-NAME is a shorter human readable name to describe the project.
 PROJECTFILE is a file name that identifies a project of this type to EDE, such as
 a Makefile, or SConstruct file.
 CLASS is the EIEIO class that is used to track this project.  It should subclass
 the class `ede-generic-project' project."
-  (add-to-list 'ede-project-class-files
-              (ede-project-autoload internal-name
-                                    :name external-name
-                                    :file 'ede/generic
-                                    :proj-file projectfile
-                                    :load-type 'ede-generic-load
-                                    :class-sym class
-                                    :new-p nil)
-              ;; Generics must go at the end, since more specific types
-              ;; can create Makefiles also.
-              t))
+  (ede-add-project-autoload
+   (ede-project-autoload internal-name
+                        :name external-name
+                        :file 'ede/generic
+                        :proj-file projectfile
+                        :load-type 'ede-generic-load
+                        :class-sym class
+                        :new-p nil
+                        :safe-p nil)   ; @todo - could be
+                                       ; safe if we do something
+                                       ; about the loading of the
+                                       ; generic config file.
+   ;; Generics must go at the end, since more specific types
+   ;; can create Makefiles also.
+   'generic))
 
 ;;;###autoload
 (defun ede-enable-generic-projects ()
   "Enable generic project loaders."
   (interactive)
-  (ede-generic-new-autoloader "edeproject-makefile" "Make"
+  (ede-generic-new-autoloader "generic-makefile" "Make"
                              "Makefile" 'ede-generic-makefile-project)
-  (ede-generic-new-autoloader "edeproject-scons" "SCons"
+  (ede-generic-new-autoloader "generic-scons" "SCons"
                              "SConstruct" 'ede-generic-scons-project)
-  (ede-generic-new-autoloader "edeproject-cmake" "CMake"
+  (ede-generic-new-autoloader "generic-cmake" "CMake"
                              "CMakeLists" 'ede-generic-cmake-project)
   )