00001 /* 00002 * Copyright 1993, 1995 Christopher Seiwald. 00003 * 00004 * This file is part of Jam - see jam.c for Copyright information. 00005 */ 00006 00007 /* 00008 * rules.h - targets, rules, and related information 00009 * 00010 * This file describes the structures holding the targets, rules, and 00011 * related information accumulated by interpreting the statements 00012 * of the jam files. 00013 * 00014 * The following are defined: 00015 * 00016 * RULE - a generic jam rule, the product of RULE and ACTIONS 00017 * ACTIONS - a chain of ACTIONs 00018 * ACTION - a RULE instance with targets and sources 00019 * TARGETS - a chain of TARGETs 00020 * TARGET - a file or "thing" that can be built 00021 * SETTINGS - variables to set when executing a TARGET's ACTIONS 00022 * 00023 * Changes: 00024 * 00025 * 01/14/03 (seiwald) - fix includes fix with new internal includes TARGET 00026 * 12/17/02 (seiwald) - new copysettings() to protect target-specific vars 00027 * 12/03/02 (seiwald) - fix odd includes support by grafting them onto depends 00028 * 11/04/02 (seiwald) - const-ing for string literals 00029 * 07/17/02 (seiwald) - TEMPORARY sources for headers now get built 00030 * 06/21/02 (seiwald) - support for named parameters 00031 * 02/28/02 (seiwald) - merge EXEC_xxx flags in with RULE_xxx 00032 * 02/14/95 (seiwald) - new NOUPDATE modifier on targets. 00033 * 02/02/95 (seiwald) - new LEAVES modifier on targets. 00034 * 01/19/95 (seiwald) - split DONTKNOW into CANTFIND/CANTMAKE. 00035 * 12/20/94 (seiwald) - NOTIME renamed NOTFILE. 00036 * 06/01/94 (seiwald) - new 'actions existing' does existing sources 00037 * 04/12/94 (seiwald) - actionlist() now just appends a single action. 00038 * 04/11/94 (seiwald) - Combined deps & headers into deps[2] in TARGET. 00039 */ 00040 00041 typedef struct _rule RULE; 00042 typedef struct _target TARGET; 00043 typedef struct _targets TARGETS; 00044 typedef struct _action ACTION; 00045 typedef struct _actions ACTIONS; 00046 typedef struct _settings SETTINGS ; 00047 00048 /* RULE - a generic jam rule, the product of RULE and ACTIONS */ 00049 00050 struct _rule { 00051 const char *name; 00052 PARSE *procedure; /* parse tree from RULE */ 00053 const char *actions; /* command string from ACTIONS */ 00054 LIST *bindlist; /* variable to bind for actions */ 00055 LIST *params; /* bind args to local vars */ 00056 int flags; /* modifiers on ACTIONS */ 00057 00058 # define RULE_UPDATED 0x01 /* $(>) is updated sources only */ 00059 # define RULE_TOGETHER 0x02 /* combine actions on single target */ 00060 # define RULE_IGNORE 0x04 /* ignore return status of executes */ 00061 # define RULE_QUIETLY 0x08 /* don't mention it unless verbose */ 00062 # define RULE_PIECEMEAL 0x10 /* split exec so each $(>) is small */ 00063 # define RULE_EXISTING 0x20 /* $(>) is pre-exisitng sources only */ 00064 # define RULE_MAXLINE 0x40 /* cmd specific maxline (last) */ 00065 00066 } ; 00067 00068 /* ACTIONS - a chain of ACTIONs */ 00069 00070 struct _actions { 00071 ACTIONS *next; 00072 ACTIONS *tail; /* valid only for head */ 00073 ACTION *action; 00074 } ; 00075 00076 /* ACTION - a RULE instance with targets and sources */ 00077 00078 struct _action { 00079 RULE *rule; 00080 TARGETS *targets; 00081 TARGETS *sources; /* aka $(>) */ 00082 char running; /* has been started */ 00083 char status; /* see TARGET status */ 00084 } ; 00085 00086 /* SETTINGS - variables to set when executing a TARGET's ACTIONS */ 00087 00088 struct _settings { 00089 SETTINGS *next; 00090 const char *symbol; /* symbol name for var_set() */ 00091 LIST *value; /* symbol value for var_set() */ 00092 } ; 00093 00094 /* TARGETS - a chain of TARGETs */ 00095 00096 struct _targets { 00097 TARGETS *next; 00098 TARGETS *tail; /* valid only for head */ 00099 TARGET *target; 00100 char needs ; /* set if this target was depended via the Needs rule */ 00101 } ; 00102 00103 /* TARGET - a file or "thing" that can be built */ 00104 00105 struct _target { 00106 const char *name; 00107 const char *boundname; /* if search() relocates target */ 00108 ACTIONS *actions; /* rules to execute, if any */ 00109 SETTINGS *settings; /* variables to define */ 00110 00111 char flags; /* status info */ 00112 00113 # define T_FLAG_TEMP 0x01 /* TEMPORARY applied */ 00114 # define T_FLAG_NOCARE 0x02 /* NOCARE applied */ 00115 # define T_FLAG_NOTFILE 0x04 /* NOTFILE applied */ 00116 # define T_FLAG_TOUCHED 0x08 /* ALWAYS applied or -t target */ 00117 # define T_FLAG_LEAVES 0x10 /* LEAVES applied */ 00118 # define T_FLAG_NOUPDATE 0x20 /* NOUPDATE applied */ 00119 # define T_FLAG_INTERNAL 0x40 /* internal INCLUDES node */ 00120 00121 char binding; /* how target relates to real file */ 00122 00123 # define T_BIND_UNBOUND 0 /* a disembodied name */ 00124 # define T_BIND_MISSING 1 /* couldn't find real file */ 00125 # define T_BIND_PARENTS 2 /* using parent's timestamp */ 00126 # define T_BIND_EXISTS 3 /* real file, timestamp valid */ 00127 00128 TARGETS *depends; /* dependencies */ 00129 TARGET *includes; /* includes */ 00130 00131 time_t time; /* update time */ 00132 time_t leaf; /* update time of leaf sources */ 00133 char fate; /* make0()'s diagnosis */ 00134 00135 # define T_FATE_INIT 0 /* nothing done to target */ 00136 # define T_FATE_MAKING 1 /* make0(target) on stack */ 00137 00138 # define T_FATE_STABLE 2 /* target didn't need updating */ 00139 # define T_FATE_NEWER 3 /* target newer than parent */ 00140 00141 # define T_FATE_SPOIL 4 /* >= SPOIL rebuilds parents */ 00142 # define T_FATE_ISTMP 4 /* unneeded temp target oddly present */ 00143 00144 # define T_FATE_BUILD 5 /* >= BUILD rebuilds target */ 00145 # define T_FATE_TOUCHED 5 /* manually touched with -t */ 00146 # define T_FATE_MISSING 6 /* is missing, needs updating */ 00147 # define T_FATE_NEEDTMP 7 /* missing temp that must be rebuild */ 00148 # define T_FATE_OUTDATED 8 /* is out of date, needs updating */ 00149 # define T_FATE_UPDATE 9 /* deps updated, needs updating */ 00150 00151 # define T_FATE_BROKEN 10 /* >= BROKEN ruins parents */ 00152 # define T_FATE_CANTFIND 10 /* no rules to make missing target */ 00153 # define T_FATE_CANTMAKE 11 /* can't find dependents */ 00154 00155 char progress; /* tracks make1() progress */ 00156 00157 # define T_MAKE_INIT 0 /* make1(target) not yet called */ 00158 # define T_MAKE_ONSTACK 1 /* make1(target) on stack */ 00159 # define T_MAKE_ACTIVE 2 /* make1(target) in make1b() */ 00160 # define T_MAKE_RUNNING 3 /* make1(target) running commands */ 00161 # define T_MAKE_DONE 4 /* make1(target) done */ 00162 00163 char status; /* execcmd() result */ 00164 00165 int asynccnt; /* child deps outstanding */ 00166 TARGETS *parents; /* used by make1() for completion */ 00167 char *cmds; /* type-punned command list */ 00168 } ; 00169 00170 RULE *bindrule( const char *rulename ); 00171 TARGET *bindtarget( const char *targetname ); 00172 TARGET *copytarget( const TARGET *t ); 00173 void touchtarget( const char *t ); 00174 TARGETS *targetlist( TARGETS *chain, LIST *targets, char needs ); 00175 TARGETS *targetentry( TARGETS *chain, TARGET *target, char needs ); 00176 TARGETS *targetchain( TARGETS *chain, TARGETS *targets ); 00177 ACTIONS *actionlist( ACTIONS *chain, ACTION *action ); 00178 SETTINGS *addsettings( SETTINGS *v, int setflag, const char *sym, LIST *val ); 00179 SETTINGS *copysettings( SETTINGS *v ); 00180 void pushsettings( SETTINGS *v ); 00181 void popsettings( SETTINGS *v ); 00182 void freesettings( SETTINGS *v ); 00183 void donerules();