diff --git a/.gitignore b/.gitignore index b8a3ff6..8365745 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /samu /.ninja_deps /.ninja_log +.vscode/ diff --git a/graph.h b/graph.h index dc7306b..bde4570 100644 --- a/graph.h +++ b/graph.h @@ -8,6 +8,7 @@ enum { MTIME_MISSING = -2, }; +/* corresponds to a file */ struct node { /* shellpath is the escaped shell path, and is populated as needed by nodepath */ struct string *path, *shellpath; @@ -15,11 +16,11 @@ struct node { /* modification time of file (in nanoseconds) and build log entry (in seconds) */ int64_t mtime, logmtime; - /* generating edge and dependent edges. - * - * only gen and nuse are set in parse.c:parseedge; use is allocated and - * populated in build.c:computedirty. */ - struct edge *gen, **use; + /* edge that builds this node */ + struct edge *gen; + /* list of edges that use this node as input, allocated and populated in graph.c:nodeuse */ + struct edge **use; + /* number of edges in this.use */ size_t nuse; /* command hash used to build this output, read from build log */ diff --git a/parse.c b/parse.c index 932a573..0977499 100644 --- a/parse.c +++ b/parse.c @@ -78,6 +78,7 @@ parseedge(struct scanner *s, struct environment *env) e = mkedge(env); + /* scan outputs */ for (out = NULL, end = &out; (str = scanstring(s, true)); ++e->nout) pushstr(&end, str); e->outimpidx = e->nout; @@ -88,6 +89,8 @@ parseedge(struct scanner *s, struct environment *env) if (e->nout == 0) scanerror(s, "expected output path"); scanchar(s, ':'); + + /* scan rule name and inputs */ name = scanname(s); e->rule = envrule(env, name); if (!e->rule) @@ -107,6 +110,8 @@ parseedge(struct scanner *s, struct environment *env) for (; (str = scanstring(s, true)); ++e->nin) pushstr(&end, str); } + + /* scan variables for the build rule */ scannewline(s); while (scanindent(s)) { name = scanname(s); @@ -115,6 +120,7 @@ parseedge(struct scanner *s, struct environment *env) envaddvar(e->env, name, val); } + /* evaluate output strings and make output nodes */ e->out = xreallocarray(NULL, e->nout, sizeof(e->out[0])); for (i = 0; i < e->nout; out = str) { str = out->next;