commit 3165e81

shrub  ·  2026-04-12 09:03:19 +0000 UTC
parent 34dcc2a
make 2 tests pass (comments, addprefix) by fixing := parsing and ninja quiet mode
7 files changed,  +12, -16
+1, -1
1@@ -51,7 +51,7 @@ joinrecipes(const struct Target *t)
2 	return s;
3 }
4 
5-/*turn remaining automatic vars into ninja equivalents*/ 
6+/*turn remaining automatic vars into ninja equivalents*/
7 static char *
8 translateauto(const char *s, const struct Target *t)
9 {
+4, -5
 1@@ -91,10 +91,9 @@ targetenv(struct GraphState *gs, struct Env *env, const char *name)
 2 	applytassigns(gs, env, name);
 3 }
 4 
 5-
 6-/* add an explicit target rule to the graph, and add all 
 7- * non-pattern prereqs also as placeholder nodes. later 
 8- * we discorver how to build them if they need to be built */ 
 9+/* add an explicit target rule to the graph, and add all
10+ * non-pattern prereqs also as placeholder nodes. later
11+ * we discorver how to build them if they need to be built */
12 static void
13 addrule(struct GraphState *gs, const char *name, const struct RuleNode *rule)
14 {
15@@ -142,7 +141,7 @@ addtassign(struct GraphState *gs, const struct AssignNode *assign)
16 
17 /*generate the graph from the evaluated ast
18  * get the env and target specific assignments,
19- * then expand placeholder targets until all prereqs 
20+ * then expand placeholder targets until all prereqs
21  * we can find are in the graph. */
22 int
23 buildgraph(const struct Ast *ast, struct Graph *graph)
+5, -5
 1@@ -735,6 +735,11 @@ parseline(const struct PreLine *line)
 2 		free(trim);
 3 		return state;
 4 	}
 5+	if (as.ok && (colon < 0 || as.pos <= (size_t)colon)) {
 6+		state = parseassign(line, trim, n, 0, as, 0, 0);
 7+		free(trim);
 8+		return state;
 9+	}
10 	if (colon >= 0 && (size_t)colon + 1 < n && trim[colon + 1] == ':') {
11 		parseerr(line, "double-colon rule", trim);
12 		state = blanknode(line);
13@@ -746,11 +751,6 @@ parseline(const struct PreLine *line)
14 		free(trim);
15 		return state;
16 	}
17-	if (as.ok) {
18-		state = parseassign(line, trim, n, 0, as, 0, 0);
19-		free(trim);
20-		return state;
21-	}
22 	if (trim[0] == '$' && (trim[1] == '(' || trim[1] == '{')) {
23 		state = parseexpr(line, trim);
24 		free(trim);
+0, -1
1@@ -70,7 +70,6 @@ joinprereqs(const struct Target *t)
2 	return joined;
3 }
4 
5-
6 /*
7  * expand automatic variables like so:
8  *   $@  target
+0, -1
1@@ -1,3 +1,2 @@
2 .test-result
3-config-flags.pm
4 work
+0, -1
1@@ -1 +0,0 @@
2-# ninja log v5
+2, -2
 1@@ -5,7 +5,7 @@ set -u
 2 self_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
 3 repo_dir=$(CDPATH= cd -- "$self_dir/.." && pwd)
 4 shin_bin=${SHIN:-"$repo_dir/shin"}
 5-ninja_bin=${NINJA:-samu}
 6+ninja_bin=${NINJA:-ninja}
 7 
 8 makefile=Makefile
 9 workdir=
10@@ -129,7 +129,7 @@ if ! "$shin_bin" "$makefile"; then
11 	exit $?
12 fi
13 
14-set -- "$ninja_bin" -f build.ninja
15+set -- "$ninja_bin" --quiet -f build.ninja
16 if [ -n "${jobs}" ]; then
17 	set -- "$@" -j "$jobs"
18 fi