Skip to content

Commit 897667d

Browse files
committed
makefile exporter: Escape double quote in toolchain flags.
Without this fix macro defined as -DFOO="BAR" won't be correctly interpreted by the compiler.
1 parent deaabf3 commit 897667d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/export/makefile/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def generate(self):
111111
for key in ['include_paths', 'library_paths', 'hex_files',
112112
'to_be_compiled']:
113113
ctx[key] = sorted(ctx[key])
114-
ctx.update(self.flags)
114+
ctx.update(self.format_flags())
115115

116116
for templatefile in \
117117
['makefile/%s_%s.tmpl' % (self.TEMPLATE,
@@ -128,6 +128,17 @@ def generate(self):
128128
else:
129129
raise NotSupportedException("This make tool is in development")
130130

131+
def format_flags(self):
132+
"""Format toolchain flags for Makefile"""
133+
flags = {}
134+
for k, v in self.flags.iteritems():
135+
if k in ['asm_flags', 'c_flags', 'cxx_flags']:
136+
flags[k] = map(lambda x: x.replace('"', '\\"'), v)
137+
else:
138+
flags[k] = v
139+
140+
return flags
141+
131142
@staticmethod
132143
def build(project_name, log_name="build_log.txt", cleanup=True):
133144
""" Build Make project """

0 commit comments

Comments
 (0)