]> code.delx.au - gnu-emacs/blob - lisp/cedet/ede/simple.el
8d77cea652974b85375ddfdf341baa64bc6ab023
[gnu-emacs] / lisp / cedet / ede / simple.el
1 ;;; ede/simple.el --- Overlay an EDE structure on an existing project
2
3 ;; Copyright (C) 2007-2011 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 ;; NOTE: EDE Simple Projects are considered obsolete. Use generic
25 ;; projects instead. They have much better automatic support and
26 ;; simpler configuration.
27 ;;
28 ;; A vast majority of projects use non-EDE project techniques, such
29 ;; as hand written Makefiles, or other IDE's.
30 ;;
31 ;; The EDE-SIMPLE project type allows EDE to wrap an existing mechanism
32 ;; with minimal configuration, and then provides project-root
33 ;; information to Semantic or other tools, and also provides structure
34 ;; information for in-project include header discovery, or speedbar
35 ;; support.
36 ;;
37 ;; It will also support a the minimal EDE UI for compilation and
38 ;; configuration.
39
40 ;; @todo - Add support for cpp-root as an ede-simple project.
41 ;; @todo - Allow ede-simple to store locally.
42
43 (require 'ede)
44 (require 'cedet-files)
45
46 ;;; Code:
47
48 (add-to-list 'ede-project-class-files
49 (ede-project-autoload "simple-overlay"
50 :name "Simple" :file 'ede/simple
51 :proj-file 'ede-simple-projectfile-for-dir
52 :load-type 'ede-simple-load
53 :class-sym 'ede-simple-project)
54 t)
55
56 (defcustom ede-simple-save-directory "~/.ede"
57 "*Directory where simple EDE project overlays are saved."
58 :group 'ede
59 :type 'directory)
60
61 (defcustom ede-simple-save-file-name "ProjSimple.ede"
62 "*File name used for simple project wrappers."
63 :group 'ede
64 :type 'string)
65
66 (defun ede-simple-projectfile-for-dir (&optional dir)
67 "Return a full file name to the project file stored in the current directory.
68 The directory has three parts:
69 <STORAGE ROOT>/<PROJ DIR AS FILE>/ProjSimple.ede"
70 (let ((d (or dir default-directory)))
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 (defun ede-simple-load (dir &optional rootproj)
81 "Load a project of type `Simple' for the directory DIR.
82 Return nil if there isn't one.
83 ROOTPROJ is nil, since we will only create a single EDE project here."
84 (let ((pf (ede-simple-projectfile-for-dir dir))
85 (obj nil))
86 (when pf
87 (setq obj (eieio-persistent-read pf))
88 (oset obj :directory dir)
89 )
90 obj))
91
92 (defclass ede-simple-target (ede-target)
93 ()
94 "EDE Simple project target.
95 All directories need at least one target.")
96
97 (defclass ede-simple-project (ede-project eieio-persistent)
98 ((extension :initform ".ede")
99 (file-header-line :initform ";; EDE Simple Project")
100 )
101 "EDE Simple project class.
102 Each directory needs a project file to control it.")
103
104 (defmethod ede-commit-project ((proj ede-simple-project))
105 "Commit any change to PROJ to its file."
106 (when (not (file-exists-p ede-simple-save-directory))
107 (if (y-or-n-p (concat ede-simple-save-directory
108 " doesn't exist. Create? "))
109 (make-directory ede-simple-save-directory)
110 (error "No save directory for new project")))
111 (eieio-persistent-save proj))
112
113 (defmethod ede-find-subproject-for-directory ((proj ede-simple-project)
114 dir)
115 "Return PROJ, for handling all subdirs below DIR."
116 proj)
117
118 (provide 'ede/simple)
119
120 ;;; ede/simple.el ends here