makefile exporter: Escape double quote in toolchain flags.

Without this fix macro defined as -DFOO="BAR" won't be correctly
interpreted by the compiler.
pull/4366/head
Vincent Coubard 2017-05-23 14:08:24 +01:00
parent deaabf3123
commit 897667deaa
1 changed files with 12 additions and 1 deletions

View File

@ -111,7 +111,7 @@ class Makefile(Exporter):
for key in ['include_paths', 'library_paths', 'hex_files',
'to_be_compiled']:
ctx[key] = sorted(ctx[key])
ctx.update(self.flags)
ctx.update(self.format_flags())
for templatefile in \
['makefile/%s_%s.tmpl' % (self.TEMPLATE,
@ -128,6 +128,17 @@ class Makefile(Exporter):
else:
raise NotSupportedException("This make tool is in development")
def format_flags(self):
"""Format toolchain flags for Makefile"""
flags = {}
for k, v in self.flags.iteritems():
if k in ['asm_flags', 'c_flags', 'cxx_flags']:
flags[k] = map(lambda x: x.replace('"', '\\"'), v)
else:
flags[k] = v
return flags
@staticmethod
def build(project_name, log_name="build_log.txt", cleanup=True):
""" Build Make project """