@@ -75,52 +75,46 @@ def print_summary(results, export=False):
75
75
76
76
print ("#" )
77
77
print ("#" * 80 )
78
-
79
78
80
- def target_cross_toolchain (allowed_toolchains ,
81
- features = [], targets = []):
79
+ def valid_choices (allowed_choices , all_choices ):
80
+ if len (allowed_choices ) > 0 :
81
+ return [t for t in all_choices if t in allowed_choices ]
82
+ else :
83
+ return all_choices
84
+
85
+
86
+ def target_cross_toolchain (allowed_targets , allowed_toolchains , features = []):
82
87
"""Generate pairs of target and toolchains
83
88
84
89
Args:
90
+ allowed_targets - a list of all possible targets
85
91
allowed_toolchains - a list of all possible toolchains
86
92
87
93
Kwargs:
88
94
features - the features that must be in the features array of a
89
95
target
90
- targets - a list of available targets
91
96
"""
92
- if len (targets ) == 0 :
93
- targets = TARGET_MAP .keys ()
94
-
95
- for target , toolchains in get_mbed_official_release ("5" ):
96
- for toolchain in toolchains :
97
- if (toolchain in allowed_toolchains and
98
- target in targets and
99
- all (feature in TARGET_MAP [target ].features
100
- for feature in features )):
97
+ for target in allowed_targets :
98
+ for toolchain in allowed_toolchains :
99
+ if all (feature in TARGET_MAP [target ].features
100
+ for feature in features ):
101
101
yield target , toolchain
102
102
103
103
104
- def target_cross_ide (allowed_ides ,
105
- features = [], targets = []):
104
+ def target_cross_ide (allowed_targets , allowed_ides , features = []):
106
105
"""Generate pairs of target and ides
107
106
108
107
Args:
108
+ allowed_targets - a list of all possible targets
109
109
allowed_ides - a list of all possible IDEs
110
110
111
111
Kwargs:
112
112
features - the features that must be in the features array of a
113
113
target
114
- targets - a list of available targets
115
114
"""
116
- if len (targets ) == 0 :
117
- targets = TARGET_MAP .keys ()
118
-
119
- for target , toolchains in get_mbed_official_release ("5" ):
115
+ for target in allowed_targets :
120
116
for ide in allowed_ides :
121
- if (EXPORTERS [ide ].TOOLCHAIN in toolchains and
122
- target in EXPORTERS [ide ].TARGETS and
123
- target in targets and
117
+ if (target in EXPORTERS [ide ].TARGETS and
124
118
all (feature in TARGET_MAP [target ].features
125
119
for feature in features )):
126
120
yield target , ide
@@ -154,7 +148,7 @@ def get_repo_list(example):
154
148
return repos
155
149
156
150
157
- def source_repos (config ):
151
+ def source_repos (config , examples ):
158
152
""" Imports each of the repos and its dependencies (.lib files) associated
159
153
with the specific examples name from the json config file. Note if
160
154
there is already a clone of the repo then it will first be removed to
@@ -167,13 +161,14 @@ def source_repos(config):
167
161
for example in config ['examples' ]:
168
162
for repo_info in get_repo_list (example ):
169
163
name = basename (repo_info ['repo' ])
170
- if os .path .exists (name ):
171
- print ("'%s' example directory already exists. Deleting..." % name )
172
- rmtree (name )
173
-
174
- subprocess .call (["mbed-cli" , "import" , repo_info ['repo' ]])
164
+ if name in examples :
165
+ if os .path .exists (name ):
166
+ print ("'%s' example directory already exists. Deleting..." % name )
167
+ rmtree (name )
175
168
176
- def clone_repos (config ):
169
+ subprocess .call (["mbed-cli" , "import" , repo_info ['repo' ]])
170
+
171
+ def clone_repos (config , examples ):
177
172
""" Clones each of the repos associated with the specific examples name from the
178
173
json config file. Note if there is already a clone of the repo then it will first
179
174
be removed to ensure a clean, up to date cloning.
@@ -185,13 +180,14 @@ def clone_repos(config):
185
180
for example in config ['examples' ]:
186
181
for repo_info in get_repo_list (example ):
187
182
name = basename (repo_info ['repo' ])
188
- if os .path .exists (name ):
189
- print ("'%s' example directory already exists. Deleting..." % name )
190
- rmtree (name )
183
+ if name in examples :
184
+ if os .path .exists (name ):
185
+ print ("'%s' example directory already exists. Deleting..." % name )
186
+ rmtree (name )
191
187
192
- subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
188
+ subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
193
189
194
- def deploy_repos (config ):
190
+ def deploy_repos (config , examples ):
195
191
""" If the example directory exists as provided by the json config file,
196
192
pull in the examples dependencies by using `mbed-cli deploy`.
197
193
Args:
@@ -202,13 +198,13 @@ def deploy_repos(config):
202
198
for example in config ['examples' ]:
203
199
for repo_info in get_repo_list (example ):
204
200
name = basename (repo_info ['repo' ])
205
-
206
- if os .path .exists (name ):
207
- os .chdir (name )
208
- subprocess .call (["mbed-cli" , "deploy" ])
209
- os .chdir (".." )
210
- else :
211
- print ("'%s' example directory doesn't exist. Skipping..." % name )
201
+ if name in examples :
202
+ if os .path .exists (name ):
203
+ os .chdir (name )
204
+ subprocess .call (["mbed-cli" , "deploy" ])
205
+ os .chdir (".." )
206
+ else :
207
+ print ("'%s' example directory doesn't exist. Skipping..." % name )
212
208
213
209
214
210
def get_num_failures (results , export = False ):
@@ -228,35 +224,36 @@ def get_num_failures(results, export=False):
228
224
229
225
return num_failures
230
226
231
-
232
- def export_repos (config , ides ):
227
+ def export_repos (config , ides , targets , examples ):
233
228
"""Exports and builds combinations of example programs, targets and IDEs.
234
229
235
- The results are returned in a [key: value] dictionary format:
236
- Where key = The example name from the json config file
237
- value = a list containing: pass_status, successes, export failures, build_failures,
238
- and build_skips
239
-
240
- where pass_status = The overall pass status for the export of the full
241
- set of example programs comprising the example suite.
242
- (IE they must build and export)
243
- True if all examples pass, false otherwise
244
- successes = list of examples that exported and built (if possible)
245
- If the exporter has no build functionality, then it is a pass
246
- if exported
247
- export_failures = list of examples that failed to export.
248
- build_failures = list of examples that failed to build
249
- build_skips = list of examples that cannot build
250
-
251
- Both successes and failures contain the example name, target and IDE
252
-
253
- Args:
254
- config - the json object imported from the file.
255
- ides - List of IDES to export to
256
- """
230
+ The results are returned in a [key: value] dictionary format:
231
+ Where key = The example name from the json config file
232
+ value = a list containing: pass_status, successes, export failures, build_failures,
233
+ and build_skips
234
+
235
+ where pass_status = The overall pass status for the export of the full
236
+ set of example programs comprising the example suite.
237
+ IE they must build and export) True if all examples pass, false otherwise
238
+ successes = list of examples that exported and built (if possible)
239
+ If the exporter has no build functionality, then it is a pass
240
+ if exported
241
+ export_failures = list of examples that failed to export.
242
+ build_failures = list of examples that failed to build
243
+ build_skips = list of examples that cannot build
244
+
245
+ Both successes and failures contain the example name, target and IDE
246
+
247
+ Args:
248
+ config - the json object imported from the file.
249
+ ides - List of IDES to export to
250
+ """
257
251
results = {}
258
252
print ("\n Exporting example repos....\n " )
259
253
for example in config ['examples' ]:
254
+ if example ['name' ] not in examples :
255
+ continue
256
+
260
257
export_failures = []
261
258
build_failures = []
262
259
build_skips = []
@@ -269,9 +266,9 @@ def export_repos(config, ides):
269
266
os .chdir (example_project_name )
270
267
# Check that the target, IDE, and features combinations are valid and return a
271
268
# list of valid combinations to work through
272
- for target , ide in target_cross_ide (ides ,
273
- example ['features' ] ,
274
- example ['targets ' ]):
269
+ for target , ide in target_cross_ide (valid_choices ( example [ 'targets' ], targets ) ,
270
+ valid_choices ( example ['exporters' ], ides ) ,
271
+ example ['features ' ]):
275
272
example_name = "{} {} {}" .format (example_project_name , target ,
276
273
ide )
277
274
def status (message ):
@@ -311,7 +308,7 @@ def status(message):
311
308
return results
312
309
313
310
314
- def compile_repos (config , toolchains ):
311
+ def compile_repos (config , toolchains , targets , examples ):
315
312
"""Compiles combinations of example programs, targets and compile chains.
316
313
317
314
The results are returned in a [key: value] dictionary format:
@@ -334,23 +331,23 @@ def compile_repos(config, toolchains):
334
331
"""
335
332
results = {}
336
333
print ("\n Compiling example repos....\n " )
337
- for example in config ['examples' ]:
334
+ for example in config ['examples' ]:
335
+ if example ['name' ] not in examples :
336
+ continue
338
337
failures = []
339
338
successes = []
340
339
compiled = True
341
340
pass_status = True
342
341
if example ['compile' ]:
343
- if len (example ['toolchains' ]) > 0 :
344
- toolchains = example ['toolchains' ]
345
-
346
342
for repo_info in get_repo_list (example ):
347
343
name = basename (repo_info ['repo' ])
348
344
os .chdir (name )
349
345
350
346
# Check that the target, toolchain and features combinations are valid and return a
351
347
# list of valid combinations to work through
352
- for target , toolchain in target_cross_toolchain (toolchains ,
353
- example ['features' ], example ['targets' ]):
348
+ for target , toolchain in target_cross_toolchain (valid_choices (example ['targets' ], targets ),
349
+ valid_choices (example ['toolchains' ], toolchains ),
350
+ example ['features' ]):
354
351
proc = subprocess .Popen (["mbed-cli" , "compile" , "-t" , toolchain ,
355
352
"-m" , target , "--silent" ])
356
353
proc .wait ()
@@ -372,7 +369,7 @@ def compile_repos(config, toolchains):
372
369
return results
373
370
374
371
375
- def update_mbedos_version (config , tag ):
372
+ def update_mbedos_version (config , tag , examples ):
376
373
""" For each example repo identified in the config json object, update the version of
377
374
mbed-os to that specified by the supplied GitHub tag. This function assumes that each
378
375
example repo has already been cloned.
@@ -384,6 +381,8 @@ def update_mbedos_version(config, tag):
384
381
"""
385
382
print ("Updating mbed-os in examples to version %s\n " % tag )
386
383
for example in config ['examples' ]:
384
+ if example ['name' ] not in examples :
385
+ continue
387
386
for repo_info in get_repo_list (example ):
388
387
update_dir = basename (repo_info ['repo' ]) + "/mbed-os"
389
388
print ("\n Changing dir to %s\n " % update_dir )
0 commit comments