Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / lisp / cedet / ede / simple.el
blob87d36913b0e37429730dbf5923a7f6857a1edc1f
1 ;;; ede/simple.el --- Overlay an EDE structure on an existing project
3 ;; Copyright (C) 2007-2014 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
22 ;;; Commentary:
24 ;; NOTE: EDE Simple Projects are considered obsolete. Use generic
25 ;; projects instead. They have much better automatic support and
26 ;; simpler configuration.
28 ;; A vast majority of projects use non-EDE project techniques, such
29 ;; as hand written Makefiles, or other IDE's.
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.
37 ;; It will also support a the minimal EDE UI for compilation and
38 ;; configuration.
40 ;; @todo - Add support for cpp-root as an ede-simple project.
41 ;; @todo - Allow ede-simple to store locally.
43 (require 'ede)
44 (require 'cedet-files)
46 ;;; Code:
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 :safe-p nil)
57 (defcustom ede-simple-save-directory "~/.ede"
58 "*Directory where simple EDE project overlays are saved."
59 :group 'ede
60 :type 'directory)
62 (defcustom ede-simple-save-file-name "ProjSimple.ede"
63 "*File name used for simple project wrappers."
64 :group 'ede
65 :type 'string)
67 (defun ede-simple-projectfile-for-dir (&optional dir)
68 "Return a full file name to the project file stored in the current directory.
69 The directory has three parts:
70 <STORAGE ROOT>/<PROJ DIR AS FILE>/ProjSimple.ede"
71 (let ((d (or dir default-directory)))
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)
81 (defun ede-simple-load (dir &optional rootproj)
82 "Load a project of type `Simple' for the directory DIR.
83 Return nil if there isn't one.
84 ROOTPROJ is nil, since we will only create a single EDE project here."
85 (let ((pf (ede-simple-projectfile-for-dir dir))
86 (obj nil))
87 (when pf
88 (setq obj (eieio-persistent-read pf))
89 (oset obj :directory dir)
91 obj))
93 (defclass ede-simple-target (ede-target)
95 "EDE Simple project target.
96 All directories need at least one target.")
98 (defclass ede-simple-project (ede-project eieio-persistent)
99 ((extension :initform ".ede")
100 (file-header-line :initform ";; EDE Simple Project")
102 "EDE Simple project class.
103 Each directory needs a project file to control it.")
105 (defmethod ede-commit-project ((proj ede-simple-project))
106 "Commit any change to PROJ to its file."
107 (when (not (file-exists-p ede-simple-save-directory))
108 (if (y-or-n-p (concat ede-simple-save-directory
109 " doesn't exist. Create? "))
110 (make-directory ede-simple-save-directory)
111 (error "No save directory for new project")))
112 (eieio-persistent-save proj))
114 (defmethod ede-find-subproject-for-directory ((proj ede-simple-project)
115 dir)
116 "Return PROJ, for handling all subdirs below DIR."
117 proj)
119 (provide 'ede/simple)
121 ;; Local variables:
122 ;; generated-autoload-load-name: "ede/simple"
123 ;; End:
125 ;;; ede/simple.el ends here