mkjambase generates more compact jambase.c
[k8jam.git] / rules.h
blob8594c6e6ec1182de24935f8d867b43007f8a044c
1 /*
2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
5 */
6 /*
7 * rules.h - targets, rules, and related information
9 * This file describes the structures holding the targets, rules, and
10 * related information accumulated by interpreting the statements
11 * of the jam files.
13 * The following are defined:
15 * RULE - a generic jam rule, the product of RULE and ACTIONS
16 * ACTIONS - a chain of ACTIONs
17 * ACTION - a RULE instance with targets and sources
18 * SETTINGS - variables to set when executing a TARGET's ACTIONS
19 * TARGETS - a chain of TARGETs
20 * TARGET - a file or "thing" that can be built
22 * 04/11/94 (seiwald) - Combined deps & headers into deps[2] in TARGET.
23 * 04/12/94 (seiwald) - actionlist() now just appends a single action.
24 * 06/01/94 (seiwald) - new 'actions existing' does existing sources
25 * 12/20/94 (seiwald) - NOTIME renamed NOTFILE.
26 * 01/19/95 (seiwald) - split DONTKNOW into CANTFIND/CANTMAKE.
27 * 02/02/95 (seiwald) - new LEAVES modifier on targets.
28 * 02/14/95 (seiwald) - new NOUPDATE modifier on targets.
29 * 02/28/02 (seiwald) - merge EXEC_xxx flags in with RULE_xxx
30 * 06/21/02 (seiwald) - support for named parameters
31 * 07/17/02 (seiwald) - TEMPORARY sources for headers now get built
32 * 11/04/02 (seiwald) - const-ing for string literals
33 * 12/03/02 (seiwald) - fix odd includes support by grafting them onto depends
34 * 12/17/02 (seiwald) - new copysettings() to protect target-specific vars
35 * 01/14/03 (seiwald) - fix includes fix with new internal includes TARGET
37 #ifndef JAMH_RULES_H
38 #define JAMH_RULES_H
41 typedef struct _rule RULE;
42 typedef struct _target TARGET;
43 typedef struct _targets TARGETS;
44 typedef struct _action ACTION;
45 typedef struct _actions ACTIONS;
46 typedef struct _settings SETTINGS ;
48 /* RULE - a generic jam rule, the product of RULE and ACTIONS */
49 enum {
50 RULE_UPDATED = 0x01, /* $(>) is updated sources only */
51 RULE_TOGETHER = 0x02, /* combine actions on single target */
52 RULE_IGNORE = 0x04, /* ignore return status of executes */
53 RULE_QUIETLY = 0x08, /* don't mention it unless verbose */
54 RULE_PIECEMEAL= 0x10, /* split exec so each $(>) is small */
55 RULE_EXISTING = 0x20, /* $(>) is pre-exisitng sources only */
56 RULE_MAXLINE = 0x40 /* cmd specific maxline (last) */
59 struct _rule {
60 const char *name;
61 PARSE *procedure; /* parse tree from RULE */
62 const char *actions; /* command string from ACTIONS */
63 LIST *bindlist; /* variable to bind for actions */
64 LIST *params; /* bind args to local vars */
65 int flags; /* modifiers on ACTIONS (RULE_XXX) */
69 /* ACTIONS - a chain of ACTIONs */
70 struct _actions {
71 ACTIONS *next;
72 ACTIONS *tail; /* valid only for head */
73 ACTION *action;
76 /* ACTION - a RULE instance with targets and sources */
77 struct _action {
78 RULE *rule;
79 TARGETS *targets;
80 TARGETS *sources; /* aka $(>) */
81 char running; /* has been started */
82 char status; /* see TARGET status */
85 /* SETTINGS - variables to set when executing a TARGET's ACTIONS */
86 struct _settings {
87 SETTINGS *next;
88 const char *symbol; /* symbol name for var_set() */
89 LIST *value; /* symbol value for var_set() */
92 /* TARGETS - a chain of TARGETs */
93 struct _targets {
94 TARGETS *next;
95 TARGETS *tail; /* valid only for head */
96 TARGET *target;
99 /* TARGET - a file or "thing" that can be built */
100 enum {
101 T_FLAG_TEMP = 0x01, /* TEMPORARY applied */
102 T_FLAG_NOCARE = 0x02, /* NOCARE applied */
103 T_FLAG_NOTFILE = 0x04, /* NOTFILE applied */
104 T_FLAG_TOUCHED = 0x08, /* ALWAYS applied or -t target */
105 T_FLAG_LEAVES = 0x10, /* LEAVES applied */
106 T_FLAG_NOUPDATE = 0x20, /* NOUPDATE applied */
107 T_FLAG_INTERNAL = 0x40 /* internal INCLUDES node */
110 enum {
111 T_BIND_UNBOUND, /* a disembodied name */
112 T_BIND_MISSING, /* couldn't find real file */
113 T_BIND_PARENTS, /* using parent's timestamp */
114 T_BIND_EXISTS /* real file, timestamp valid */
117 enum {
118 T_FATE_INIT, /* nothing done to target */
119 T_FATE_MAKING, /* make0(target) on stack */
121 T_FATE_STABLE, /* target didn't need updating */
122 T_FATE_NEWER, /* target newer than parent */
124 T_FATE_SPOIL, /* >= SPOIL rebuilds parents */
125 T_FATE_ISTMP=T_FATE_SPOIL, /* unneeded temp target oddly present */
127 T_FATE_BUILD, /* >= BUILD rebuilds target */
128 T_FATE_TOUCHED = T_FATE_BUILD, /* manually touched with -t */
129 T_FATE_MISSING, /* is missing, needs updating */
130 T_FATE_NEEDTMP, /* missing temp that must be rebuild */
131 T_FATE_OUTDATED, /* is out of date, needs updating */
132 T_FATE_UPDATE, /* deps updated, needs updating */
134 T_FATE_BROKEN, /* >= BROKEN ruins parents */
135 T_FATE_CANTFIND = T_FATE_BROKEN, /* no rules to make missing target */
136 T_FATE_CANTMAKE /* can't find dependents */
139 enum {
140 T_MAKE_INIT, /* make1(target) not yet called */
141 T_MAKE_ONSTACK, /* make1(target) on stack */
142 T_MAKE_ACTIVE, /* make1(target) in make1b() */
143 T_MAKE_RUNNING, /* make1(target) running commands */
144 T_MAKE_DONE /* make1(target) done */
145 #ifndef JAM_OPT_SEMAPHORE
146 ,T_MAKE_SEMAPHORE /* special target type for semaphores */
147 #endif
150 struct _target {
151 const char *name;
152 const char *boundname; /* if search() relocates target */
153 ACTIONS *actions; /* rules to execute, if any */
154 SETTINGS *settings; /* variables to define */
156 char flags; /* status info (T_FLAG_XXX) */
158 char binding; /* how target relates to real file (T_BIND_XXX) */
160 TARGETS *depends; /* dependencies */
161 TARGET *includes; /* includes */
163 time_t time; /* update time */
164 time_t leaf; /* update time of leaf sources */
165 char fate; /* make0()'s diagnosis (T_FATE_XXX) */
167 char progress; /* tracks make1() progress (T_MAKE_XXX)*/
169 #ifndef JAM_OPT_SEMAPHORE
170 TARGET *semaphore; /* used in serialization */
171 #endif
173 char status; /* execcmd() result */
175 int asynccnt; /* child deps outstanding */
176 TARGETS *parents; /* used by make1() for completion */
177 char *cmds; /* type-punned command list */
181 extern RULE *bindrule (const char *rulename);
182 extern TARGET *bindtarget (const char *targetname);
183 extern TARGET *copytarget (const TARGET *t);
184 extern void touchtarget (const char *t);
185 extern TARGETS *targetlist (TARGETS *chain, LIST *targets);
186 extern TARGETS *targetentry (TARGETS *chain, TARGET *target);
187 extern TARGETS *targetchain (TARGETS *chain, TARGETS *targets);
188 extern ACTIONS *actionlist (ACTIONS *chain, ACTION *action);
189 extern SETTINGS *addsettings (SETTINGS *v, int setflag, const char *sym, LIST *val);
190 extern SETTINGS *copysettings (SETTINGS *v);
191 extern void pushsettings (SETTINGS *v);
192 extern void popsettings (SETTINGS *v);
193 extern void freesettings (SETTINGS *v);
194 extern void donerules (void);
197 #endif