commit d7b5611
shrub
·
2026-04-28 16:45:00 +0000 UTC
parent 4d9df5a
detect recursive submake
4 files changed,
+12,
-8
+1,
-0
1@@ -1,3 +1,4 @@
2+life.mak
3 build.dot
4 config.mak
5 test-musl.mk
+0,
-6
1@@ -387,12 +387,6 @@ main(int argc, char **argv)
2 return rc == -2 ? 2 : 1;
3 }
4 }
5- if (expandgraph(&sg.graph) < 0) {
6- fprintf(stderr, "expand error in %s\n", path ? path : "(default)");
7- free(pathbuf);
8- freesubgraph(&sg);
9- return 2;
10- }
11 if (dump_graph)
12 dumpgraph(&sg.graph);
13 if (gen == GEN_DOT) {
+2,
-0
1@@ -329,6 +329,8 @@ expandgraph(struct Graph *graph)
2 nr = &new_recipes.v[new_recipes.n++];
3 *nr = *r;
4 nr->body = exp;
5+ freesubmake(&nr->sm);
6+ nr->submake = parsesubmake(&nr->sm, nr->body);
7 free(r->body);
8 r->body = 0;
9 memset(&r->sm, 0, sizeof(r->sm));
+9,
-2
1@@ -440,9 +440,11 @@ expandsubgraphs(struct SubGraph *sg, struct SubGraphStack *stack)
2 addwords(&child.goals, &r->sm.goals);
3 if (strcmp(child.cwd, sg->cwd) == 0 &&
4 (!child.makefile || strcmp(child.makefile, sg->makefile) == 0)) {
5+ fprintf(stderr, "cannot expand recursive submake graph: %s\n",
6+ r->body);
7 freesubgraph(&child);
8- k++;
9- continue;
10+ freestrs(&prevgoals);
11+ return -1;
12 }
13 rc = buildsubgraph0(&child, stack);
14 if (rc > 0) {
15@@ -565,6 +567,11 @@ buildsubgraph0(struct SubGraph *sg, struct SubGraphStack *stack)
16 fprintf(stderr, "graph error in %s/%s\n", sg->cwd, path);
17 goto out;
18 }
19+ rc = expandgraph(&sg->graph);
20+ if (rc < 0) {
21+ fprintf(stderr, "expand error in %s/%s\n", sg->cwd, path);
22+ goto out;
23+ }
24 scopegraph(&sg->graph, sg->prefix);
25 rc = expandsubgraphs(sg, stack);
26 out: