Initial Commit
[packages] / xemacs-packages / ede / ede-simple.el
1 ;;; ede-simple.el --- Overlay an EDE structure on an existing project
2
3 ;; Copyright (C) 2007 Eric M. Ludlam
4
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 ;; X-RCS: $Id: ede-simple.el,v 1.1 2007-11-26 15:22:10 michaels Exp $
7
8 ;; This program is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation; either version 2, or (at
11 ;; your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;; General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22
23 ;;; Commentary:
24 ;;
25 ;; A vast majority of projects use non-EDE project techniques, such
26 ;; as hand written Makefiles, or other IDE's.
27 ;;
28 ;; The EDE-SIMPLE project type allows EDE to wrap an existing mechanism
29 ;; with minimal configuration, and then provides project-root
30 ;; information to Semantic or other tools, and also provides structure
31 ;; information for in-project include header discovery, or speedbar
32 ;; support.
33 ;;
34 ;; It will also support a the minimal EDE UI for compilation and
35 ;; configuration.
36
37 (require 'ede)
38 (require 'cedet-files)
39
40 ;;; Code:
41 (add-to-list 'ede-project-class-files
42              (ede-project-autoload "simple-overlay"
43               :name "Simple" :file 'ede-simple
44               :proj-file 'ede-simple-projectfile-for-dir
45               :load-type 'ede-simple-load
46               :class-sym 'ede-simple-project)
47              t)
48
49 (defcustom ede-simple-save-directory "~/.ede"
50   "*Directory where simple EDE project overlays are saved."
51  :group 'ede
52  :type 'directory)
53
54 (defcustom ede-simple-save-file-name "ProjSimple.ede"
55   "*File name used for simple project wrappers."
56   :group 'ede
57   :type 'string)
58
59 ;;;###autoload
60 (defun ede-simple-projectfile-for-dir (&optional dir)
61   "Return a full file name to the project file stored in the current directory.
62 The directory has three parts:
63   <STORAGE ROOT>/<PROJ DIR AS FILE>/ProjSimple.ede"
64   (when (not (file-exists-p ede-simple-save-directory))
65     (if (y-or-n-p (concat ede-simple-save-directory
66                           " Doesn't exist.  Create? "))
67         (make-directory ede-simple-save-directory)
68       (error "No save directory for new project")))
69   (let ((d (or dir default-directory))
70         )
71     (concat
72      ;; Storage root
73      (file-name-as-directory (expand-file-name ede-simple-save-directory))
74      ;; Convert directory to filename
75      (cedet-directory-name-to-file-name d)
76      ;; Filename
77      ede-simple-save-file-name)
78     ))
79
80 ;;;###autoload
81 (defun ede-simple-load (dir)
82   "Load a project of type `Simple' for the directory DIR.
83 Return nil if there isn't one."
84   (let ((pf (ede-simple-projectfile-for-dir dir)))
85     (when pf
86       (eieio-persistent-read pf))
87     ))
88
89 (defclass ede-simple-target (ede-target)
90   ()
91   "EDE Simple project target.
92 All directories need at least one target.")
93
94 ;;;###autoload
95 (defclass ede-simple-project (eieio-persistent ede-project)
96   ((extension :initform ".ede")
97    (file-header-line :initform ";; EDE Simple Project")
98    )
99   "EDE Simple project class.
100 Each directory needs a a project file to control it.")
101
102 (defmethod ede-commit-project ((proj ede-simple-project))
103   "Commit any change to PROJ to its file."
104   (eieio-persistent-save proj))
105
106
107 (provide 'ede-simple)
108
109 ;;; ede-simple.el ends here