Annotation of src/usr.bin/make/gnode.h, Revision 1.23
1.1 espie 1: #ifndef GNODE_H
2: #define GNODE_H
1.23 ! espie 3: /* $OpenBSD: gnode.h,v 1.22 2012/10/06 09:32:40 espie Exp $ */
1.1 espie 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
1.18 espie 36: #ifndef LOCATION_TYPE
37: #include "location.h"
38: #endif
1.1 espie 39: #ifndef SYMTABLE_H
40: #include "symtable.h"
41: #endif
42:
43: /*-
44: * The structure for an individual graph node. Each node has several
45: * pieces of data associated with it.
46: * 1) the name of the target it describes
47: * 2) the location of the target file in the file system.
48: * 3) the type of operator used to define its sources (qv. parse.c)
49: * 4) whether it is involved in this invocation of make
50: * 5) whether the target has been remade
51: * 6) whether any of its children has been remade
52: * 7) the number of its children that are, as yet, unmade
53: * 8) its modification time
54: * 9) the modification time of its youngest child (qv. make.c)
55: * 10) a list of nodes for which this is a source
56: * 11) a list of nodes on which this depends
57: * 12) a list of nodes that depend on this, as gleaned from the
58: * transformation rules.
59: * 13) a list of nodes of the same name created by the :: operator
60: * 14) a list of nodes that must be made (if they're made) before
61: * this node can be, but that do no enter into the datedness of
62: * this node.
63: * 15) a list of nodes that must be made (if they're made) after
64: * this node is, but that do not depend on this node, in the
65: * normal sense.
66: * 16) a Lst of ``local'' variables that are specific to this target
67: * and this target only (qv. var.c [$@ $< $?, etc.])
68: * 17) a Lst of strings that are commands to be given to a shell
69: * to create this target.
70: */
1.5 espie 71:
1.10 espie 72: #define UNKNOWN 0
1.5 espie 73: #define BEINGMADE 1
74: #define MADE 2
1.15 espie 75: #define UPTODATE 3
1.5 espie 76: #define ERROR 4
77: #define ABORTED 5
78: #define CYCLE 6
79: #define ENDCYCLE 7
80: #define NOSUCHNODE 8
1.21 espie 81: #define BUILDING 9
1.23 ! espie 82: #define HELDBACK 10
1.5 espie 83:
1.15 espie 84: #define SPECIAL_NONE 0U
85: #define SPECIAL_PATH 21U
86: #define SPECIAL_MASK 63U
87: #define SPECIAL_TARGET 64U
88: #define SPECIAL_SOURCE 128U
1.5 espie 89: #define SPECIAL_TARGETSOURCE (SPECIAL_TARGET|SPECIAL_SOURCE)
90:
1.21 espie 91: #define SPECIAL_EXEC 4U
92: #define SPECIAL_IGNORE 5U
1.23 ! espie 93: #define SPECIAL_NOTHING 6U
1.21 espie 94: #define SPECIAL_INVISIBLE 8U
95: #define SPECIAL_JOIN 9U
96: #define SPECIAL_MADE 11U
97: #define SPECIAL_MAIN 12U
98: #define SPECIAL_MAKE 13U
99: #define SPECIAL_MFLAGS 14U
100: #define SPECIAL_NOTMAIN 15U
101: #define SPECIAL_NOTPARALLEL 16U
102: #define SPECIAL_OPTIONAL 18U
103: #define SPECIAL_ORDER 19U
104: #define SPECIAL_PARALLEL 20U
105: #define SPECIAL_PHONY 22U
106: #define SPECIAL_PRECIOUS 23U
107: #define SPECIAL_SILENT 25U
108: #define SPECIAL_SUFFIXES 27U
109: #define SPECIAL_USE 28U
110: #define SPECIAL_WAIT 29U
111: #define SPECIAL_NOPATH 30U
112: #define SPECIAL_ERROR 31U
113: #define SPECIAL_CHEAP 32U
114: #define SPECIAL_EXPENSIVE 33U
115:
1.1 espie 116: struct GNode_ {
1.15 espie 117: unsigned int special_op; /* special op to apply */
1.5 espie 118: unsigned char special;/* type of special node */
1.14 espie 119: char must_make; /* true if this target needs to be remade */
1.5 espie 120: char childMade; /* true if one of this target's children was
121: * made */
1.9 espie 122: char built_status; /* Set to reflect the state of processing
1.5 espie 123: * on this node:
1.10 espie 124: * UNKNOWN - Not examined yet
125: * BEINGMADE - Target is currently being made.
1.21 espie 126: * BUILDING - There is a job running
1.5 espie 127: * MADE - Was out-of-date and has been made
128: * UPTODATE - Was already up-to-date
129: * ERROR - An error occurred while it was being
130: * made (used only in compat mode)
131: * ABORTED - The target was aborted due to
1.10 espie 132: * an error making an inferior.
1.5 espie 133: * CYCLE - Marked as potentially being part of
134: * a graph cycle. If we come back to a
135: * node marked this way, it is printed
1.9 espie 136: * and 'built_status' is changed to ENDCYCLE.
1.5 espie 137: * ENDCYCLE - the cycle has been completely
138: * printed. Go back and unmark all its
139: * members.
140: */
141: char *path; /* The full pathname of the file */
1.15 espie 142: unsigned int type; /* Its type (see the OP flags, below) */
1.5 espie 143: int order; /* Its wait weight */
144:
145: int unmade; /* The number of unmade children */
146:
147: TIMESTAMP mtime; /* Its modification time */
148: TIMESTAMP cmtime; /* The modification time of its youngest
149: * child */
150:
1.8 espie 151: GNode *impliedsrc;
1.5 espie 152: LIST cohorts; /* Other nodes for the :: operator */
153: LIST parents; /* Nodes that depend on this one */
154: LIST children; /* Nodes on which this one depends */
155: LIST successors; /* Nodes that must be made after this one */
156: LIST preds; /* Nodes that must be made before this one */
157:
158: SymTable context; /* The local variables */
159: LIST commands; /* Creation commands */
1.23 ! espie 160: Suff *suffix; /* Suffix for the node (determined by
1.5 espie 161: * Suff_FindDeps and opaque to everyone
162: * but the Suff module) */
1.23 ! espie 163: GNode *sibling; /* equivalent targets */
! 164: GNode *groupling; /* target lists */
! 165: GNode *watched; /* the node currently building */
1.14 espie 166: /* stuff for target name equivalence */
167: char *basename; /* pointer to name stripped of path */
1.23 ! espie 168: GNode *next;
1.5 espie 169: char name[1]; /* The target's name */
1.20 espie 170: };
171:
172: struct command
173: {
174: Location location;
175: char string[1];
1.1 espie 176: };
177:
1.14 espie 178: #define has_been_built(gn) \
179: ((gn)->built_status == MADE || (gn)->built_status == UPTODATE)
180: #define should_have_file(gn) \
181: ((gn)->special == SPECIAL_NONE && \
182: ((gn)->type & (OP_PHONY | OP_DUMMY)) == 0)
1.1 espie 183: /*
184: * The OP_ constants are used when parsing a dependency line as a way of
185: * communicating to other parts of the program the way in which a target
186: * should be made. These constants are bitwise-OR'ed together and
187: * placed in the 'type' field of each node. Any node that has
188: * a 'type' field which satisfies the OP_NOP function was never never on
189: * the lefthand side of an operator, though it may have been on the
190: * righthand side...
191: */
192: #define OP_DEPENDS 0x00000001 /* Execution of commands depends on
193: * kids (:) */
194: #define OP_FORCE 0x00000002 /* Always execute commands (!) */
195: #define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids
196: * per line (::) */
1.6 espie 197: #define OP_ERROR 0x00000000
1.1 espie 198: #define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
199:
200: #define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't
201: * exist and can't be created */
202: #define OP_USE 0x00000010 /* Use associated commands for parents */
203: #define OP_EXEC 0x00000020 /* Target is never out of date, but always
204: * execute commands anyway. Its time
205: * doesn't matter, so it has none...sort
206: * of */
207: #define OP_IGNORE 0x00000040 /* Ignore errors when creating the node */
208: #define OP_PRECIOUS 0x00000080 /* Don't remove the target when
209: * interrupted */
210: #define OP_SILENT 0x00000100 /* Don't echo commands when executed */
1.5 espie 211: #define OP_MAKE 0x00000200 /* Target is a recursive make so its
1.1 espie 212: * commands should always be executed when
213: * it is out of date, regardless of the
214: * state of the -n or -t flags */
215: #define OP_JOIN 0x00000400 /* Target is out-of-date only if any of its
216: * children was out-of-date */
217: #define OP_MADE 0x00000800 /* Assume the node is already made; even if
218: * it really is out of date */
1.14 espie 219: #define OP_INVISIBLE 0x00001000 /* The node is invisible to its parents.
1.1 espie 220: * I.e. it doesn't show up in the parents's
221: * local variables. */
1.14 espie 222: #define OP_NOTMAIN 0x00002000 /* The node is exempt from normal 'main
1.1 espie 223: * target' processing in parse.c */
1.14 espie 224: #define OP_PHONY 0x00004000 /* Not a file target; run always */
225: #define OP_NOPATH 0x00008000 /* Don't search for file in the path */
226: #define OP_NODEFAULT 0x00010000 /* Special node that never needs */
1.5 espie 227: /* DEFAULT commands applied */
1.14 espie 228: #define OP_DUMMY 0x00020000 /* node was created by default, but it */
1.5 espie 229: /* does not really exist. */
1.1 espie 230: /* Attributes applied by PMake */
1.14 espie 231: #define OP_TRANSFORM 0x00040000 /* The node is a transformation rule */
232: #define OP_MEMBER 0x00080000 /* Target is a member of an archive */
1.23 ! espie 233: #define OP_DOUBLE 0x00100000 /* normal op with double commands */
1.14 espie 234: #define OP_ARCHV 0x00200000 /* Target is an archive construct */
235: #define OP_HAS_COMMANDS 0x00400000 /* Target has all the commands it should.
1.1 espie 236: * Used when parsing to catch multiple
237: * commands for a target */
1.14 espie 238: #define OP_DEPS_FOUND 0x00800000 /* Already processed by Suff_FindDeps */
1.7 espie 239: #define OP_RESOLVED 0x01000000 /* We looked harder already */
1.19 espie 240: #define OP_CHEAP 0x02000000 /* Assume job is not recursive */
241: #define OP_EXPENSIVE 0x04000000 /* Recursive job, don't run in parallel */
1.1 espie 242:
243: /*
244: * OP_NOP will return true if the node with the given type was not the
245: * object of a dependency operator
246: */
247: #define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000)
248:
249: #define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM)
250:
251:
252: #endif