The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rules.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 1993, 1995 Christopher Seiwald.
00003  *
00004  * This file is part of Jam - see jam.c for Copyright information.
00005  */
00006 
00007 /*  This file is ALSO:
00008  *  (C) Copyright David Abrahams 2001. Permission to copy, use,
00009  *  modify, sell and distribute this software is granted provided this
00010  *  copyright notice appears in all copies. This software is provided
00011  *  "as is" without express or implied warranty, and with no claim as
00012  *  to its suitability for any purpose.
00013  */
00014 
00015 #ifndef RULES_DWA_20011020_H
00016 # define RULES_DWA_20011020_H
00017 
00018 # include "modules.h"
00019 # include "jam.h"
00020 
00021 /*
00022  * rules.h -  targets, rules, and related information
00023  *
00024  * This file describes the structures holding the targets, rules, and
00025  * related information accumulated by interpreting the statements
00026  * of the jam files.
00027  *
00028  * The following are defined:
00029  *
00030  *      RULE - a generic jam rule, the product of RULE and ACTIONS 
00031  *      ACTIONS - a chain of ACTIONs 
00032  *      ACTION - a RULE instance with targets and sources 
00033  *      SETTINGS - variables to set when executing a TARGET's ACTIONS 
00034  *      TARGETS - a chain of TARGETs 
00035  *      TARGET - a file or "thing" that can be built 
00036  *
00037  * 04/11/94 (seiwald) - Combined deps & headers into deps[2] in TARGET.
00038  * 04/12/94 (seiwald) - actionlist() now just appends a single action.
00039  * 06/01/94 (seiwald) - new 'actions existing' does existing sources
00040  * 12/20/94 (seiwald) - NOTIME renamed NOTFILE.
00041  * 01/19/95 (seiwald) - split DONTKNOW into CANTFIND/CANTMAKE.
00042  * 02/02/95 (seiwald) - new LEAVES modifier on targets.
00043  * 02/14/95 (seiwald) - new NOUPDATE modifier on targets.
00044  */
00045 
00046 typedef struct _rule RULE;
00047 typedef struct _target TARGET;
00048 typedef struct _targets TARGETS;
00049 typedef struct _action ACTION;
00050 typedef struct _actions ACTIONS;
00051 typedef struct _settings SETTINGS ;
00052 
00053 /* RULE - a generic jam rule, the product of RULE and ACTIONS */
00054 
00055 /* A rule's argument list */
00056 struct argument_list
00057 {
00058     int reference_count;
00059     LOL data[1];
00060 };
00061 
00062 /* The build actions corresponding to a rule */
00063 struct rule_actions
00064 {
00065     int reference_count;
00066     char* command;       /* command string from ACTIONS */
00067     LIST* bindlist;
00068     int flags;          /* modifiers on ACTIONS */
00069 
00070 # define    RULE_NEWSRCS    0x01    /* $(>) is updated sources only */
00071 # define    RULE_TOGETHER   0x02    /* combine actions on single target */
00072 # define    RULE_IGNORE 0x04    /* ignore return status of executes */
00073 # define    RULE_QUIETLY    0x08    /* don't mention it unless verbose */
00074 # define    RULE_PIECEMEAL  0x10    /* split exec so each $(>) is small */
00075 # define    RULE_EXISTING   0x20    /* $(>) is pre-exisitng sources only */
00076 };
00077 
00078 typedef struct rule_actions rule_actions;
00079 typedef struct argument_list argument_list;
00080 
00081 struct _rule {
00082     char    *name;
00083     PARSE   *procedure;        /* parse tree from RULE */
00084     argument_list* arguments;  /* argument checking info, or NULL for unchecked */
00085     rule_actions* actions;     /* build actions, or NULL for no actions */
00086     module_t  *module;           /* module in which this rule is executed */
00087     int     exported;          /* nonzero if this rule is supposed to
00088                                 * appear in the global module and be
00089                                 * automatically imported into other modules
00090                                 */
00091 };
00092 
00093 /* ACTIONS - a chain of ACTIONs */
00094 
00095 struct _actions {
00096         ACTIONS *next;
00097         ACTIONS *tail;                  /* valid only for head */
00098         ACTION  *action;
00099 } ;
00100 
00101 /* ACTION - a RULE instance with targets and sources */
00102 
00103 struct _action {
00104         RULE    *rule;
00105         TARGETS *targets;
00106         TARGETS *sources;               /* aka $(>) */
00107         char    running;                /* has been started */
00108         char    status;                 /* see TARGET status */
00109 } ;
00110 
00111 /* SETTINGS - variables to set when executing a TARGET's ACTIONS */
00112 
00113 struct _settings {
00114         SETTINGS *next;
00115         char    *symbol;                /* symbol name for var_set() */
00116         LIST    *value;                 /* symbol value for var_set() */
00117 } ;
00118 
00119 /* TARGETS - a chain of TARGETs */
00120 
00121 struct _targets {
00122         TARGETS *next;
00123         TARGETS *tail;                  /* valid only for head */
00124         TARGET  *target;
00125 } ;
00126 
00127 /* TARGET - a file or "thing" that can be built */
00128 
00129 struct _target {
00130         char    *name;
00131         char    *boundname;             /* if search() relocates target */
00132         ACTIONS *actions;               /* rules to execute, if any */
00133         SETTINGS *settings;             /* variables to define */
00134 
00135         short flags;                    /* status info */
00136 
00137 # define        T_FLAG_TEMP     0x0001  /* TEMPORARY applied */
00138 # define        T_FLAG_NOCARE   0x0002  /* NOCARE applied */
00139 # define        T_FLAG_NOTFILE  0x0004  /* NOTFILE applied */
00140 # define        T_FLAG_TOUCHED  0x0008  /* ALWAYS applied or -t target */
00141 # define        T_FLAG_LEAVES   0x0010  /* LEAVES applied */
00142 # define        T_FLAG_NOUPDATE 0x0020  /* NOUPDATE applied */
00143 # define        T_FLAG_VISITED  0x0040    /* CWM: Used in debugging */
00144 
00145 /* this flag was added to support a new builtin rule named "RMBAD" */
00146 /* it is used to force removal of outdated targets whose dependencies
00147  * fail to build  */
00148     
00149 # define        T_FLAG_RMOLD    0x0080    /* RMBAD applied */
00150 
00151 /* this flag was added to support a new builting rule named "FAIL_EXPECTED" */
00152 /* it is used to indicate that the result of running a given action should  */
00153 /* be inverted (i.e. ok <=> fail). This is useful to launch certain test    */
00154 /* runs from a Jamfile..                                                    */
00155 /*                                                                          */
00156 # define        T_FLAG_FAIL_EXPECTED  0x0100  /* FAIL_EXPECTED applied */
00157 
00158 # define T_FLAG_INTERNAL 0x0200    /* internal INCLUDES node */
00159 
00160 
00161 
00162 #ifdef OPT_SEMAPHORE
00163 # define        T_MAKE_SEMAPHORE 5 /* Special target type for semaphores */
00164 #endif
00165 
00166 
00167         char    binding;                /* how target relates to real file */
00168 
00169 # define        T_BIND_UNBOUND  0       /* a disembodied name */
00170 # define        T_BIND_MISSING  1       /* couldn't find real file */
00171 #ifdef OPT_SEMAPHORE
00172         TARGET  *semaphore;             /* used in serialization */
00173 #endif
00174 # define        T_BIND_PARENTS  2       /* using parent's timestamp */
00175 # define        T_BIND_EXISTS   3       /* real file, timestamp valid */
00176 
00177         TARGETS         *depends;       /* dependencies */
00178         TARGET          *includes;      /* includes */
00179     TARGET        *original_target; /* original_target->includes = this */
00180     char rescanned;
00181 
00182         time_t  time;                   /* update time */
00183         time_t  leaf;                   /* update time of leaf sources */
00184 
00185         char    fate;                   /* make0()'s diagnosis */
00186 
00187 # define        T_FATE_INIT     0       /* nothing done to target */
00188 # define        T_FATE_MAKING   1       /* make0(target) on stack */
00189 
00190 # define        T_FATE_STABLE   2       /* target didn't need updating */
00191 # define        T_FATE_NEWER    3       /* target newer than parent */
00192 
00193 # define        T_FATE_SPOIL    4       /* >= SPOIL rebuilds parents */
00194 # define        T_FATE_ISTMP    4       /* unneeded temp target oddly present */
00195 
00196 # define        T_FATE_BUILD    5       /* >= BUILD rebuilds target */
00197 # define        T_FATE_TOUCHED  5       /* manually touched with -t */
00198 # define        T_FATE_MISSING  6       /* is missing, needs updating */
00199 # define        T_FATE_NEEDTMP  7       /* missing temp that must be rebuild */
00200 # define        T_FATE_OUTDATED 8       /* is out of date, needs updating */
00201 # define        T_FATE_UPDATE   9       /* deps updated, needs updating */
00202 
00203 # define        T_FATE_BROKEN   10      /* >= BROKEN ruins parents */
00204 # define        T_FATE_CANTFIND 10      /* no rules to make missing target */
00205 # define        T_FATE_CANTMAKE 11      /* can't find dependents */
00206 
00207         char    progress;               /* tracks make1() progress */
00208 
00209 # define        T_MAKE_INIT     0       /* make1(target) not yet called */
00210 # define        T_MAKE_ONSTACK  1       /* make1(target) on stack */
00211 # define        T_MAKE_ACTIVE   2       /* make1(target) in make1b() */
00212 # define        T_MAKE_RUNNING  3       /* make1(target) running commands */
00213 # define        T_MAKE_DONE     4       /* make1(target) done */
00214 
00215         char    status;                 /* execcmd() result */
00216 
00217         int     asynccnt;               /* child deps outstanding */
00218         TARGETS *parents;               /* used by make1() for completion */
00219         char    *cmds;                  /* type-punned command list */
00220 
00221     char* failed;
00222 } ;
00223 
00224 RULE    *bindrule( char *rulename, module_t* );
00225 
00226 RULE*   import_rule( RULE* source, module_t* m, char* name );
00227 RULE*   new_rule_body( module_t* m, char* rulename, argument_list* args, PARSE* procedure, int exprt );
00228 RULE*   new_rule_actions( module_t* m, char* rulename, char* command, LIST* bindlist, int flags );
00229 TARGET  *bindtarget( const char *targetname );
00230 TARGET *copytarget( const TARGET *t );
00231 void bind_explicitly_located_targets();
00232 TARGET* search_for_target( char * name, LIST* search_path );
00233 void    touchtarget( char *t );
00234 TARGETS *targetlist( TARGETS *chain, LIST  *targets );
00235 TARGETS *targetentry( TARGETS *chain, TARGET *target );
00236 TARGETS *targetchain( TARGETS *chain, TARGETS *targets );
00237 void freetargets( TARGETS *chain );
00238 ACTIONS *actionlist( ACTIONS *chain, ACTION *action );
00239 void freeactions( ACTIONS *chain );
00240 SETTINGS *addsettings( SETTINGS *head, int append, char *symbol, LIST *value );
00241 void    pushsettings( SETTINGS *v );
00242 void    popsettings( SETTINGS *v );
00243 SETTINGS *copysettings( SETTINGS *v );
00244 void    freesettings( SETTINGS *v );
00245 void    rule_free( RULE *r );
00246 void    donerules();
00247 
00248 argument_list* args_new();
00249 void    args_refer( argument_list* );
00250 void    args_free( argument_list* );
00251 
00252 void actions_refer(rule_actions*);
00253 void actions_free(rule_actions*);
00254 
00255 #endif
00256 

Generated on Mon Nov 8 17:07:52 2004 for MPT by  doxygen 1.3.9.1