1 ;;; cit-checkenv.el --- Check this computer's environment for needed tools.
3 ;; Copyright (C) 2014 Eric Ludlam
5 ;; Author: Eric Ludlam <zappo@ballista>
7 ;; This program is free software; you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License as
9 ;; published by the Free Software Foundation, either version 3 of the
10 ;; License, or (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see http://www.gnu.org/licenses/.
22 ;; Lots of build tools are needed to run the CEDET Integration tests.
23 ;; This command will summarize the requirements.
29 (require 'cedet-global
)
30 (require 'cedet-idutils
)
31 (require 'cedet-cscope
)
34 (defclass cit-checkenv-test
(eieio-named)
35 ((testgroup :initarg
:testgroup
39 "A function, or a string representing a program to run.")
40 (result :initarg
:result
43 If :test is a function then this is the expected output, compare w/ eq.
44 If :test is a string, then this is a version string to look for.")
45 (required :initarg
:required
48 "A class representing a thing to check.")
50 (defmethod cit-checkenv-dotest ((test cit-checkenv-test
) testgroup
)
52 (when (let ((tg (oref test testgroup
)))
53 (or (not testgroup
) (not tg
)
55 (string= testgroup tg
)
56 (member testgroup tg
))))
59 (cond ((functionp (oref test test
))
61 (let ((found (funcall (oref test test
)))
62 (expect (oref test result
)))
64 (cit-checkenv-ok test
)
65 (cit-checkenv-error test
"Test failed: Found %s, expected %s"
68 ((and (stringp (oref test test
)) (not (slot-boundp test
'result
)))
69 ;; Just check it is on the exec path.
70 (if (locate-file (oref test test
) exec-path
)
71 (cit-checkenv-ok test
)
72 (cit-checkenv-error test
"%s not found on exec-path."
76 (error "Unknown thing to check: %S" (oref test test
))))
79 (defmethod cit-checkenv-ok ((this cit-checkenv-test
))
80 "Note that test THIS is OK."
81 (message "OK: %S" (oref this
:object-name
)))
83 (defmethod cit-checkenv-error ((this cit-checkenv-test
) formatmsg
&rest args
)
84 "Issue an error (ie - test failed) for test THIS."
85 (let* ((req (oref this required
))
87 (if req
"Error" "Warning")
88 (format " (%s): " (oref this
:object-name
))
89 (apply 'format formatmsg args
))))
94 (defvar cit-checkenv-checks
96 (cit-checkenv-test "global"
97 :testgroup
'("Make" "Automake" "globalref")
98 :test
(lambda () (cedet-gnu-global-version-check t
))
100 (cit-checkenv-test "idutils"
101 :testgroup
'("Make" "Automake")
102 :test
(lambda () (cedet-idutils-version-check t
))
105 (cit-checkenv-test "cscope"
106 :testgroup
'("Make" "Automake")
107 :test
(lambda () (cedet-cscope-version-check t
))
110 (cit-checkenv-test "make" :testgroup
'("Make" "Automake" "Arduino") :test
"make")
112 (cit-checkenv-test "automake" :testgroup
"Automake" :test
"automake")
113 (cit-checkenv-test "libtool" :testgroup
"Automake" :test
"libtool")
115 (cit-checkenv-test "cpp" :testgroup
'("Make" "Automake" "cpp") :test
"cpp")
117 (cit-checkenv-test "texinfo" :testgroup
'("Make" "Automake") :test
"makeinfo")
119 (cit-checkenv-test "java"
121 :test
(lambda () (cedet-java-version-check t
))
123 (cit-checkenv-test "jar" :testgroup
"Java" :test
"jar")
124 (cit-checkenv-test "javap" :testgroup
"Java" :test
"javap")
126 (cit-checkenv-test "arduino" :testgroup
"Arduino"
128 (require 'ede
/arduino
)
129 (stringp (ede-arduino-find-install)))
131 (cit-checkenv-test "arduino-mk" :testgroup
"Arduino"
133 (require 'ede
/arduino
)
134 (stringp (ede-arduino-Arduino.mk
)))
137 (cit-checkenv-test "android-sdk" :testgroup
"Android"
138 :test
(lambda () (cedet-android-adb-version-check t
))
140 (cit-checkenv-test "ant" :testgroup
"Android" :test
"ant") ;; may be moving off this soon.
142 "List of checks to perform to see if this system can run the tests.
143 Each entry is a `cit-checkenv-test' object. See the doc for that
146 (defun cit-checkenv (testgroup)
147 "Check this computer for the needed tools."
148 (interactive "sTest Group: ")
149 (message "\n** Environment testing:
150 Checking your environment for the tools needed to test CEDET.\n")
151 (mapc (lambda (check) (cit-checkenv-dotest check testgroup
)) cit-checkenv-checks
)
153 (message "** Environment Tests complete\n")
157 (provide 'cit-checkenv
)
159 ;;; cit-checkenv.el ends here