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