fixed pkg-config rule
[k8jam.git] / src / rules.h
blob19a23cab2ef334af24694491a4515c187c2de40f
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
40 #include "hash.h"
43 typedef struct _rule RULE;
44 typedef struct _target TARGET;
45 typedef struct _targets TARGETS;
46 typedef struct _action ACTION;
47 typedef struct _actions ACTIONS;
48 typedef struct _settings SETTINGS ;
51 /* RULE - a generic jam rule, the product of RULE and ACTIONS */
52 enum {
53 RULE_UPDATED = 0x01, /* $(>) is updated sources only */
54 RULE_TOGETHER = 0x02, /* combine actions on single target */
55 RULE_IGNORE = 0x04, /* ignore return status of executes */
56 RULE_QUIETLY = 0x08, /* don't mention it unless verbose */
57 RULE_PIECEMEAL= 0x10, /* split exec so each $(>) is small */
58 RULE_EXISTING = 0x20, /* $(>) is pre-exisitng sources only */
59 RULE_MAXLINE = 0x40 /* cmd specific maxline (last) */
62 struct _rule {
63 const char *name;
64 PARSE *procedure; /* parse tree from RULE */
65 const char *actions; /* command string from ACTIONS */
66 LIST *bindlist; /* variable to bind for actions */
67 LIST *params; /* bind args to local vars */
68 int flags; /* modifiers on ACTIONS (RULE_XXX) */
71 /* ACTIONS - a chain of ACTIONs */
72 struct _actions {
73 ACTIONS *next;
74 ACTIONS *tail; /* valid only for head */
75 ACTION *action;
78 /* ACTION - a RULE instance with targets and sources */
79 struct _action {
80 RULE *rule;
81 TARGETS *targets;
82 TARGETS *sources; /* aka $(>) */
83 char running; /* has been started */
84 char status; /* see TARGET status */
87 /* SETTINGS - variables to set when executing a TARGET's ACTIONS */
88 struct _settings {
89 SETTINGS *next;
90 const char *symbol; /* symbol name for var_set() */
91 LIST *value; /* symbol value for var_set() */
94 /* TARGETS - a chain of TARGETs */
95 struct _targets {
96 TARGETS *next;
97 TARGETS *tail; /* valid only for head */
98 TARGET *target;
101 /* TARGET - a file or "thing" that can be built */
102 enum {
103 T_FLAG_TEMP = 0x01, /* TEMPORARY applied */
104 T_FLAG_NOCARE = 0x02, /* NOCARE applied */
105 T_FLAG_NOTFILE = 0x04, /* NOTFILE applied */
106 T_FLAG_TOUCHED = 0x08, /* ALWAYS applied or -t target */
107 T_FLAG_LEAVES = 0x10, /* LEAVES applied */
108 T_FLAG_NOUPDATE = 0x20, /* NOUPDATE applied */
109 T_FLAG_INTERNAL = 0x40, /* internal INCLUDES node */
111 T_FLAG_FORCECARE= 0x100
114 enum {
115 T_BIND_UNBOUND, /* a disembodied name */
116 T_BIND_MISSING, /* couldn't find real file */
117 T_BIND_PARENTS, /* using parent's timestamp */
118 T_BIND_EXISTS /* real file, timestamp valid */
121 enum {
122 T_FATE_INIT, /* nothing done to target */
123 T_FATE_MAKING, /* make0(target) on stack */
125 T_FATE_STABLE, /* target didn't need updating */
126 T_FATE_NEWER, /* target newer than parent */
128 T_FATE_SPOIL, /* >= SPOIL rebuilds parents */
129 T_FATE_ISTMP=T_FATE_SPOIL, /* unneeded temp target oddly present */
131 T_FATE_BUILD, /* >= BUILD rebuilds target */
132 T_FATE_TOUCHED = T_FATE_BUILD, /* manually touched with -t */
133 T_FATE_MISSING, /* is missing, needs updating */
134 T_FATE_NEEDTMP, /* missing temp that must be rebuild */
135 T_FATE_OUTDATED, /* is out of date, needs updating */
136 T_FATE_UPDATE, /* deps updated, needs updating */
138 T_FATE_BROKEN, /* >= BROKEN ruins parents */
139 T_FATE_CANTFIND = T_FATE_BROKEN, /* no rules to make missing target */
140 T_FATE_CANTMAKE /* can't find dependents */
143 enum {
144 T_MAKE_INIT, /* make1(target) not yet called */
145 T_MAKE_ONSTACK, /* make1(target) on stack */
146 T_MAKE_ACTIVE, /* make1(target) in make1b() */
147 T_MAKE_RUNNING, /* make1(target) running commands */
148 T_MAKE_DONE /* make1(target) done */
149 #ifdef JAM_OPT_SEMAPHORE
150 ,T_MAKE_SEMAPHORE /* special target type for semaphores */
151 #endif
154 struct _target {
155 const char *name;
156 const char *boundname; /* if search() relocates target */
157 ACTIONS *actions; /* rules to execute, if any */
158 SETTINGS *settings; /* variables to define */
160 char flags; /* status info (T_FLAG_XXX) */
162 char binding; /* how target relates to real file (T_BIND_XXX) */
164 TARGETS *depends; /* dependencies */
165 TARGET *includes; /* includes */
167 time_t time; /* update time */
168 time_t leaf; /* update time of leaf sources */
169 char fate; /* make0()'s diagnosis (T_FATE_XXX) */
171 char progress; /* tracks make1() progress (T_MAKE_XXX)*/
173 #ifdef JAM_OPT_SEMAPHORE
174 TARGET *semaphore; /* used in serialization */
175 #endif
177 char status; /* execcmd() result */
179 int asynccnt; /* child deps outstanding */
180 TARGETS *parents; /* used by make1() for completion */
181 char *cmds; /* type-punned command list */
185 extern int haverule (const char *rulename);
186 extern RULE *findrule (const char *rulename); /* can return NULL */
187 extern RULE *bindrule (const char *rulename);
188 extern TARGET *bindtarget (const char *targetname);
189 extern TARGET *copytarget (const TARGET *t);
190 extern void touchtarget (const char *t);
191 extern TARGETS *targetlist (TARGETS *chain, LIST *targets);
192 extern TARGETS *targetentry (TARGETS *chain, TARGET *target);
193 extern TARGETS *targetchain (TARGETS *chain, TARGETS *targets);
194 extern ACTIONS *actionlist (ACTIONS *chain, ACTION *action);
195 extern SETTINGS *addsettings (SETTINGS *v, int setflag, const char *sym, LIST *val);
196 extern SETTINGS *copysettings (SETTINGS *v);
197 extern void pushsettings (SETTINGS *v);
198 extern void popsettings (SETTINGS *v);
199 extern void freesettings (SETTINGS *v);
200 extern void donerules (void);
202 extern int iteraterules (HashIteratorCB itercb, void *udata);
205 #endif