Skip to content

Commit f813bb9

Browse files
committed
Fix GCC interpretation of dependency file
The dependency file generated by GCC might contain more than one dependency listed on a single line, which wasn't taken into account by the GCC dependency fille interpreter. This commit fixes this issue.
1 parent ae16d3e commit f813bb9

File tree

1 file changed

+12
-1
lines changed
  • workspace_tools/toolchains

1 file changed

+12
-1
lines changed

workspace_tools/toolchains/gcc.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,18 @@ def parse_dependencies(self, dep_path):
7979
for line in open(dep_path).readlines()[1:]:
8080
file = line.replace('\\\n', '').strip()
8181
if file:
82-
dependencies.append(file)
82+
# GCC might list more than one dependency on a single line, in this case
83+
# the dependencies are separated by a space. However, a space might also
84+
# indicate an actual space character in a dependency path, but in this case
85+
# the space character is prefixed by a backslash.
86+
# Temporary replace all '\ ' with a special char that is not used (\a in this
87+
# case) to keep them from being interpreted by 'split' (they will be converted
88+
# back later to a space char)
89+
file = file.replace('\\ ', '\a')
90+
if file.find(" ") == -1:
91+
dependencies.append(file.replace('\a', ' '))
92+
else:
93+
dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")]
8394
return dependencies
8495

8596
def parse_output(self, output):

0 commit comments

Comments
 (0)