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