@@ -147,32 +147,16 @@ def target_cross_ide(allowed_targets, allowed_ides, features=[], toolchains=[]):
147
147
yield target , ide
148
148
149
149
150
- def get_repo_list (example ):
151
- """ Returns a list of all the repos and their types associated with the
152
- specific example in the json config file.
153
- If the key 'test-repo-source' is set to 'mbed', then it will return the
154
- mbed section as a list. Otherwise, it will return the single github repo.
155
- NOTE: This does not currently deal with multiple examples underneath a github
156
- sourced exampe repo.
157
-
158
- Args:
159
- example - Example for which the repo list is requested
160
-
150
+ def get_sub_examples_list (example ):
151
+ """
161
152
"""
162
- repos = []
163
- if example ['test-repo-source' ] == 'mbed' :
164
- for repo in example ['mbed' ]:
165
- repos .append ({
166
- 'repo' : repo ,
167
- 'type' : 'hg'
168
- })
153
+ sub_examples = []
154
+ if example ['sub-repo-example' ]:
155
+ for sub in example ['subs' ]:
156
+ sub_examples .append ("%s/%s" % (example ["name" ], sub ))
169
157
else :
170
- repos .append ({
171
- 'repo' : example ['github' ],
172
- 'type' : 'git'
173
- })
174
- return repos
175
-
158
+ sub_examples .append (example ["name" ])
159
+ return sub_examples
176
160
177
161
def source_repos (config , exp_filter ):
178
162
""" Imports each of the repos and its dependencies (.lib files) associated
@@ -250,24 +234,7 @@ def deploy_repos(config, exp_filter):
250
234
return 1
251
235
return 0
252
236
253
- def get_num_failures (results , export = False ):
254
- """ Returns the number of failed compilations from the results summary
255
- Args:
256
- results - results summary of the compilation stage. See compile_repos() for
257
- details of the format.
258
- num_failures
259
-
260
- """
261
- num_failures = 0
262
-
263
- for key , val in list (results .items ()):
264
- num_failures = num_failures + len (val [3 ])
265
- if export :
266
- num_failures += len (val [4 ])
267
-
268
- return num_failures
269
-
270
- def export_repos (config , ides , targets , examples ):
237
+ def export_repos (config , ides , targets , exp_filter ):
271
238
"""Exports and builds combinations of example programs, targets and IDEs.
272
239
273
240
The results are returned in a [key: value] dictionary format:
@@ -292,12 +259,10 @@ def export_repos(config, ides, targets, examples):
292
259
ides - List of IDES to export to
293
260
"""
294
261
results = {}
295
- valid_examples = set ( examples )
262
+
296
263
print ("\n Exporting example repos....\n " )
297
264
for example in config ['examples' ]:
298
- example_names = [basename (x ['repo' ]) for x in get_repo_list (example )]
299
- common_examples = valid_examples .intersection (set (example_names ))
300
- if not common_examples :
265
+ if example ['name' ] not in exp_filter :
301
266
continue
302
267
export_failures = []
303
268
build_failures = []
@@ -306,41 +271,39 @@ def export_repos(config, ides, targets, examples):
306
271
exported = True
307
272
pass_status = True
308
273
if example ['export' ]:
309
- for repo_info in get_repo_list (example ):
310
- example_project_name = basename ( repo_info [ 'repo' ] )
311
- os . chdir ( example_project_name )
274
+ for name in get_sub_examples_list (example ):
275
+ os . chdir ( name )
276
+ logging . info ( "In folder '%s'" % name )
312
277
# Check that the target, IDE, and features combinations are valid and return a
313
278
# list of valid combinations to work through
314
279
for target , ide in target_cross_ide (valid_choices (example ['targets' ], targets ),
315
280
valid_choices (example ['exporters' ], ides ),
316
281
example ['features' ], example ['toolchains' ]):
317
- example_name = "{} {} {}" .format (example_project_name , target ,
318
- ide )
319
- def status (message ):
320
- print (message + " %s" % example_name )
321
- sys .stdout .flush ()
322
-
323
- status ("Exporting" )
324
- proc = subprocess .Popen (["mbed-cli" , "export" , "-i" , ide ,
325
- "-m" , target ])
282
+ example_summary = {"name" : name , "target" : target , "ide" : ide }
283
+ summary_string = "%s %s %s" % (name , target , ide )
284
+ logging .info ("Exporting %s" % summary_string )
285
+
286
+ cmd = ["mbed-cli" , "export" , "-i" , ide , "-m" , target ]
287
+ logging .info ("Executing command '%s'..." % " " .join (cmd ))
288
+ proc = subprocess .Popen (cmd )
326
289
proc .wait ()
327
290
if proc .returncode :
328
- export_failures .append (example_name )
329
- status ("FAILURE exporting" )
291
+ export_failures .append (example_summary )
292
+ logging . error ("FAILURE exporting %s" % summary_string )
330
293
else :
331
- status ("SUCCESS exporting" )
332
- status ("Building" )
294
+ logging . info ("SUCCESS exporting %s" % summary_string )
295
+ logging . info ("Building %s" % summary_string )
333
296
try :
334
- if EXPORTERS [ide ].build (example_project_name , cleanup = False ):
335
- status ("FAILURE building" )
336
- build_failures .append (example_name )
297
+ if EXPORTERS [ide ].build (name , cleanup = False ):
298
+ logging . error ("FAILURE building %s" % summary_string )
299
+ build_failures .append (example_summary )
337
300
else :
338
- status ("SUCCESS building" )
339
- successes .append (example_name )
301
+ logging . info ("SUCCESS building %s" % summary_string )
302
+ successes .append (example_summary )
340
303
except TypeError :
341
- successes .append (example_name )
342
- build_skips .append (example_name )
343
- os .chdir (".." )
304
+ successes .append (example_summary )
305
+ build_skips .append (example_summary )
306
+ os .chdir (CWD )
344
307
345
308
if len (build_failures + export_failures ) > 0 :
346
309
pass_status = False
0 commit comments