simple.el 3.9 KB

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