Fix escaping of $$ strings; then escape them again before passing to ninja!

This commit is contained in:
David Given
2025-08-26 21:30:50 +02:00
parent b05f5e7caa
commit 6170b704b1
3 changed files with 8 additions and 7 deletions

View File

@@ -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

View File

@@ -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 $@

View File

@@ -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)