From 6170b704b172eeac4ab730e899d06fe27faf6da0 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 26 Aug 2025 21:30:50 +0200 Subject: [PATCH] Fix escaping of $$ strings; then escape them again before passing to ninja! --- Makefile | 6 ++++-- build/ab.mk | 1 - build/ab.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 7e9aee8a..a4aaa672 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ ifeq ($(BUILDTYPE),windows) MINGW = i686-w64-mingw32- CC = $(MINGW)gcc CXX = $(MINGW)g++ -std=c++20 - CFLAGS += -g -O3 + CFLAGS += -g -O3 \ + -Wno-unknown-warning-option CXXFLAGS += \ -fext-numeric-literals \ -Wno-deprecated-enum-float-conversion \ @@ -26,7 +27,8 @@ ifeq ($(BUILDTYPE),windows) else CC = gcc CXX = g++ -std=c++20 - CFLAGS = -g -O3 + CFLAGS = -g -O3 \ + -Wno-unknown-warning-option CXXFLAGS += \ -Wno-deprecated-enum-float-conversion \ -Wno-deprecated-enum-enum-conversion diff --git a/build/ab.mk b/build/ab.mk index 02e24059..2f7b92ae 100644 --- a/build/ab.mk +++ b/build/ab.mk @@ -115,5 +115,4 @@ $(OBJ)/build.ninja $(OBJ)/build.targets &: include $(OBJ)/build.targets .PHONY: $(ninja-targets) $(ninja-targets) &: $(OBJ)/build.ninja - @echo "NINJA" +$(hide) $(NINJA) -f $(OBJ)/build.ninja $@ diff --git a/build/ab.py b/build/ab.py index 05145616..df29e92d 100644 --- a/build/ab.py +++ b/build/ab.py @@ -150,7 +150,7 @@ class GlobalFormatter(string.Formatter): m = re.search(f"(?:[^$]|^)()\\$\\(([^)]*)\\)()", format_string) if not m: yield ( - _undo_escaped_dollar(format_string, "("), + format_string, None, None, None, @@ -161,7 +161,7 @@ class GlobalFormatter(string.Formatter): format_string = format_string[m.end(3) :] yield ( - _undo_escaped_dollar(left, "(") if left else None, + left if left else None, var, None, None, @@ -187,7 +187,7 @@ def substituteGlobalVariables(value): oldValue = value value = globalFormatter.format(value) if value == oldValue: - return value + return _undo_escaped_dollar( value, "(") def Rule(func): @@ -583,7 +583,7 @@ def emit_rule(self, ins, outs, cmds=[], label=None): emit(" command=sh", rulef) else: emit("build", *fouts, ":rule", *fins) - emit(" command=", "&&".join([s.strip() for s in rule])) + emit(" command=", "&&".join([s.strip() for s in rule]).replace("$", "$$")) if label: emit(" description=", label) emit("build", name, ":phony", *fouts)