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