1
1
""" Import and bulid a bunch of example programs
2
2
3
- This library includes functions that are shared between the examples.py and
3
+ This library includes functions that are shared between the examples.py and
4
4
the update.py modules.
5
-
5
+
6
6
"""
7
7
import os
8
8
from os .path import dirname , abspath , basename
@@ -123,20 +123,19 @@ def target_cross_ide(allowed_targets, allowed_ides, features=[], toolchains=[]):
123
123
124
124
125
125
def get_repo_list (example ):
126
- """ Returns a list of all the repos associated with the specific example in the json
127
- config file.
128
- If there are repos listed under the mbed section then these will be returned as a
129
- list. If not then the github single repo with be returned.
130
- NOTE: This does not currently deal with multiple examples underneath a github
126
+ """ Returns a list of all the repos and their types associated with the
127
+ specific example in the json config file.
128
+ If the key 'test-repo-source' is set to ' mbed', then it will return the
129
+ mbed section as a list. Otherwise, it will return the single github repo.
130
+ NOTE: This does not currently deal with multiple examples underneath a github
131
131
sourced exampe repo.
132
132
133
133
Args:
134
134
example - Example for which the repo list is requested
135
- repos - The list of repos and types contained within that example in the json file
136
135
137
136
"""
138
137
repos = []
139
- if len ( example ['mbed' ]) > 0 :
138
+ if example ['test-repo-source' ] == 'mbed' :
140
139
for repo in example ['mbed' ]:
141
140
repos .append ({
142
141
'repo' : repo ,
@@ -156,7 +155,7 @@ def source_repos(config, examples):
156
155
there is already a clone of the repo then it will first be removed to
157
156
ensure a clean, up to date cloning.
158
157
Args:
159
- config - the json object imported from the file.
158
+ config - the json object imported from the file.
160
159
161
160
"""
162
161
print ("\n Importing example repos....\n " )
@@ -214,7 +213,7 @@ def get_num_failures(results, export=False):
214
213
Args:
215
214
results - results summary of the compilation stage. See compile_repos() for
216
215
details of the format.
217
- num_failures
216
+ num_failures
218
217
219
218
"""
220
219
num_failures = 0
@@ -314,23 +313,23 @@ def status(message):
314
313
315
314
def compile_repos (config , toolchains , targets , examples ):
316
315
"""Compiles combinations of example programs, targets and compile chains.
317
-
316
+
318
317
The results are returned in a [key: value] dictionary format:
319
318
Where key = The example name from the json config file
320
319
value = a list containing: pass_status, successes, and failures
321
-
320
+
322
321
where pass_status = The overall pass status for the compilation of the full
323
322
set of example programs comprising the example suite.
324
323
True if all examples pass, false otherwise
325
- successes = list of passing examples.
324
+ successes = list of passing examples.
326
325
failures = list of failing examples.
327
-
326
+
328
327
Both successes and failures contain the example name, target and compile chain
329
328
330
329
Args:
331
- config - the json object imported from the file.
330
+ config - the json object imported from the file.
332
331
toolchains - List of toolchains to compile for.
333
- results - results of the compilation stage.
332
+ results - results of the compilation stage.
334
333
335
334
"""
336
335
results = {}
@@ -349,8 +348,8 @@ def compile_repos(config, toolchains, targets, examples):
349
348
for repo_info in get_repo_list (example ):
350
349
name = basename (repo_info ['repo' ])
351
350
os .chdir (name )
352
-
353
- # Check that the target, toolchain and features combinations are valid and return a
351
+
352
+ # Check that the target, toolchain and features combinations are valid and return a
354
353
# list of valid combinations to work through
355
354
for target , toolchain in target_cross_toolchain (valid_choices (example ['targets' ], targets ),
356
355
valid_choices (example ['toolchains' ], toolchains ),
@@ -365,7 +364,7 @@ def compile_repos(config, toolchains, targets, examples):
365
364
else :
366
365
successes .append (example_summary )
367
366
os .chdir (".." )
368
-
367
+
369
368
# If there are any compilation failures for the example 'set' then the overall status is fail.
370
369
if len (failures ) > 0 :
371
370
pass_status = False
@@ -378,14 +377,14 @@ def compile_repos(config, toolchains, targets, examples):
378
377
379
378
380
379
def update_mbedos_version (config , tag , examples ):
381
- """ For each example repo identified in the config json object, update the version of
380
+ """ For each example repo identified in the config json object, update the version of
382
381
mbed-os to that specified by the supplied GitHub tag. This function assumes that each
383
382
example repo has already been cloned.
384
-
383
+
385
384
Args:
386
- config - the json object imported from the file.
385
+ config - the json object imported from the file.
387
386
tag - GitHub tag corresponding to a version of mbed-os to upgrade to.
388
-
387
+
389
388
"""
390
389
print ("Updating mbed-os in examples to version %s\n " % tag )
391
390
for example in config ['examples' ]:
@@ -397,4 +396,3 @@ def update_mbedos_version(config, tag, examples):
397
396
os .chdir (update_dir )
398
397
subprocess .call (["mbed-cli" , "update" , tag , "--clean" ])
399
398
os .chdir ("../.." )
400
-
0 commit comments