@@ -124,12 +124,12 @@ class Uvision(Exporter):
124
124
#File associations within .uvprojx file
125
125
file_types = {'.cpp' : 8 , '.c' : 1 , '.s' : 2 ,
126
126
'.obj' : 3 , '.o' : 3 , '.lib' : 4 ,
127
- '.ar' : 4 , '.h' : 5 , '.sct' : 4 }
127
+ '.ar' : 4 , '.h' : 5 , '.hpp' : 5 , '. sct' : 4 }
128
128
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
131
131
Positional Arguments:
132
- loc - the file's location
132
+ files - the location of source files
133
133
134
134
.uvprojx XML for project file:
135
135
<File>
@@ -138,11 +138,14 @@ def uv_file(self, loc):
138
138
<FilePath>{{file.loc}}</FilePath>
139
139
</File>
140
140
"""
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 )
146
149
147
150
def format_flags (self ):
148
151
"""Format toolchain flags for Uvision"""
@@ -174,7 +177,7 @@ def format_src(self, srcs):
174
177
"""Make sources into the named tuple for use in the template"""
175
178
grouped = self .group_project_files (srcs )
176
179
for group , files in grouped .items ():
177
- grouped [group ] = [ self .uv_file ( src ) for src in files ]
180
+ grouped [group ] = self .uv_files ( files )
178
181
return grouped
179
182
180
183
def generate (self ):
@@ -188,6 +191,8 @@ def generate(self):
188
191
self .resources .objects + self .resources .libraries
189
192
ctx = {
190
193
'name' : self .project_name ,
194
+ # project_files => dict of generators - file group to generator of
195
+ # UVFile tuples defined above
191
196
'project_files' : self .format_src (srcs ),
192
197
'linker_script' :self .resources .linker_script ,
193
198
'include_paths' : '; ' .join (self .resources .inc_dirs ).encode ('utf-8' ),
0 commit comments