@@ -131,10 +131,10 @@ class Uvision(Exporter):
131
131
'.obj' : 3 , '.o' : 3 , '.lib' : 4 ,
132
132
'.ar' : 4 , '.h' : 5 , '.hpp' : 5 , '.sct' : 4 }
133
133
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
136
136
Positional Arguments:
137
- loc - the file's location
137
+ files - the location of source files
138
138
139
139
.uvprojx XML for project file:
140
140
<File>
@@ -143,11 +143,14 @@ def uv_file(self, loc):
143
143
<FilePath>{{file.loc}}</FilePath>
144
144
</File>
145
145
"""
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 )
151
154
152
155
def format_flags (self ):
153
156
"""Format toolchain flags for Uvision"""
@@ -179,7 +182,7 @@ def format_src(self, srcs):
179
182
"""Make sources into the named tuple for use in the template"""
180
183
grouped = self .group_project_files (srcs )
181
184
for group , files in grouped .items ():
182
- grouped [group ] = [ self .uv_file ( src ) for src in files ]
185
+ grouped [group ] = self .uv_files ( files )
183
186
return grouped
184
187
185
188
def generate (self ):
@@ -193,6 +196,8 @@ def generate(self):
193
196
self .resources .objects + self .resources .libraries
194
197
ctx = {
195
198
'name' : self .project_name ,
199
+ # project_files => dict of generators - file group to generator of
200
+ # UVFile tuples defined above
196
201
'project_files' : self .format_src (srcs ),
197
202
'linker_script' :self .resources .linker_script ,
198
203
'include_paths' : '; ' .join (self .resources .inc_dirs ).encode ('utf-8' ),
0 commit comments