option.c: fixed warnings
[k8jam.git] / src / rules.h
blobf56a6ab3876634ef71eea13a0207ed2ef3e47337
1 /*
2 * Copyright 1993, 1995 Christopher Seiwald.
3 * This file is part of Jam - see jam.c for Copyright information.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * rules.h - targets, rules, and related information
20 * This file describes the structures holding the targets, rules, and
21 * related information accumulated by interpreting the statements
22 * of the jam files.
24 * The following are defined:
26 * RULE - a generic jam rule, the product of RULE and ACTIONS
27 * ACTIONS - a chain of ACTIONs
28 * ACTION - a RULE instance with targets and sources
29 * SETTINGS - variables to set when executing a TARGET's ACTIONS
30 * TARGETS - a chain of TARGETs
31 * TARGET - a file or "thing" that can be built
33 #ifndef JAMH_RULES_H
34 #define JAMH_RULES_H
36 #include "jam.h"
37 #include "hash.h"
40 typedef struct _rule RULE;
41 typedef struct _target TARGET;
42 typedef struct _targets TARGETS;
43 typedef struct _action ACTION;
44 typedef struct _actions ACTIONS;
45 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) */
68 /* ACTIONS - a chain of ACTIONs */
69 struct _actions {
70 ACTIONS *next;
71 ACTIONS *tail; /* valid only for head */
72 ACTION *action;
75 /* ACTION - a RULE instance with targets and sources */
76 struct _action {
77 RULE *rule;
78 TARGETS *targets;
79 TARGETS *sources; /* aka $(>) */
80 char running; /* has been started */
81 char status; /* see TARGET status */
84 /* SETTINGS - variables to set when executing a TARGET's ACTIONS */
85 struct _settings {
86 SETTINGS *next;
87 const char *symbol; /* symbol name for var_set() */
88 LIST *value; /* symbol value for var_set() */
91 /* TARGETS - a chain of TARGETs */
92 struct _targets {
93 TARGETS *next;
94 TARGETS *tail; /* valid only for head */
95 TARGET *target;
98 /* TARGET - a file or "thing" that can be built */
99 enum {
100 T_FLAG_TEMP = 0x01, /* TEMPORARY applied */
101 T_FLAG_NOCARE = 0x02, /* NOCARE applied */
102 T_FLAG_NOTFILE = 0x04, /* NOTFILE applied */
103 T_FLAG_TOUCHED = 0x08, /* ALWAYS applied or -t target */
104 T_FLAG_LEAVES = 0x10, /* LEAVES applied */
105 T_FLAG_NOUPDATE = 0x20, /* NOUPDATE applied */
106 T_FLAG_INTERNAL = 0x40, /* internal INCLUDES node */
108 T_FLAG_FORCECARE= 0x100
111 enum {
112 T_BIND_UNBOUND, /* a disembodied name */
113 T_BIND_MISSING, /* couldn't find real file */
114 T_BIND_PARENTS, /* using parent's timestamp */
115 T_BIND_EXISTS /* real file, timestamp valid */
118 enum {
119 T_FATE_INIT, /* nothing done to target */
120 T_FATE_MAKING, /* make0(target) on stack */
122 T_FATE_STABLE, /* target didn't need updating */
123 T_FATE_NEWER, /* target newer than parent */
125 T_FATE_SPOIL, /* >= SPOIL rebuilds parents */
126 T_FATE_ISTMP=T_FATE_SPOIL, /* unneeded temp target oddly present */
128 T_FATE_BUILD, /* >= BUILD rebuilds target */
129 T_FATE_TOUCHED = T_FATE_BUILD, /* manually touched with -t */
130 T_FATE_MISSING, /* is missing, needs updating */
131 T_FATE_NEEDTMP, /* missing temp that must be rebuild */
132 T_FATE_OUTDATED, /* is out of date, needs updating */
133 T_FATE_UPDATE, /* deps updated, needs updating */
135 T_FATE_BROKEN, /* >= BROKEN ruins parents */
136 T_FATE_CANTFIND = T_FATE_BROKEN, /* no rules to make missing target */
137 T_FATE_CANTMAKE /* can't find dependents */
140 enum {
141 T_MAKE_INIT, /* make1(target) not yet called */
142 T_MAKE_ONSTACK, /* make1(target) on stack */
143 T_MAKE_ACTIVE, /* make1(target) in make1b() */
144 T_MAKE_RUNNING, /* make1(target) running commands */
145 T_MAKE_DONE /* make1(target) done */
146 #ifdef JAM_OPT_SEMAPHORE
147 ,T_MAKE_SEMAPHORE /* special target type for semaphores */
148 #endif
151 struct _target {
152 const char *name;
153 const char *boundname; /* if search() relocates target */
154 ACTIONS *actions; /* rules to execute, if any */
155 SETTINGS *settings; /* variables to define */
157 char flags; /* status info (T_FLAG_XXX) */
159 char binding; /* how target relates to real file (T_BIND_XXX) */
161 TARGETS *depends; /* dependencies */
162 TARGET *includes; /* includes */
164 time_t time; /* update time */
165 time_t leaf; /* update time of leaf sources */
166 char fate; /* make0()'s diagnosis (T_FATE_XXX) */
168 char progress; /* tracks make1() progress (T_MAKE_XXX)*/
170 #ifdef JAM_OPT_SEMAPHORE
171 TARGET *semaphore; /* used in serialization */
172 #endif
174 char status; /* execcmd() result */
176 int asynccnt; /* child deps outstanding */
177 TARGETS *parents; /* used by make1() for completion */
178 char *cmds; /* type-punned command list */
182 extern int haverule (const char *rulename);
183 extern RULE *findrule (const char *rulename); /* can return NULL */
184 extern RULE *bindrule (const char *rulename);
185 extern TARGET *bindtarget (const char *targetname);
186 extern TARGET *copytarget (const TARGET *t);
187 extern void touchtarget (const char *t);
188 extern TARGETS *targetlist (TARGETS *chain, LIST *targets);
189 extern TARGETS *targetentry (TARGETS *chain, TARGET *target);
190 extern TARGETS *targetchain (TARGETS *chain, TARGETS *targets);
191 extern ACTIONS *actionlist (ACTIONS *chain, ACTION *action);
192 extern SETTINGS *addsettings (SETTINGS *v, int setflag, const char *sym, LIST *val);
193 extern SETTINGS *copysettings (SETTINGS *v);
194 extern void pushsettings (SETTINGS *v);
195 extern void popsettings (SETTINGS *v);
196 extern void freesettings (SETTINGS *v);
197 extern void donerules (void);
199 extern int iteraterules (hash_iterator_cb itercb, void *udata);
202 #endif