chiark / gitweb /
(Bug fix) Include the SIGWINCH handler even if `wresize' isn't known.
[sw-tools] / src / sw_build.h
1 /* -*-c-*-
2  *
3  * $Id: sw_build.h,v 1.2 1999/07/16 12:50:24 mdw Exp $
4  *
5  * Management of build processes
6  *
7  * (c) 1999 EBI
8  */
9
10 /*----- Licensing notice --------------------------------------------------* 
11  *
12  * This file is part of sw-tools.
13  *
14  * sw-tools is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  * 
19  * sw-tools is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * 
24  * You should have received a copy of the GNU General Public License
25  * along with sw-tools; if not, write to the Free Software Foundation,
26  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27  */
28
29 /*----- Revision history --------------------------------------------------* 
30  *
31  * $Log: sw_build.h,v $
32  * Revision 1.2  1999/07/16 12:50:24  mdw
33  * Improve exit status display.  New interface from `doto' project.
34  *
35  * Revision 1.1.1.1  1999/06/02 16:53:35  mdw
36  * Initial import.
37  *
38  */
39
40 #ifndef SW_BUILD_H
41 #define SW_BUILD_H
42
43 #ifdef __cplusplus
44   extern "C" {
45 #endif
46
47 /*----- Header files ------------------------------------------------------*/
48
49 #ifndef SW_ARCH_H
50 #  include "sw_arch.h"
51 #endif
52
53 #ifndef SW_INFO_H
54 #  include "sw_info.h"
55 #endif
56
57 #ifndef SW_RSH_H
58 #  include "sw_rsh.h"
59 #endif
60
61 /*----- Data structures ---------------------------------------------------*/
62
63 /* --- Information about a presentation handler --- *
64  *
65  * The @pres@ structure includes everything you need to know about a
66  * presentation handler.
67  *
68  * Presentation handler blocks are linked into a list, in a similar way to
69  * commands.  (See the `sw.h' header for information on this.)  The magic
70  * link macro is @PRES_LINK@.
71  *
72  * The `name' field is used to resolve the `--output=' option argument into a
73  * presentation.  Make the first few characters distinctive: it uses
74  * abbreviation-matching to choose a presentation style.
75  *
76  * The various routines work like this:
77  *
78  *   * @ok@ is used to find out whether the handler can *in principle* run in
79  *     the current environment.  For example, a presentation handler which
80  *     makes use of special terminal features would ensure that standard
81  *     output is a terminal; similarly, an X-based handler would ensure that
82  *     there is a current display set.  If the handler responds `false' to
83  *     this request, the `plain' handler is chosen instead.  A zero value
84  *     means that it's always OK to use this handler.
85  *
86  *  * @init@ is used to initialize the chosen handler.  It returns zero for
87  *    success, nonzero for failure.  A failure at this point is a fatal
88  *    error: the decision about which handler to run has already been made.
89  *    The function is passed the build list as an argument.  Entries with
90  *    null remote contexts are not to be built and can be ignored here.  Note
91  *    that the actual build jobs have not been started yet.  They're left
92  *    until last because they're the most difficult things to stop.  (Indeed,
93  *    if some don't start, the others are left to run anyway.)  A zero value
94  *    means this handler needs no initialization.
95  *
96  *  * @output@ reports new output for a particular build: a pointer to the
97  *    appropriate archtecture entry is passed.  The handler should format the
98  *    text in the buffer in some pleasing and useful manner, and then return.
99  *    Any errors which occur at this point are the handler's own problem to
100  *    sort out.  It is not permitted for a handler to have a null output
101  *    routine.
102  *
103  *  * @close@ informs the handler that a particular build has completed.  The
104  *    @ok@ argument is nonzero if the build was successful, and zero
105  *    otherwise.  (A message describing the failure will have been
106  *    synthetically output before this point, so only a small visual cue is
107  *    needed here.)  A zero value means this handler is not interested in
108  *    close events.  The argument @summ@ is a quick summary of the exit
109  *    status.
110  *
111  *  * @done@ informs the handler that all builds have completed.  The handler
112  *    should make sure that the display will remain as long as is needed, and
113  *    deallocate any resources it obtained eariler.  A zero value means the
114  *    handler needs no cleanup and its output is persistent anyway.
115  *
116  *  * @abort@ cleans up immediately, because something went horribly wrong.
117  *    This shouldn't happen very often, but when it is, it's normally
118  *    followed by a call to @die@.  A zero value means that this sort of
119  *    thing isn't necessary.
120  *
121  * That's all there is.  Any questions?
122  *
123  * (The current structure doesn't interface very well with X toolkits.  Some
124  * kind of call-tree inverstion would be handy for that, although I don't
125  * want to make all the handlers able to cope with `select' management.  This
126  * needs thought, if I ever decide to add an X interface here.)
127  */
128
129 typedef struct pres {
130   struct pres *next;
131   const char *name;
132   int (*ok)(void);
133   int (*init)(archcons */*a*/);
134   void (*output)(archent */*e*/, const char */*p*/, size_t /*sz*/);
135   void (*close)(archent */*e*/, int /*ok*/, const char */*summ*/);
136   void (*done)(archcons */*a*/);
137   void (*abort)(archcons */*a*/);
138 } pres;
139
140 /*----- Functions provided ------------------------------------------------*/
141
142 /* --- @swbuild_archlist@ --- *
143  *
144  * Arguments:   @swinfo *sw@ = pointer to the build information block
145  *
146  * Returns:     A list of architectures which are to be built.
147  *
148  * Use:         Decides which architectures need building, and returns them
149  *              in a list.
150  */
151
152 extern archcons *swbuild_archlist(swinfo */*sw*/);
153
154 /*----- Subcommands -------------------------------------------------------*/
155
156 extern int sw_run(int /*argc*/, char */*argv*/[]);
157 extern int sw_make(int /*argc*/, char */*argv*/[]);
158 extern int sw_conf(int /*argc*/, char */*argv*/[]);
159 extern int sw_reset(int /*argc*/, char */*argv*/[]);
160 extern void swrsh_build(sw_remote */*r*/, char */*argv*/[], char */*env*/[]);
161
162 #ifdef CMD_LINK
163    static cmd cmd_reset = {
164      CMD_LINK, "reset", sw_reset,
165 "reset\tClears all the architecture build flags, so that all architectures\n\
166         will be built next time.  This is useful just before a call to\n\
167         `sw make clean', for example.\n"
168    };
169    static cmd cmd_run = {
170      &cmd_reset, "run", sw_run,
171 "run COMMAND [ARGS...]\n\
172         Run COMMAND across all architectures that haven't been built yet,\n\
173         in architecture-specific subdirectories.  The output is written to\n\
174         logfiles in the subdirectories, and displayed in some way by the\n\
175         selected output style.\n"
176    };
177    static cmd cmd_make = {
178      &cmd_run, "make", sw_make,
179 "make [ARGS...]\n\
180         Syntactic sugar for `run make ARGS'.  The `make' program named in\n\
181         the environment variable `SW_MAKE' is used by preference.\n"
182    };
183    static cmd cmd_conf = {
184      &cmd_make, "configure", sw_conf,
185 "configure [ARGS...]\n\
186         Syntactic sugar for `run ../configure --prefix=PREFIX'.  Put other\n\
187         autoconf site configuration in the `config.site' script.  The\n\
188         `prefix' value used is " PREFIX ".\n"
189    };
190 #  undef CMD_LINK
191 #  define CMD_LINK &cmd_conf
192 #endif
193
194 #ifdef RCMD_LINK
195    static rcmd rcmd_build = { RCMD_LINK, "build", swrsh_build };
196 #  undef RCMD_LINK
197 #  define RCMD_LINK &rcmd_build
198 #endif
199
200 /*----- That's all, folks -------------------------------------------------*/
201
202 #ifdef __cplusplus
203   }
204 #endif
205
206 #endif