Skip to content

Commit 9da1ff5

Browse files
authored
Merge pull request #3114 from sarahmarshy/uvision-filetype-fix
Fix issue with unrecognized uvision file types
2 parents 93c08f3 + b1bdf71 commit 9da1ff5

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tools/export/uvision/__init__.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ class Uvision(Exporter):
131131
'.obj': 3, '.o': 3, '.lib': 4,
132132
'.ar': 4, '.h': 5, '.hpp': 5, '.sct': 4}
133133

134-
def uv_file(self, loc):
135-
"""Return a namedtuple of information about project file
134+
def uv_files(self, files):
135+
"""An generator containing Uvision specific information about project files
136136
Positional Arguments:
137-
loc - the file's location
137+
files - the location of source files
138138
139139
.uvprojx XML for project file:
140140
<File>
@@ -143,11 +143,14 @@ def uv_file(self, loc):
143143
<FilePath>{{file.loc}}</FilePath>
144144
</File>
145145
"""
146-
UVFile = namedtuple('UVFile', ['type','loc','name'])
147-
_, ext = os.path.splitext(loc)
148-
type = self.file_types[ext.lower()]
149-
name = ntpath.basename(normpath(loc))
150-
return UVFile(type, loc, name)
146+
for loc in files:
147+
#Encapsulates the information necessary for template entry above
148+
UVFile = namedtuple('UVFile', ['type','loc','name'])
149+
_, ext = os.path.splitext(loc)
150+
if ext.lower() in self.file_types:
151+
type = self.file_types[ext.lower()]
152+
name = ntpath.basename(normpath(loc))
153+
yield UVFile(type, loc, name)
151154

152155
def format_flags(self):
153156
"""Format toolchain flags for Uvision"""
@@ -179,7 +182,7 @@ def format_src(self, srcs):
179182
"""Make sources into the named tuple for use in the template"""
180183
grouped = self.group_project_files(srcs)
181184
for group, files in grouped.items():
182-
grouped[group] = [self.uv_file(src) for src in files]
185+
grouped[group] = self.uv_files(files)
183186
return grouped
184187

185188
def generate(self):
@@ -193,6 +196,8 @@ def generate(self):
193196
self.resources.objects + self.resources.libraries
194197
ctx = {
195198
'name': self.project_name,
199+
# project_files => dict of generators - file group to generator of
200+
# UVFile tuples defined above
196201
'project_files': self.format_src(srcs),
197202
'linker_script':self.resources.linker_script,
198203
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),

0 commit comments

Comments
 (0)