2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
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
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
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
;
49 /* RULE - a generic jam rule, the product of RULE and ACTIONS */
51 RULE_UPDATED
= 0x01, /* $(>) is updated sources only */
52 RULE_TOGETHER
= 0x02, /* combine actions on single target */
53 RULE_IGNORE
= 0x04, /* ignore return status of executes */
54 RULE_QUIETLY
= 0x08, /* don't mention it unless verbose */
55 RULE_PIECEMEAL
= 0x10, /* split exec so each $(>) is small */
56 RULE_EXISTING
= 0x20, /* $(>) is pre-exisitng sources only */
57 RULE_MAXLINE
= 0x40 /* cmd specific maxline (last) */
62 PARSE
*procedure
; /* parse tree from RULE */
63 const char *actions
; /* command string from ACTIONS */
64 LIST
*bindlist
; /* variable to bind for actions */
65 LIST
*params
; /* bind args to local vars */
66 int flags
; /* modifiers on ACTIONS (RULE_XXX) */
70 /* ACTIONS - a chain of ACTIONs */
73 ACTIONS
*tail
; /* valid only for head */
77 /* ACTION - a RULE instance with targets and sources */
81 TARGETS
*sources
; /* aka $(>) */
82 char running
; /* has been started */
83 char status
; /* see TARGET status */
86 /* SETTINGS - variables to set when executing a TARGET's ACTIONS */
89 const char *symbol
; /* symbol name for var_set() */
90 LIST
*value
; /* symbol value for var_set() */
93 /* TARGETS - a chain of TARGETs */
96 TARGETS
*tail
; /* valid only for head */
100 /* TARGET - a file or "thing" that can be built */
102 T_FLAG_TEMP
= 0x01, /* TEMPORARY applied */
103 T_FLAG_NOCARE
= 0x02, /* NOCARE applied */
104 T_FLAG_NOTFILE
= 0x04, /* NOTFILE applied */
105 T_FLAG_TOUCHED
= 0x08, /* ALWAYS applied or -t target */
106 T_FLAG_LEAVES
= 0x10, /* LEAVES applied */
107 T_FLAG_NOUPDATE
= 0x20, /* NOUPDATE applied */
108 T_FLAG_INTERNAL
= 0x40, /* internal INCLUDES node */
110 T_FLAG_FORCECARE
= 0x100
114 T_BIND_UNBOUND
, /* a disembodied name */
115 T_BIND_MISSING
, /* couldn't find real file */
116 T_BIND_PARENTS
, /* using parent's timestamp */
117 T_BIND_EXISTS
/* real file, timestamp valid */
121 T_FATE_INIT
, /* nothing done to target */
122 T_FATE_MAKING
, /* make0(target) on stack */
124 T_FATE_STABLE
, /* target didn't need updating */
125 T_FATE_NEWER
, /* target newer than parent */
127 T_FATE_SPOIL
, /* >= SPOIL rebuilds parents */
128 T_FATE_ISTMP
=T_FATE_SPOIL
, /* unneeded temp target oddly present */
130 T_FATE_BUILD
, /* >= BUILD rebuilds target */
131 T_FATE_TOUCHED
= T_FATE_BUILD
, /* manually touched with -t */
132 T_FATE_MISSING
, /* is missing, needs updating */
133 T_FATE_NEEDTMP
, /* missing temp that must be rebuild */
134 T_FATE_OUTDATED
, /* is out of date, needs updating */
135 T_FATE_UPDATE
, /* deps updated, needs updating */
137 T_FATE_BROKEN
, /* >= BROKEN ruins parents */
138 T_FATE_CANTFIND
= T_FATE_BROKEN
, /* no rules to make missing target */
139 T_FATE_CANTMAKE
/* can't find dependents */
143 T_MAKE_INIT
, /* make1(target) not yet called */
144 T_MAKE_ONSTACK
, /* make1(target) on stack */
145 T_MAKE_ACTIVE
, /* make1(target) in make1b() */
146 T_MAKE_RUNNING
, /* make1(target) running commands */
147 T_MAKE_DONE
/* make1(target) done */
148 #ifdef JAM_OPT_SEMAPHORE
149 ,T_MAKE_SEMAPHORE
/* special target type for semaphores */
155 const char *boundname
; /* if search() relocates target */
156 ACTIONS
*actions
; /* rules to execute, if any */
157 SETTINGS
*settings
; /* variables to define */
159 char flags
; /* status info (T_FLAG_XXX) */
161 char binding
; /* how target relates to real file (T_BIND_XXX) */
163 TARGETS
*depends
; /* dependencies */
164 TARGET
*includes
; /* includes */
166 time_t time
; /* update time */
167 time_t leaf
; /* update time of leaf sources */
168 char fate
; /* make0()'s diagnosis (T_FATE_XXX) */
170 char progress
; /* tracks make1() progress (T_MAKE_XXX)*/
172 #ifdef JAM_OPT_SEMAPHORE
173 TARGET
*semaphore
; /* used in serialization */
176 char status
; /* execcmd() result */
178 int asynccnt
; /* child deps outstanding */
179 TARGETS
*parents
; /* used by make1() for completion */
180 char *cmds
; /* type-punned command list */
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);