@@ -75,52 +75,46 @@ def print_summary(results, export=False):
7575
7676 print ("#" )
7777 print ("#" * 80 )
78-
7978
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 = []):
8287 """Generate pairs of target and toolchains
8388
8489 Args:
90+ allowed_targets - a list of all possible targets
8591 allowed_toolchains - a list of all possible toolchains
8692
8793 Kwargs:
8894 features - the features that must be in the features array of a
8995 target
90- targets - a list of available targets
9196 """
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 ):
101101 yield target , toolchain
102102
103103
104- def target_cross_ide (allowed_ides ,
105- features = [], targets = []):
104+ def target_cross_ide (allowed_targets , allowed_ides , features = []):
106105 """Generate pairs of target and ides
107106
108107 Args:
108+ allowed_targets - a list of all possible targets
109109 allowed_ides - a list of all possible IDEs
110110
111111 Kwargs:
112112 features - the features that must be in the features array of a
113113 target
114- targets - a list of available targets
115114 """
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 :
120116 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
124118 all (feature in TARGET_MAP [target ].features
125119 for feature in features )):
126120 yield target , ide
@@ -154,7 +148,7 @@ def get_repo_list(example):
154148 return repos
155149
156150
157- def source_repos (config ):
151+ def source_repos (config , examples ):
158152 """ Imports each of the repos and its dependencies (.lib files) associated
159153 with the specific examples name from the json config file. Note if
160154 there is already a clone of the repo then it will first be removed to
@@ -167,13 +161,14 @@ def source_repos(config):
167161 for example in config ['examples' ]:
168162 for repo_info in get_repo_list (example ):
169163 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 )
175168
176- def clone_repos (config ):
169+ subprocess .call (["mbed-cli" , "import" , repo_info ['repo' ]])
170+
171+ def clone_repos (config , examples ):
177172 """ Clones each of the repos associated with the specific examples name from the
178173 json config file. Note if there is already a clone of the repo then it will first
179174 be removed to ensure a clean, up to date cloning.
@@ -185,13 +180,14 @@ def clone_repos(config):
185180 for example in config ['examples' ]:
186181 for repo_info in get_repo_list (example ):
187182 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 )
191187
192- subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
188+ subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
193189
194- def deploy_repos (config ):
190+ def deploy_repos (config , examples ):
195191 """ If the example directory exists as provided by the json config file,
196192 pull in the examples dependencies by using `mbed-cli deploy`.
197193 Args:
@@ -202,13 +198,13 @@ def deploy_repos(config):
202198 for example in config ['examples' ]:
203199 for repo_info in get_repo_list (example ):
204200 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 )
212208
213209
214210def get_num_failures (results , export = False ):
@@ -228,35 +224,36 @@ def get_num_failures(results, export=False):
228224
229225 return num_failures
230226
231-
232- def export_repos (config , ides ):
227+ def export_repos (config , ides , targets , examples ):
233228 """Exports and builds combinations of example programs, targets and IDEs.
234229
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+ """
257251 results = {}
258252 print ("\n Exporting example repos....\n " )
259253 for example in config ['examples' ]:
254+ if example ['name' ] not in examples :
255+ continue
256+
260257 export_failures = []
261258 build_failures = []
262259 build_skips = []
@@ -269,9 +266,9 @@ def export_repos(config, ides):
269266 os .chdir (example_project_name )
270267 # Check that the target, IDE, and features combinations are valid and return a
271268 # 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 ' ]):
275272 example_name = "{} {} {}" .format (example_project_name , target ,
276273 ide )
277274 def status (message ):
@@ -311,7 +308,7 @@ def status(message):
311308 return results
312309
313310
314- def compile_repos (config , toolchains ):
311+ def compile_repos (config , toolchains , targets , examples ):
315312 """Compiles combinations of example programs, targets and compile chains.
316313
317314 The results are returned in a [key: value] dictionary format:
@@ -334,23 +331,23 @@ def compile_repos(config, toolchains):
334331 """
335332 results = {}
336333 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
338337 failures = []
339338 successes = []
340339 compiled = True
341340 pass_status = True
342341 if example ['compile' ]:
343- if len (example ['toolchains' ]) > 0 :
344- toolchains = example ['toolchains' ]
345-
346342 for repo_info in get_repo_list (example ):
347343 name = basename (repo_info ['repo' ])
348344 os .chdir (name )
349345
350346 # Check that the target, toolchain and features combinations are valid and return a
351347 # 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' ]):
354351 proc = subprocess .Popen (["mbed-cli" , "compile" , "-t" , toolchain ,
355352 "-m" , target , "--silent" ])
356353 proc .wait ()
@@ -372,7 +369,7 @@ def compile_repos(config, toolchains):
372369 return results
373370
374371
375- def update_mbedos_version (config , tag ):
372+ def update_mbedos_version (config , tag , examples ):
376373 """ For each example repo identified in the config json object, update the version of
377374 mbed-os to that specified by the supplied GitHub tag. This function assumes that each
378375 example repo has already been cloned.
@@ -384,6 +381,8 @@ def update_mbedos_version(config, tag):
384381 """
385382 print ("Updating mbed-os in examples to version %s\n " % tag )
386383 for example in config ['examples' ]:
384+ if example ['name' ] not in examples :
385+ continue
387386 for repo_info in get_repo_list (example ):
388387 update_dir = basename (repo_info ['repo' ]) + "/mbed-os"
389388 print ("\n Changing dir to %s\n " % update_dir )
0 commit comments