Initial Commit
[packages] / xemacs-packages / jde / lisp / jde-make.el
1 ;;; jde-make.el -- Integrated Development Environment for Java.
2 ;; $Revision: 1.17 $ 
3
4 ;; Author: Paul Kinnucan <pkinnucan@attbi.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
7
8 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004 Paul Kinnucan.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 (require 'compile)
26
27 (defgroup jde-make nil
28   "JDE Make Interface"
29   :group 'jde
30   :prefix "jde-make-")
31
32 (defcustom jde-make-program "make"
33   "*Specifies name of make program."
34  :group 'jde-make
35  :type 'string)
36
37 (defcustom jde-make-working-directory ""
38   "*Path of the working directory to use in 'make' build mode. This
39 string must end in a slash, for example, c:/foo/bar/ or ./  .
40 If this string is empty, the 'make' build mode uses the current file
41 location as its working directory."
42   :group 'jde-make
43   :type 'string)
44
45 (defcustom jde-make-args ""
46   "*Specifies arguments to be passed to make program."
47   :group 'jde-make
48   :type 'string)
49
50 (defcustom jde-make-finish-hook 
51   '(jde-compile-finish-refresh-speedbar jde-compile-finish-update-class-info)
52   "List of functions to be invoked when compilation of a 
53 Java source file terminates. Each function should accept
54 two arguments: the compilation buffer and a string 
55 describing how the compilation finished."
56   :group 'jde-make
57   :type 'hook)
58
59 (defvar jde-interactive-make-args ""
60 "String of compiler arguments entered in the minibuffer.")
61
62 (defcustom jde-read-make-args nil
63 "*Specify whether to prompt for additional make arguments.
64 If this variable is non-nil, and if `jde-build-use-make' is non nil
65 the jde-build command prompts you to enter additional make
66 arguments in the minibuffer. These arguments are appended to those 
67 specified by customization variables. The JDE maintains a history 
68 list of arguments entered in the minibuffer."
69   :group 'jde-make
70   :type 'boolean
71 )
72
73
74 (defun jde-make-make-command (more-args)
75   "Constructs the java compile command as: jde-compiler + options + buffer file name."
76   (concat jde-make-program " " jde-make-args
77           (if (not (string= more-args ""))
78               (concat " " more-args))
79           " "))
80
81
82 ;;;###autoload
83 (defun jde-make ()
84   "Run the make program specified by `jde-make-program' with the
85 command-line arguments specified by `jde-make-args'. If
86 `jde-read-make-args' is nonnil, this command also prompts you to enter
87 make arguments in the minibuffer and passes any arguments that you
88 enter to the make program along with the arguments specified by
89 `jde-make-args'."
90   (interactive)
91   (if jde-read-make-args
92       (setq jde-interactive-make-args
93               (read-from-minibuffer 
94                "Make args: "
95                jde-interactive-make-args
96                nil nil
97                '(jde-interactive-make-arg-history . 1))))
98
99   (let ((make-command
100          (jde-make-make-command 
101           jde-interactive-make-args))
102         (save-default-directory default-directory)
103         (default-directory 
104           (if (string= jde-make-working-directory "")
105               default-directory
106             (jde-normalize-path 'jde-make-working-directory))))
107
108
109     ;; Force save-some-buffers to use the minibuffer
110     ;; to query user about whether to save modified buffers.
111     ;; Otherwise, when user invokes jde-make from
112     ;; menu, save-some-buffers tries to popup a menu
113     ;; which seems not to be supported--at least on
114     ;; the PC.
115     (if (and (eq system-type 'windows-nt)
116              (not jde-xemacsp)) 
117         (let ((temp last-nonmenu-event))
118           ;; The next line makes emacs think that jde-make
119           ;; was invoked from the minibuffer, even when it
120           ;; is actually invoked from the menu-bar.
121           (setq last-nonmenu-event t)
122           (save-some-buffers (not compilation-ask-about-save) nil)
123           (setq last-nonmenu-event temp))
124       (save-some-buffers (not compilation-ask-about-save) nil))
125
126     (setq compilation-finish-function 
127       (lambda (buf msg) 
128         (run-hook-with-args 'jde-make-finish-hook buf msg)
129         (setq compilation-finish-function nil)))
130
131     (cd default-directory)
132     (compile-internal make-command "No more errors")
133     (cd save-default-directory)))
134
135 ;;;###autoload
136 (defun jde-make-show-options ()
137   "Show the JDE Make Options panel."
138   (interactive)
139   (customize-apropos "jde-make" 'groups))
140
141 ;; Register and initialize the customization variables defined
142 ;; by this package.
143 (jde-update-autoloaded-symbols)
144
145 (provide 'jde-make)
146
147 ;; $Log: jde-make.el,v $
148 ;; Revision 1.17  2004/08/21 04:30:43  paulk
149 ;; Update the JDEE wizard class list after making a project.
150 ;;
151 ;; Revision 1.16  2003/09/16 05:13:39  paulk
152 ;; Update jde-make command to issue a cd to the default directory before invoking
153 ;; make and to restore the original cwd afterwards. This fixes a bug in the
154 ;; implementation of the jde-make-working-directory variable.
155 ;;
156 ;; Revision 1.15  2002/11/21 04:18:41  paulk
157 ;; These packages, when autoloaded, now register and initialize the customization variables
158 ;; that they define to the values specified in the current project file.
159 ;;
160 ;; Revision 1.14  2002/10/22 05:02:09  paulk
161 ;; Put make customization variables in their own group and provide an autoloaded command for displaying them as a group.
162 ;;
163 ;; Revision 1.13  2002/09/16 05:14:18  paulk
164 ;; Adds a jde-make-finish-hook variable that allows you to specify functions
165 ;; to run when make finishes. By default the variable is set to functions
166 ;; that update the speedbar and the completion cache. Thanks to Sandip Chitale.
167 ;;
168 ;; Revision 1.12  2002/03/22 05:24:32  paulk
169 ;; Expanded documentation for the jde-make command.
170 ;;
171 ;; Revision 1.11  2001/07/16 13:39:33  paulk
172 ;; Added note to the doc for jde-make-working-directory that the path must end in a path separator.
173 ;;
174 ;; Revision 1.10  2001/05/31 04:00:50  paulk
175 ;; Backed out the previous change which was NOT a bug.
176 ;;
177 ;; Revision 1.9  2001/05/31 01:09:13  paulk
178 ;; Small bug fix. Thanks to Luis Miguel Hernanz Iglesias <luish@germinus.com>.
179 ;;
180 ;; Revision 1.8  2001/04/16 05:59:17  paulk
181 ;; Normalize paths. Thanks to Nick Sieger.
182 ;;
183 ;; Revision 1.7  2000/08/09 03:29:26  paulk
184 ;; Added jde-make-working-directory variable. Thanks to Laurent Latil <Laurent.Latil@france.sun.com>
185 ;;
186 ;; Revision 1.6  1999/04/27 16:44:49  paulk
187 ;; Updated to allow interactive entry of make arguments. Thanks to Yarek J. Kowalik <jgk@klg.com> for providing this enhancement.
188 ;;
189 ;; Revision 1.5  1999/01/17 00:43:57  paulk
190 ;; Removed two line feeds at the end of make command as they appeared to
191 ;; confuse GNU make for NT.
192 ;;
193 ;; Revision 1.4  1998/11/27 09:38:23  paulk
194 ;; Changed to use compile mode as suggested by Robert Grace <rmg2768@draper.com>.
195 ;;
196 ;; Revision 1.3  1998/05/29 01:46:39  paulk
197 ;; Added dummy function for jde-make-mode to facilitate autoloading.
198 ;;
199 ;; Revision 1.2  1998/05/27 06:04:52  paulk
200 ;; Added autoload comments.
201 ;;
202 ;; Revision 1.1  1998/03/27 04:44:36  kinnucan
203 ;; Initial revision
204 ;;
205
206 ;; End of jde-make.el