Skip to content

Commit 58180db

Browse files
committed
Use shell escaping instead of quoting
OSs don't agree on what the quote chars mean
1 parent 6adac92 commit 58180db

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

tools/export/makefile/Makefile.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ SREC_CAT = srec_cat
7575
{%- endif %}
7676
{%- block additional_executables -%}{%- endblock %}
7777

78-
{% for flag in c_flags %}C_FLAGS += "{{flag}}"
78+
{% for flag in c_flags %}C_FLAGS += {{shell_escape(flag)}}
7979
{% endfor %}
80-
{% for flag in cxx_flags %}CXX_FLAGS += "{{flag}}"
80+
{% for flag in cxx_flags %}CXX_FLAGS += {{shell_escape(flag)}}
8181
{% endfor %}
82-
{% for flag in asm_flags %}ASM_FLAGS += "{{flag}}"
82+
{% for flag in asm_flags %}ASM_FLAGS += {{shell_escape(flag)}}
8383
{% endfor %}
8484

8585
LD_FLAGS :={%- block ld_flags -%} {{ld_flags|join(" ")}} {% endblock %}

tools/export/makefile/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
from tools.utils import NotSupportedException
3030
from tools.targets import TARGET_MAP
3131

32+
SHELL_ESCAPE_TABLE = {
33+
"(": "\(",
34+
")": "\)",
35+
}
36+
37+
38+
def shell_escape(string):
39+
return "".join(SHELL_ESCAPE_TABLE.get(char, char) for char in string)
40+
3241

3342
class Makefile(Exporter):
3443
"""Generic Makefile template that mimics the behavior of the python build
@@ -97,6 +106,7 @@ def generate(self):
97106
'link_script_option': self.LINK_SCRIPT_OPTION,
98107
'user_library_flag': self.USER_LIBRARY_FLAG,
99108
'needs_asm_preproc': self.PREPROCESS_ASM,
109+
'shell_escape': shell_escape,
100110
}
101111

102112
if hasattr(self.toolchain, "preproc"):

0 commit comments

Comments
 (0)