@@ -76,57 +76,48 @@ def print_summary(results, export=False):
76
76
print ("#" )
77
77
print ("#" * 80 )
78
78
79
- def valid_targets ( allowed_targets , targets ):
80
- if len (allowed_targets ) > 0 :
81
- return [t for t in targets if t in allowed_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
82
else :
83
- return targets
83
+ return all_choices
84
84
85
85
86
- def target_cross_toolchain (allowed_toolchains ,
87
- features = [], targets = []):
86
+ def target_cross_toolchain (allowed_targets , allowed_toolchains , features = []):
88
87
"""Generate pairs of target and toolchains
89
88
90
89
Args:
90
+ allowed_targets - a list of all possible targets
91
91
allowed_toolchains - a list of all possible toolchains
92
92
93
93
Kwargs:
94
94
features - the features that must be in the features array of a
95
95
target
96
- targets - a list of available targets
97
96
"""
98
- if len (targets ) == 0 :
99
- targets = TARGET_MAP .keys ()
100
-
101
- for target , toolchains in get_mbed_official_release ("5" ):
102
- for toolchain in toolchains :
103
- if (toolchain in allowed_toolchains and
104
- target in targets and
105
- all (feature in TARGET_MAP [target ].features
106
- 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 ):
107
101
yield target , toolchain
108
102
109
103
110
- def target_cross_ide (allowed_ides ,
111
- features = [], targets = []):
104
+ def target_cross_ide (allowed_targets , allowed_ides , features = []):
112
105
"""Generate pairs of target and ides
113
106
114
107
Args:
108
+ allowed_targets - a list of all possible targets
115
109
allowed_ides - a list of all possible IDEs
116
110
117
111
Kwargs:
118
112
features - the features that must be in the features array of a
119
113
target
120
- targets - a list of available targets
121
114
"""
122
- if len (targets ) == 0 :
123
- targets = TARGET_MAP .keys ()
124
-
125
- for target , toolchains in get_mbed_official_release ("5" ):
115
+ for target in allowed_targets :
126
116
for ide in allowed_ides :
127
- if (EXPORTERS [ide ].TOOLCHAIN in toolchains and
128
- target in EXPORTERS [ide ].TARGETS and
129
- target in targets and
117
+ if all (feature in TARGET_MAP [target ].features
118
+ for feature in features ):
119
+ yield target , toolchain
120
+ if (target in EXPORTERS [ide ].TARGETS and
130
121
all (feature in TARGET_MAP [target ].features
131
122
for feature in features )):
132
123
yield target , ide
@@ -160,7 +151,7 @@ def get_repo_list(example):
160
151
return repos
161
152
162
153
163
- def source_repos (config ):
154
+ def source_repos (config , examples ):
164
155
""" Imports each of the repos and its dependencies (.lib files) associated
165
156
with the specific examples name from the json config file. Note if
166
157
there is already a clone of the repo then it will first be removed to
@@ -173,13 +164,14 @@ def source_repos(config):
173
164
for example in config ['examples' ]:
174
165
for repo_info in get_repo_list (example ):
175
166
name = basename (repo_info ['repo' ])
176
- if os .path .exists (name ):
177
- print ("'%s' example directory already exists. Deleting..." % name )
178
- rmtree (name )
179
-
180
- subprocess .call (["mbed-cli" , "import" , repo_info ['repo' ]])
167
+ if name in examples :
168
+ if os .path .exists (name ):
169
+ print ("'%s' example directory already exists. Deleting..." % name )
170
+ rmtree (name )
181
171
182
- def clone_repos (config ):
172
+ subprocess .call (["mbed-cli" , "import" , repo_info ['repo' ]])
173
+
174
+ def clone_repos (config , examples ):
183
175
""" Clones each of the repos associated with the specific examples name from the
184
176
json config file. Note if there is already a clone of the repo then it will first
185
177
be removed to ensure a clean, up to date cloning.
@@ -191,13 +183,14 @@ def clone_repos(config):
191
183
for example in config ['examples' ]:
192
184
for repo_info in get_repo_list (example ):
193
185
name = basename (repo_info ['repo' ])
194
- if os .path .exists (name ):
195
- print ("'%s' example directory already exists. Deleting..." % name )
196
- rmtree (name )
186
+ if name in examples :
187
+ if os .path .exists (name ):
188
+ print ("'%s' example directory already exists. Deleting..." % name )
189
+ rmtree (name )
197
190
198
- subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
191
+ subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
199
192
200
- def deploy_repos (config ):
193
+ def deploy_repos (config , examples ):
201
194
""" If the example directory exists as provided by the json config file,
202
195
pull in the examples dependencies by using `mbed-cli deploy`.
203
196
Args:
@@ -208,13 +201,13 @@ def deploy_repos(config):
208
201
for example in config ['examples' ]:
209
202
for repo_info in get_repo_list (example ):
210
203
name = basename (repo_info ['repo' ])
211
-
212
- if os .path .exists (name ):
213
- os .chdir (name )
214
- subprocess .call (["mbed-cli" , "deploy" ])
215
- os .chdir (".." )
216
- else :
217
- print ("'%s' example directory doesn't exist. Skipping..." % name )
204
+ if name in examples :
205
+ if os .path .exists (name ):
206
+ os .chdir (name )
207
+ subprocess .call (["mbed-cli" , "deploy" ])
208
+ os .chdir (".." )
209
+ else :
210
+ print ("'%s' example directory doesn't exist. Skipping..." % name )
218
211
219
212
220
213
def get_num_failures (results , export = False ):
@@ -276,9 +269,9 @@ def export_repos(config, ides, targets, examples):
276
269
os .chdir (example_project_name )
277
270
# Check that the target, IDE, and features combinations are valid and return a
278
271
# list of valid combinations to work through
279
- for target , ide in target_cross_ide (ides ,
280
- example ['features' ] ,
281
- valid_targets ( example ['targets' ], targets ) ):
272
+ for target , ide in target_cross_ide (valid_choices ( example [ 'targets' ], targets ) ,
273
+ valid_choices ( example ['exporters' ], ides ) ,
274
+ example ['features' ] ):
282
275
example_name = "{} {} {}" .format (example_project_name , target ,
283
276
ide )
284
277
def status (message ):
@@ -349,18 +342,15 @@ def compile_repos(config, toolchains, targets, examples):
349
342
compiled = True
350
343
pass_status = True
351
344
if example ['compile' ]:
352
- if len (example ['toolchains' ]) > 0 :
353
- toolchains = example ['toolchains' ]
354
-
355
345
for repo_info in get_repo_list (example ):
356
346
name = basename (repo_info ['repo' ])
357
347
os .chdir (name )
358
348
359
349
# Check that the target, toolchain and features combinations are valid and return a
360
350
# list of valid combinations to work through
361
- for target , toolchain in target_cross_toolchain (toolchains ,
362
- example ['features' ] ,
363
- valid_targets ( example ['targets' ], targets ) ):
351
+ for target , toolchain in target_cross_toolchain (valid_choices ( example [ 'targets' ], targets ) ,
352
+ valid_choices ( example ['toolchains' ], toolchains ) ,
353
+ example ['features' ] ):
364
354
proc = subprocess .Popen (["mbed-cli" , "compile" , "-t" , toolchain ,
365
355
"-m" , target , "--silent" ])
366
356
proc .wait ()
0 commit comments