[BACK]Return to gnode.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Annotation of src/usr.bin/make/gnode.h, Revision 1.4

1.1       espie       1: #ifndef GNODE_H
                      2: #define GNODE_H
                      3: /*     $OpenPackages$ */
1.3       espie       4: /*     $OpenBSD: gnode.h,v 1.2 2001/09/19 10:58:07 mpech Exp $ */
1.1       espie       5:
                      6: /*
                      7:  * Copyright (c) 2001 Marc Espie.
                      8:  *
                      9:  * Redistribution and use in source and binary forms, with or without
                     10:  * modification, are permitted provided that the following conditions
                     11:  * are met:
                     12:  * 1. Redistributions of source code must retain the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer.
                     14:  * 2. Redistributions in binary form must reproduce the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer in the
                     16:  *    documentation and/or other materials provided with the distribution.
                     17:  *
                     18:  * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
                     19:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
                     20:  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
                     21:  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OPENBSD
                     22:  * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
                     23:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
                     24:  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     25:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     26:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     27:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
                     28:  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     29:  */
                     30:
                     31: #ifndef TIMESTAMP_TYPE
                     32: #include "timestamp_t.h"
                     33: #endif
                     34: #ifndef LIST_TYPE
                     35: #include "lst_t.h"
                     36: #endif
                     37: #ifndef SYMTABLE_H
                     38: #include "symtable.h"
                     39: #endif
                     40:
                     41: struct Suff_;
                     42: /*-
                     43:  * The structure for an individual graph node. Each node has several
                     44:  * pieces of data associated with it.
                     45:  *     1) the name of the target it describes
                     46:  *     2) the location of the target file in the file system.
                     47:  *     3) the type of operator used to define its sources (qv. parse.c)
                     48:  *     4) whether it is involved in this invocation of make
                     49:  *     5) whether the target has been remade
                     50:  *     6) whether any of its children has been remade
                     51:  *     7) the number of its children that are, as yet, unmade
                     52:  *     8) its modification time
                     53:  *     9) the modification time of its youngest child (qv. make.c)
                     54:  *     10) a list of nodes for which this is a source
                     55:  *     11) a list of nodes on which this depends
                     56:  *     12) a list of nodes that depend on this, as gleaned from the
                     57:  *         transformation rules.
                     58:  *     13) a list of nodes of the same name created by the :: operator
                     59:  *     14) a list of nodes that must be made (if they're made) before
                     60:  *         this node can be, but that do no enter into the datedness of
                     61:  *         this node.
                     62:  *     15) a list of nodes that must be made (if they're made) after
                     63:  *         this node is, but that do not depend on this node, in the
                     64:  *         normal sense.
                     65:  *     16) a Lst of ``local'' variables that are specific to this target
                     66:  *        and this target only (qv. var.c [$@ $< $?, etc.])
                     67:  *     17) a Lst of strings that are commands to be given to a shell
                     68:  *        to create this target.
                     69:  */
                     70: struct GNode_ {
                     71:     char           *path;      /* The full pathname of the file */
                     72:     int            type;       /* Its type (see the OP flags, below) */
                     73:     int            order;      /* Its wait weight */
                     74:
                     75:     bool           make;       /* true if this target needs to be remade */
                     76:     enum {
                     77:        UNMADE, BEINGMADE, MADE, UPTODATE, ERROR, ABORTED,
                     78:        CYCLE, ENDCYCLE
                     79:     }              made;       /* Set to reflect the state of processing
                     80:                                 * on this node:
                     81:                                 *  UNMADE - Not examined yet
                     82:                                 *  BEINGMADE - Target is already being made.
                     83:                                 *      Indicates a cycle in the graph. (compat
                     84:                                 *      mode only)
                     85:                                 *  MADE - Was out-of-date and has been made
                     86:                                 *  UPTODATE - Was already up-to-date
1.2       mpech      87:                                 *  ERROR - An error occurred while it was being
1.1       espie      88:                                 *      made (used only in compat mode)
                     89:                                 *  ABORTED - The target was aborted due to
                     90:                                 *      an error making an inferior (compat).
                     91:                                 *  CYCLE - Marked as potentially being part of
                     92:                                 *      a graph cycle. If we come back to a
                     93:                                 *      node marked this way, it is printed
                     94:                                 *      and 'made' is changed to ENDCYCLE.
                     95:                                 *  ENDCYCLE - the cycle has been completely
                     96:                                 *      printed. Go back and unmark all its
                     97:                                 *      members.
                     98:                                 */
                     99:     bool           childMade;  /* true if one of this target's children was
                    100:                                 * made */
                    101:     int            unmade;     /* The number of unmade children */
                    102:
                    103:     TIMESTAMP      mtime;      /* Its modification time */
                    104:     TIMESTAMP      cmtime;     /* The modification time of its youngest
                    105:                                 * child */
                    106:
                    107:     LIST           iParents;   /* Links to parents for which this is an
                    108:                                 * implied source, if any */
                    109:     LIST           cohorts;    /* Other nodes for the :: operator */
                    110:     LIST           parents;    /* Nodes that depend on this one */
                    111:     LIST           children;   /* Nodes on which this one depends */
                    112:     LIST           successors; /* Nodes that must be made after this one */
                    113:     LIST           preds;      /* Nodes that must be made before this one */
                    114:
                    115:     SymTable       context;    /* The local variables */
                    116:     unsigned long   lineno;    /* First line number of commands.  */
                    117:     const char *    fname;     /* File name of commands.  */
                    118:     LIST           commands;   /* Creation commands */
                    119:     LstNode        current;    /* Current command, for job */
                    120:
                    121:     struct Suff_    *suffix;   /* Suffix for the node (determined by
                    122:                                 * Suff_FindDeps and opaque to everyone
                    123:                                 * but the Suff module) */
                    124:     char      name[1];         /* The target's name */
                    125: };
                    126:
                    127: /*
                    128:  * The OP_ constants are used when parsing a dependency line as a way of
                    129:  * communicating to other parts of the program the way in which a target
                    130:  * should be made. These constants are bitwise-OR'ed together and
                    131:  * placed in the 'type' field of each node. Any node that has
                    132:  * a 'type' field which satisfies the OP_NOP function was never never on
                    133:  * the lefthand side of an operator, though it may have been on the
                    134:  * righthand side...
                    135:  */
                    136: #define OP_DEPENDS     0x00000001  /* Execution of commands depends on
                    137:                                     * kids (:) */
                    138: #define OP_FORCE       0x00000002  /* Always execute commands (!) */
                    139: #define OP_DOUBLEDEP   0x00000004  /* Execution of commands depends on kids
                    140:                                     * per line (::) */
                    141: #define OP_OPMASK      (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
                    142:
                    143: #define OP_OPTIONAL    0x00000008  /* Don't care if the target doesn't
                    144:                                     * exist and can't be created */
                    145: #define OP_USE         0x00000010  /* Use associated commands for parents */
                    146: #define OP_EXEC        0x00000020  /* Target is never out of date, but always
                    147:                                     * execute commands anyway. Its time
                    148:                                     * doesn't matter, so it has none...sort
                    149:                                     * of */
                    150: #define OP_IGNORE      0x00000040  /* Ignore errors when creating the node */
                    151: #define OP_PRECIOUS    0x00000080  /* Don't remove the target when
                    152:                                     * interrupted */
                    153: #define OP_SILENT      0x00000100  /* Don't echo commands when executed */
                    154: #define OP_MAKE        0x00000200  /* Target is a recurrsive make so its
                    155:                                     * commands should always be executed when
                    156:                                     * it is out of date, regardless of the
                    157:                                     * state of the -n or -t flags */
                    158: #define OP_JOIN        0x00000400  /* Target is out-of-date only if any of its
                    159:                                     * children was out-of-date */
                    160: #define OP_MADE        0x00000800  /* Assume the node is already made; even if
                    161:                                     * it really is out of date */
                    162: #define OP_INVISIBLE   0x00004000  /* The node is invisible to its parents.
                    163:                                     * I.e. it doesn't show up in the parents's
                    164:                                     * local variables. */
                    165: #define OP_NOTMAIN     0x00008000  /* The node is exempt from normal 'main
                    166:                                     * target' processing in parse.c */
                    167: #define OP_PHONY       0x00010000  /* Not a file target; run always */
                    168: #define OP_NOPATH      0x00020000  /* Don't search for file in the path */
                    169: /* Attributes applied by PMake */
                    170: #define OP_TRANSFORM   0x80000000  /* The node is a transformation rule */
                    171: #define OP_MEMBER      0x40000000  /* Target is a member of an archive */
                    172: #define OP_LIB         0x20000000  /* Target is a library */
                    173: #define OP_ARCHV       0x10000000  /* Target is an archive construct */
                    174: #define OP_HAS_COMMANDS 0x08000000  /* Target has all the commands it should.
                    175:                                     * Used when parsing to catch multiple
                    176:                                     * commands for a target */
                    177: #define OP_SAVE_CMDS   0x04000000  /* Saving commands on .END (Compat) */
                    178: #define OP_DEPS_FOUND  0x02000000  /* Already processed by Suff_FindDeps */
                    179:
                    180: /*
                    181:  * OP_NOP will return true if the node with the given type was not the
                    182:  * object of a dependency operator
                    183:  */
                    184: #define OP_NOP(t)      (((t) & OP_OPMASK) == 0x00000000)
                    185:
                    186: #define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM)
                    187:
                    188:
                    189: #endif