you can list libxyz.a in Main rule now, this will work exactly as LinkLibraries
[k8jam.git] / src / rules.h
blob03d3e7527f8121dccbc39d9e9bda44c69431834d
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, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * rules.h - targets, rules, and related information
21 * This file describes the structures holding the targets, rules, and
22 * related information accumulated by interpreting the statements
23 * of the jam files.
25 * The following are defined:
27 * RULE - a generic jam rule, the product of RULE and ACTIONS
28 * ACTIONS - a chain of ACTIONs
29 * ACTION - a RULE instance with targets and sources
30 * SETTINGS - variables to set when executing a TARGET's ACTIONS
31 * TARGETS - a chain of TARGETs
32 * TARGET - a file or "thing" that can be built
34 #ifndef JAMH_RULES_H
35 #define JAMH_RULES_H
37 #include "jam.h"
38 #include "hash.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 ;
49 /* RULE - a generic jam rule, the product of RULE and ACTIONS */
50 enum {
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) */
60 struct _rule {
61 const char *name;
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) */
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 */
109 T_FLAG_FORCECARE= 0x100
112 enum {
113 T_BIND_UNBOUND, /* a disembodied name */
114 T_BIND_MISSING, /* couldn't find real file */
115 T_BIND_PARENTS, /* using parent's timestamp */
116 T_BIND_EXISTS /* real file, timestamp valid */
119 enum {
120 T_FATE_INIT, /* nothing done to target */
121 T_FATE_MAKING, /* make0(target) on stack */
123 T_FATE_STABLE, /* target didn't need updating */
124 T_FATE_NEWER, /* target newer than parent */
126 T_FATE_SPOIL, /* >= SPOIL rebuilds parents */
127 T_FATE_ISTMP=T_FATE_SPOIL, /* unneeded temp target oddly present */
129 T_FATE_BUILD, /* >= BUILD rebuilds target */
130 T_FATE_TOUCHED = T_FATE_BUILD, /* manually touched with -t */
131 T_FATE_MISSING, /* is missing, needs updating */
132 T_FATE_NEEDTMP, /* missing temp that must be rebuild */
133 T_FATE_OUTDATED, /* is out of date, needs updating */
134 T_FATE_UPDATE, /* deps updated, needs updating */
136 T_FATE_BROKEN, /* >= BROKEN ruins parents */
137 T_FATE_CANTFIND = T_FATE_BROKEN, /* no rules to make missing target */
138 T_FATE_CANTMAKE /* can't find dependents */
141 enum {
142 T_MAKE_INIT, /* make1(target) not yet called */
143 T_MAKE_ONSTACK, /* make1(target) on stack */
144 T_MAKE_ACTIVE, /* make1(target) in make1b() */
145 T_MAKE_RUNNING, /* make1(target) running commands */
146 T_MAKE_DONE /* make1(target) done */
147 #ifdef JAM_OPT_SEMAPHORE
148 ,T_MAKE_SEMAPHORE /* special target type for semaphores */
149 #endif
152 struct _target {
153 const char *name;
154 const char *boundname; /* if search() relocates target */
155 ACTIONS *actions; /* rules to execute, if any */
156 SETTINGS *settings; /* variables to define */
158 char flags; /* status info (T_FLAG_XXX) */
160 char binding; /* how target relates to real file (T_BIND_XXX) */
162 TARGETS *depends; /* dependencies */
163 TARGET *includes; /* includes */
165 time_t time; /* update time */
166 time_t leaf; /* update time of leaf sources */
167 char fate; /* make0()'s diagnosis (T_FATE_XXX) */
169 char progress; /* tracks make1() progress (T_MAKE_XXX)*/
171 #ifdef JAM_OPT_SEMAPHORE
172 TARGET *semaphore; /* used in serialization */
173 #endif
175 char status; /* execcmd() result */
177 int asynccnt; /* child deps outstanding */
178 TARGETS *parents; /* used by make1() for completion */
179 char *cmds; /* type-punned command list */
183 extern int haverule (const char *rulename);
184 extern RULE *findrule (const char *rulename); /* can return NULL */
185 extern RULE *bindrule (const char *rulename);
186 extern TARGET *bindtarget (const char *targetname);
187 extern TARGET *copytarget (const TARGET *t);
188 extern void touchtarget (const char *t);
189 extern TARGETS *targetlist (TARGETS *chain, LIST *targets);
190 extern TARGETS *targetentry (TARGETS *chain, TARGET *target);
191 extern TARGETS *targetchain (TARGETS *chain, TARGETS *targets);
192 extern ACTIONS *actionlist (ACTIONS *chain, ACTION *action);
193 extern SETTINGS *addsettings (SETTINGS *v, int setflag, const char *sym, LIST *val);
194 extern SETTINGS *copysettings (SETTINGS *v);
195 extern void pushsettings (SETTINGS *v);
196 extern void popsettings (SETTINGS *v);
197 extern void freesettings (SETTINGS *v);
198 extern void donerules (void);
200 extern int iteraterules (hash_iterator_cb itercb, void *udata);
203 #endif