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