Initial Commit
[packages] / xemacs-packages / ede / ede-simple.el.upstream
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.upstream,v 1.1 2007-11-26 15:22:11 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 ;;;###autoload
42 (add-to-list 'ede-project-class-files
43              (ede-project-autoload "simple-overlay"
44               :name "Simple" :file 'ede-simple
45               :proj-file 'ede-simple-projectfile-for-dir
46               :load-type 'ede-simple-load
47               :class-sym 'ede-simple-project)
48              t)
49
50 (defcustom ede-simple-save-directory "~/.ede"
51   "*Directory where simple EDE project overlays are saved."
52  :group 'ede
53  :type 'directory)
54
55 (defcustom ede-simple-save-file-name "ProjSimple.ede"
56   "*File name used for simple project wrappers."
57   :group 'ede
58   :type 'string)
59
60 ;;;###autoload
61 (defun ede-simple-projectfile-for-dir (&optional dir)
62   "Return a full file name to the project file stored in the current directory.
63 The directory has three parts:
64   <STORAGE ROOT>/<PROJ DIR AS FILE>/ProjSimple.ede"
65   (when (not (file-exists-p ede-simple-save-directory))
66     (if (y-or-n-p (concat ede-simple-save-directory
67                           " Doesn't exist.  Create? "))
68         (make-directory ede-simple-save-directory)
69       (error "No save directory for new project")))
70   (let ((d (or dir default-directory))
71         )
72     (concat
73      ;; Storage root
74      (file-name-as-directory (expand-file-name ede-simple-save-directory))
75      ;; Convert directory to filename
76      (cedet-directory-name-to-file-name d)
77      ;; Filename
78      ede-simple-save-file-name)
79     ))
80
81 ;;;###autoload
82 (defun ede-simple-load (dir)
83   "Load a project of type `Simple' for the directory DIR.
84 Return nil if there isn't one."
85   (let ((pf (ede-simple-projectfile-for-dir dir)))
86     (when pf
87       (eieio-persistent-read pf))
88     ))
89
90 (defclass ede-simple-target (ede-target)
91   ()
92   "EDE Simple project target.
93 All directories need at least one target.")
94
95 ;;;###autoload
96 (defclass ede-simple-project (eieio-persistent ede-project)
97   ((extension :initform ".ede")
98    (file-header-line :initform ";; EDE Simple Project")
99    )
100   "EDE Simple project class.
101 Each directory needs a a project file to control it.")
102
103 (defmethod ede-commit-project ((proj ede-simple-project))
104   "Commit any change to PROJ to its file."
105   (eieio-persistent-save proj))
106
107
108 (provide 'ede-simple)
109
110 ;;; ede-simple.el ends here