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