Skip to content

Commit b1bdf71

Browse files
committed
Fix issue with unrecognized uvision file types
1 parent d1a71eb commit b1bdf71

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tools/export/uvision/__init__.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ class Uvision(Exporter):
124124
#File associations within .uvprojx file
125125
file_types = {'.cpp': 8, '.c': 1, '.s': 2,
126126
'.obj': 3, '.o': 3, '.lib': 4,
127-
'.ar': 4, '.h': 5, '.sct': 4}
127+
'.ar': 4, '.h': 5, '.hpp': 5, '.sct': 4}
128128

129-
def uv_file(self, loc):
130-
"""Return a namedtuple of information about project file
129+
def uv_files(self, files):
130+
"""An generator containing Uvision specific information about project files
131131
Positional Arguments:
132-
loc - the file's location
132+
files - the location of source files
133133
134134
.uvprojx XML for project file:
135135
<File>
@@ -138,11 +138,14 @@ def uv_file(self, loc):
138138
<FilePath>{{file.loc}}</FilePath>
139139
</File>
140140
"""
141-
UVFile = namedtuple('UVFile', ['type','loc','name'])
142-
_, ext = os.path.splitext(loc)
143-
type = self.file_types[ext.lower()]
144-
name = ntpath.basename(normpath(loc))
145-
return UVFile(type, loc, name)
141+
for loc in files:
142+
#Encapsulates the information necessary for template entry above
143+
UVFile = namedtuple('UVFile', ['type','loc','name'])
144+
_, ext = os.path.splitext(loc)
145+
if ext.lower() in self.file_types:
146+
type = self.file_types[ext.lower()]
147+
name = ntpath.basename(normpath(loc))
148+
yield UVFile(type, loc, name)
146149

147150
def format_flags(self):
148151
"""Format toolchain flags for Uvision"""
@@ -174,7 +177,7 @@ def format_src(self, srcs):
174177
"""Make sources into the named tuple for use in the template"""
175178
grouped = self.group_project_files(srcs)
176179
for group, files in grouped.items():
177-
grouped[group] = [self.uv_file(src) for src in files]
180+
grouped[group] = self.uv_files(files)
178181
return grouped
179182

180183
def generate(self):
@@ -188,6 +191,8 @@ def generate(self):
188191
self.resources.objects + self.resources.libraries
189192
ctx = {
190193
'name': self.project_name,
194+
# project_files => dict of generators - file group to generator of
195+
# UVFile tuples defined above
191196
'project_files': self.format_src(srcs),
192197
'linker_script':self.resources.linker_script,
193198
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),

0 commit comments

Comments
 (0)