diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/ninja.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/misc/ninja.py b/misc/ninja.py index abde596..7fa4bf1 100644 --- a/misc/ninja.py +++ b/misc/ninja.py @@ -84,3 +84,11 @@ class Writer(object): if isinstance(input, list): return input return [input] + + +def escape(string): + """Escape a string such that it can be embedded into a Ninja file without + further interpretation.""" + assert '\n' not in string, 'Ninja syntax does not allow newlines' + # We only have one special metacharacter: '$'. + return string.replace('$', '$$') |