commit d304126

shrub  ·  2026-05-04 19:13:29 +0000 UTC
parent 38b7f57
allow target specific += assigns to be inhereted by prereqs even when prereqs were created earlier in the graph, +600ish test passes
2 files changed,  +13, -3
M README
M README
+1, -1
1@@ -17,6 +17,6 @@ if you want to help out, there's lots to do. feel free to make a
2 contibution. some high-priority tasks are listed in the TODO file.
3 
4 it is implemented in C99. the perl in this repo is just the gnu make 
5-test suite (of which 1960/3865 tests pass, at the time of writing)
6+test suite (of which 2613/3865 tests pass, at the time of writing)
7 
8 this is public domain software
+12, -2
 1@@ -142,15 +142,25 @@ addrule(struct GraphState *gs, const char *name, const struct RuleNode *rule)
 2 	copyenv(&t->env, &env);
 3 
 4 	for (i = 0; i < rule->prereqs.n; i++) {
 5+		struct Env penv;
 6+		struct EvalCtx pctx;
 7+
 8 		if (strchr(rule->prereqs.v[i], '%'))
 9 			continue;
10-		if (!findtarget(gs->graph, rule->prereqs.v[i])) {
11+		t = findtarget(gs->graph, rule->prereqs.v[i]);
12+		if (!t) {
13 			gs->graph->v = xrealloc(gs->graph->v, (gs->graph->n + 1) * sizeof(gs->graph->v[0]));
14 			t = &gs->graph->v[gs->graph->n++];
15 			memset(t, 0, sizeof(*t));
16 			t->name = intern(rule->prereqs.v[i]);
17-			copyenv(&t->env, &env);
18 		}
19+		memset(&penv, 0, sizeof(penv));
20+		memset(&pctx, 0, sizeof(pctx));
21+		pctx.env = &penv;
22+		targetenv(gs, &pctx, &env, t->name);
23+		freeenv(&t->env);
24+		copyenv(&t->env, pctx.env);
25+		freeenv(&penv);
26 	}
27 	freeenv(&env);
28 }