Fix issue with unrecognized uvision file types

pull/3114/head
Sarah Marsh 2016-10-21 16:06:49 -05:00
parent d1a71eb9fc
commit b1bdf71749
1 changed files with 15 additions and 10 deletions

View File

@ -124,12 +124,12 @@ class Uvision(Exporter):
#File associations within .uvprojx file #File associations within .uvprojx file
file_types = {'.cpp': 8, '.c': 1, '.s': 2, file_types = {'.cpp': 8, '.c': 1, '.s': 2,
'.obj': 3, '.o': 3, '.lib': 4, '.obj': 3, '.o': 3, '.lib': 4,
'.ar': 4, '.h': 5, '.sct': 4} '.ar': 4, '.h': 5, '.hpp': 5, '.sct': 4}
def uv_file(self, loc): def uv_files(self, files):
"""Return a namedtuple of information about project file """An generator containing Uvision specific information about project files
Positional Arguments: Positional Arguments:
loc - the file's location files - the location of source files
.uvprojx XML for project file: .uvprojx XML for project file:
<File> <File>
@ -138,11 +138,14 @@ class Uvision(Exporter):
<FilePath>{{file.loc}}</FilePath> <FilePath>{{file.loc}}</FilePath>
</File> </File>
""" """
UVFile = namedtuple('UVFile', ['type','loc','name']) for loc in files:
_, ext = os.path.splitext(loc) #Encapsulates the information necessary for template entry above
type = self.file_types[ext.lower()] UVFile = namedtuple('UVFile', ['type','loc','name'])
name = ntpath.basename(normpath(loc)) _, ext = os.path.splitext(loc)
return UVFile(type, loc, name) if ext.lower() in self.file_types:
type = self.file_types[ext.lower()]
name = ntpath.basename(normpath(loc))
yield UVFile(type, loc, name)
def format_flags(self): def format_flags(self):
"""Format toolchain flags for Uvision""" """Format toolchain flags for Uvision"""
@ -174,7 +177,7 @@ class Uvision(Exporter):
"""Make sources into the named tuple for use in the template""" """Make sources into the named tuple for use in the template"""
grouped = self.group_project_files(srcs) grouped = self.group_project_files(srcs)
for group, files in grouped.items(): for group, files in grouped.items():
grouped[group] = [self.uv_file(src) for src in files] grouped[group] = self.uv_files(files)
return grouped return grouped
def generate(self): def generate(self):
@ -188,6 +191,8 @@ class Uvision(Exporter):
self.resources.objects + self.resources.libraries self.resources.objects + self.resources.libraries
ctx = { ctx = {
'name': self.project_name, 'name': self.project_name,
# project_files => dict of generators - file group to generator of
# UVFile tuples defined above
'project_files': self.format_src(srcs), 'project_files': self.format_src(srcs),
'linker_script':self.resources.linker_script, 'linker_script':self.resources.linker_script,
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'), 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),