/* * Copyright 1993, 1995 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ /* * rules.h - targets, rules, and related information * * This file describes the structures holding the targets, rules, and * related information accumulated by interpreting the statements * of the jam files. * * The following are defined: * * RULE - a generic jam rule, the product of RULE and ACTIONS * ACTIONS - a chain of ACTIONs * ACTION - a RULE instance with targets and sources * SETTINGS - variables to set when executing a TARGET's ACTIONS * TARGETS - a chain of TARGETs * TARGET - a file or "thing" that can be built * * 04/11/94 (seiwald) - Combined deps & headers into deps[2] in TARGET. * 04/12/94 (seiwald) - actionlist() now just appends a single action. * 06/01/94 (seiwald) - new 'actions existing' does existing sources * 12/20/94 (seiwald) - NOTIME renamed NOTFILE. * 01/19/95 (seiwald) - split DONTKNOW into CANTFIND/CANTMAKE. * 02/02/95 (seiwald) - new LEAVES modifier on targets. * 02/14/95 (seiwald) - new NOUPDATE modifier on targets. * 02/28/02 (seiwald) - merge EXEC_xxx flags in with RULE_xxx * 06/21/02 (seiwald) - support for named parameters * 07/17/02 (seiwald) - TEMPORARY sources for headers now get built * 11/04/02 (seiwald) - const-ing for string literals * 12/03/02 (seiwald) - fix odd includes support by grafting them onto depends * 12/17/02 (seiwald) - new copysettings() to protect target-specific vars * 01/14/03 (seiwald) - fix includes fix with new internal includes TARGET */ typedef struct _rule RULE; typedef struct _target TARGET; typedef struct _targets TARGETS; typedef struct _action ACTION; typedef struct _actions ACTIONS; typedef struct _settings SETTINGS ; /* RULE - a generic jam rule, the product of RULE and ACTIONS */ struct _rule { const char *name; PARSE *procedure; /* parse tree from RULE */ const char *actions; /* command string from ACTIONS */ LIST *bindlist; /* variable to bind for actions */ LIST *params; /* bind args to local vars */ int flags; /* modifiers on ACTIONS */ # define RULE_UPDATED 0x01 /* $(>) is updated sources only */ # define RULE_TOGETHER 0x02 /* combine actions on single target */ # define RULE_IGNORE 0x04 /* ignore return status of executes */ # define RULE_QUIETLY 0x08 /* don't mention it unless verbose */ # define RULE_PIECEMEAL 0x10 /* split exec so each $(>) is small */ # define RULE_EXISTING 0x20 /* $(>) is pre-exisitng sources only */ # define RULE_MAXLINE 0x40 /* cmd specific maxline (last) */ } ; /* ACTIONS - a chain of ACTIONs */ struct _actions { ACTIONS *next; ACTIONS *tail; /* valid only for head */ ACTION *action; } ; /* ACTION - a RULE instance with targets and sources */ struct _action { RULE *rule; TARGETS *targets; TARGETS *sources; /* aka $(>) */ char running; /* has been started */ char status; /* see TARGET status */ } ; /* SETTINGS - variables to set when executing a TARGET's ACTIONS */ struct _settings { SETTINGS *next; const char *symbol; /* symbol name for var_set() */ LIST *value; /* symbol value for var_set() */ } ; /* TARGETS - a chain of TARGETs */ struct _targets { TARGETS *next; TARGETS *tail; /* valid only for head */ TARGET *target; } ; /* TARGET - a file or "thing" that can be built */ struct _target { const char *name; const char *boundname; /* if search() relocates target */ ACTIONS *actions; /* rules to execute, if any */ SETTINGS *settings; /* variables to define */ char flags; /* status info */ # define T_FLAG_TEMP 0x01 /* TEMPORARY applied */ # define T_FLAG_NOCARE 0x02 /* NOCARE applied */ # define T_FLAG_NOTFILE 0x04 /* NOTFILE applied */ # define T_FLAG_TOUCHED 0x08 /* ALWAYS applied or -t target */ # define T_FLAG_LEAVES 0x10 /* LEAVES applied */ # define T_FLAG_NOUPDATE 0x20 /* NOUPDATE applied */ # define T_FLAG_INTERNAL 0x40 /* internal INCLUDES node */ char binding; /* how target relates to real file */ # define T_BIND_UNBOUND 0 /* a disembodied name */ # define T_BIND_MISSING 1 /* couldn't find real file */ # define T_BIND_PARENTS 2 /* using parent's timestamp */ # define T_BIND_EXISTS 3 /* real file, timestamp valid */ TARGETS *depends; /* dependencies */ TARGET *includes; /* includes */ time_t time; /* update time */ time_t leaf; /* update time of leaf sources */ char fate; /* make0()'s diagnosis */ # define T_FATE_INIT 0 /* nothing done to target */ # define T_FATE_MAKING 1 /* make0(target) on stack */ # define T_FATE_STABLE 2 /* target didn't need updating */ # define T_FATE_NEWER 3 /* target newer than parent */ # define T_FATE_SPOIL 4 /* >= SPOIL rebuilds parents */ # define T_FATE_ISTMP 4 /* unneeded temp target oddly present */ # define T_FATE_BUILD 5 /* >= BUILD rebuilds target */ # define T_FATE_TOUCHED 5 /* manually touched with -t */ # define T_FATE_MISSING 6 /* is missing, needs updating */ # define T_FATE_NEEDTMP 7 /* missing temp that must be rebuild */ # define T_FATE_OUTDATED 8 /* is out of date, needs updating */ # define T_FATE_UPDATE 9 /* deps updated, needs updating */ # define T_FATE_BROKEN 10 /* >= BROKEN ruins parents */ # define T_FATE_CANTFIND 10 /* no rules to make missing target */ # define T_FATE_CANTMAKE 11 /* can't find dependents */ char progress; /* tracks make1() progress */ # define T_MAKE_INIT 0 /* make1(target) not yet called */ # define T_MAKE_ONSTACK 1 /* make1(target) on stack */ # define T_MAKE_ACTIVE 2 /* make1(target) in make1b() */ # define T_MAKE_RUNNING 3 /* make1(target) running commands */ # define T_MAKE_DONE 4 /* make1(target) done */ char status; /* execcmd() result */ int asynccnt; /* child deps outstanding */ TARGETS *parents; /* used by make1() for completion */ char *cmds; /* type-punned command list */ } ; RULE *bindrule( const char *rulename ); TARGET *bindtarget( const char *targetname ); TARGET *copytarget( const TARGET *t ); void touchtarget( const char *t ); TARGETS *targetlist( TARGETS *chain, LIST *targets ); TARGETS *targetentry( TARGETS *chain, TARGET *target ); TARGETS *targetchain( TARGETS *chain, TARGETS *targets ); ACTIONS *actionlist( ACTIONS *chain, ACTION *action ); SETTINGS *addsettings( SETTINGS *v, int setflag, const char *sym, LIST *val ); SETTINGS *copysettings( SETTINGS *v ); void pushsettings( SETTINGS *v ); void popsettings( SETTINGS *v ); void freesettings( SETTINGS *v ); void donerules();
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#12 | 3065 | Perforce staff |
Support for 'actions ... maxline value', to set a command specific maxline (rather than the OS-specific maximum). Undocumented. |
||
#11 | 2614 | rmg |
Fix to includes of includes not being considered, broken by 2499. Details taken from email to jamming: The challenge is to make included includes appear as direct includes, so that they get considered. This used to work by recursion, because each TARGET node computed the summary of its includes -- the hfate and htime -- along with the summary of its dependents -- the fate and time. Alas, that previous arrangement confused make1() into treating headers as direct dependencies during the build phase. A.o | A.c -- A.h (Read depends down, includes across) (Failed build of A.h aborts build of A.c) The fix to the confused make1() problem was to consolidate the special handling of includes by having make0() tack onto a target's list of dependendies any of the target's dependents' includes. Unfortunately, this fix did not recurse: if the target's dependents' includes included other files, those files were not added to the target's dependencies. A.o | A.c -- A.h -- B.h -- C.h is rewritten to: A.o | \ A.c A.h -- B.h -- C.h (A.o depends on A.h, but not B.h or C.h. This is the current, broken state of jam 2.5rc1.) Matt's bugfix added some recursion at this point, by transitively appending includes' includes onto the includes chain. But, as he found out (and I did before), this can slow make0() down considerably, as typically header files all include each other and you wind up with lots of really long chains. A.o | A.c -- A.h -- B.h -- C.h is rewritten to: A.o | A.c -- A.h -- B.h -- C.h - B.h - C.h - C.h (Matt's fix: if the .h files include each other, the includes chains get very long.) The final(?) fix I have is relatively simple, but is an extra step: to have make0() replace a target's includes chain with a single pseudo-target whose dependencies are the original target's includes. That pseudo-target gets passed to make0(), which then recursively consolidates its fate and time. This then makes a target's includes fate and time available in a single target hanging off the original target. A.o | A.c -- A.h -- B.h -- C.h is rewritten to: A.o | \ A.c A.c-includes | \ A.h A.h-includes | \ B.h B.h-includes | C.h (New pseudo-target xxx-includes recursively consolidates fate and time of all included targets.) While this new scheme does add a node for every include file, it is linear, rather than exponential, and the time is pretty much neglible. User-visible bugfix not documented, because there is no place in RELNOTES for release-candidate fixes. Bumped patchlevel to 2.5rc2. |
||
#10 | 2559 | rmg |
Fix 'var on target ?= value' so that var is only set if it did not have a target-specific value. Previously, it would just overwrite the var's value. Bug fix documented in RELNOTES. === computer:1666: Change 39566 by seiwald@play-seiwald on 2002/12/27 14:44:01 |
||
#9 | 2529 | rmg |
Fix "on target" variables during header scan, from Matt Armstrong. Setting target-specific variables while under the influence of the target's target-specific variables caused the _global_ values to be modified. This happened both during header file scanning and with the "on target statement" syntax. The manifestation of this was if a file #included itself, HdrRule would accidentally set HDRRULE/HDRSCAN globally, and then all files (executables, etc) would get scanned for includes. While this borrows from Matt's fix, it is a slightly different implementation. User visible fix documented in RELNOTES. === computer:1666: Change 39095 by seiwald@play-seiwald on 2002/12/17 14:00:58 |
||
#8 | 2499 | rmg |
Fix 'includes' support so that included files aren't treated as direct dependencies during the command execution phase. If an included file failed to build, make1() would bypass the including file. Now make0() appends each child's 'includes' onto its own 'depends' list, eliminating 'includes'-specific code in make0() and make1(). This not only fixes the bug, but removes some complexity as well. Bug fix documented in RELNOTES. === computer:1666: Change 38399 by seiwald@play-seiwald on 2002/12/03 16:00:40 |
||
#7 | 2493 | rmg |
Rewrite the past: update all jam's source with comments to reflect changes since about 2.3, very early 2001. Whitespace only change. === computer:1666: Change 37660 by seiwald@play-seiwald on 2002/11/06 22:41:35 Note: I regenerated jamgram.c on my linux 7.3 system prior to the submit, since patch was so unhappy trying to lay down the changes from Christopher's change. Presumably this is just due to different yacc/bison/whatever particulars on the system where Christopher made the changes originally. - rmg |
||
#6 | 2491 | rmg |
Some consting in jam to make it more compilable by C++ compilers. No functional change. === computer:1666: Change 37433 by perforce@perforce on 2002/10/30 16:08:51 Recreational const-ing of jam, for compilers that don't allow "string" to be passed as a non-const char *. This included a few places where we were modifying what could possibly have been read-only storage, oddly enough. No functional change. === computer:1666: Change 37602 by seiwald@play-seiwald on 2002/11/04 17:25:40 |
||
#5 | 2484 | rmg |
Rework make0() to consider headers when deciding whether to update a temporary source file. This makes it possible to have generated, temporary source files that must be regened because an included header has been updated. === computer:1666: Change 35018 by seiwald@play-seiwald on 2002/07/17 10:41:35 Followon to 35018: actually update a "needtmp" target (duh). === computer:1666: Change 35023 by seiwald@play-seiwald on 2002/07/17 11:10:16 Fix to 35018, which handled out-of-date header files built from temporary sources. Unfortunately, the change made circular header dependencies (which are legion) get reported. Now the circular dependency reporting is done in the call to make0() rather than at the beginning of make0(), and step 3b (the header recursion) simply skips that check. Change to unreleased behavior. === computer:1666: Change 36247 by seiwald@waffle-cyg-seiwald on 2002/09/16 16:15:10 |
||
#4 | 2482 | rmg |
Jam.html partial rewrite and the support for named parameters to rules. === computer:1666: Change 34516 by seiwald@play-seiwald on 2002/06/21 23:59:12 |
||
#3 | 1492 | Perforce staff |
Replace action modifiers EXEC_* from compile.h with RULE_* flags from rules.h. They've always been the same quantity defined in two places. Note that RULE_NEWSRCS is now RULE_UPDATED, to be consistent with 'actions updated'. No functional change. |
||
#2 | 486 | Perforce staff |
Jam 2.3. See RELNOTES for a list of changes from 2.2.x. Just about every source file was touched when jam got ANSI-fied. |
||
#1 | 2 | laura | Add Jam/MR 2.2 source |