summaryrefslogtreecommitdiffstats
path: root/libclc/build/ninja_syntax.py
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2014-01-29 20:03:26 +0000
committerTom Stellard <thomas.stellard@amd.com>2014-01-29 20:03:26 +0000
commit91d51db80065a692a5f1a371ad7717f6f2ee3189 (patch)
tree68e0795767a9941d2c72fdab043954697d01aab5 /libclc/build/ninja_syntax.py
parentac0fb621cef63422ebec88e73f548a033dee93cc (diff)
downloadbcm5719-llvm-91d51db80065a692a5f1a371ad7717f6f2ee3189.tar.gz
bcm5719-llvm-91d51db80065a692a5f1a371ad7717f6f2ee3189.zip
Fixed ninja build issues relating to use of $(DESTDIR)
We use ${DESTDIR} syntax now instead of $(DESTDIR) because that syntax works both is the shell (at least it does for bash) and for make (at least it does for GNU Make) Patch By: Dan Liew llvm-svn: 200414
Diffstat (limited to 'libclc/build/ninja_syntax.py')
-rw-r--r--libclc/build/ninja_syntax.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/libclc/build/ninja_syntax.py b/libclc/build/ninja_syntax.py
index 6e8a87c7406..7d9f592dfad 100644
--- a/libclc/build/ninja_syntax.py
+++ b/libclc/build/ninja_syntax.py
@@ -8,6 +8,7 @@ use Python.
"""
import textwrap
+import re
class Writer(object):
def __init__(self, output, width=78):
@@ -31,7 +32,7 @@ class Writer(object):
def rule(self, name, command, description=None, depfile=None,
generator=False):
self._line('rule %s' % name)
- self.variable('command', command, indent=1)
+ self.variable('command', escape(command), indent=1)
if description:
self.variable('description', description, indent=1)
if depfile:
@@ -103,8 +104,15 @@ class Writer(object):
def escape(string):
- """Escape a string such that it can be embedded into a Ninja file without
- further interpretation."""
+ """Escape a string such that Makefile and shell variables are
+ correctly escaped for use in a Ninja file.
+ """
assert '\n' not in string, 'Ninja syntax does not allow newlines'
# We only have one special metacharacter: '$'.
- return string.replace('$', '$$')
+
+ # We should leave $in and $out untouched.
+ # Just look for makefile/shell style substitutions
+ return re.sub(r'(\$[{(][a-z_]+[})])',
+ r'$\1',
+ string,
+ flags=re.IGNORECASE)
OpenPOWER on IntegriCloud