@@ -136,35 +136,79 @@ def get_repo_list(example):
136
136
137
137
Args:
138
138
example - Example for which the repo list is requested
139
- repos - The list of repos contained within that example in the json file
139
+ repos - The list of repos and types contained within that example in the json file
140
140
141
141
"""
142
142
repos = []
143
143
if len (example ['mbed' ]) > 0 :
144
144
for repo in example ['mbed' ]:
145
- repos .append (repo )
145
+ repos .append ({
146
+ 'repo' : repo ,
147
+ 'type' : 'hg'
148
+ })
146
149
else :
147
- repos .append (example ['github' ])
150
+ repos .append ({
151
+ 'repo' : example ['github' ],
152
+ 'type' : 'git'
153
+ })
148
154
return repos
149
155
150
156
151
157
def source_repos (config ):
152
- """ Clones each of the repos associated with the specific examples name from the
153
- json config file. Note if there is already a clone of the repo then it will first
154
- be removed to ensure a clean, up to date cloning.
158
+ """ Imports each of the repos and its dependencies (.lib files) associated
159
+ with the specific examples name from the json config file. Note if
160
+ there is already a clone of the repo then it will first be removed to
161
+ ensure a clean, up to date cloning.
155
162
Args:
156
163
config - the json object imported from the file.
157
164
158
165
"""
159
166
print ("\n Importing example repos....\n " )
160
167
for example in config ['examples' ]:
161
- for repo in get_repo_list (example ):
162
- name = basename (repo )
168
+ for repo_info in get_repo_list (example ):
169
+ name = basename (repo_info [ ' repo' ] )
163
170
if os .path .exists (name ):
164
171
print ("'%s' example directory already exists. Deleting..." % name )
165
172
rmtree (name )
166
173
167
- subprocess .call (["mbed-cli" , "import" , repo ])
174
+ subprocess .call (["mbed-cli" , "import" , repo_info ['repo' ]])
175
+
176
+ def clone_repos (config ):
177
+ """ Clones each of the repos associated with the specific examples name from the
178
+ json config file. Note if there is already a clone of the repo then it will first
179
+ be removed to ensure a clean, up to date cloning.
180
+ Args:
181
+ config - the json object imported from the file.
182
+
183
+ """
184
+ print ("\n Cloning example repos....\n " )
185
+ for example in config ['examples' ]:
186
+ for repo_info in get_repo_list (example ):
187
+ name = basename (repo_info ['repo' ])
188
+ if os .path .exists (name ):
189
+ print ("'%s' example directory already exists. Deleting..." % name )
190
+ rmtree (name )
191
+
192
+ subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
193
+
194
+ def deploy_repos (config ):
195
+ """ If the example directory exists as provided by the json config file,
196
+ pull in the examples dependencies by using `mbed-cli deploy`.
197
+ Args:
198
+ config - the json object imported from the file.
199
+
200
+ """
201
+ print ("\n Deploying example repos....\n " )
202
+ for example in config ['examples' ]:
203
+ for repo_info in get_repo_list (example ):
204
+ 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 )
168
212
169
213
170
214
def get_num_failures (results , export = False ):
@@ -220,8 +264,8 @@ def export_repos(config, ides):
220
264
exported = True
221
265
pass_status = True
222
266
if example ['export' ]:
223
- for repo in get_repo_list (example ):
224
- example_project_name = basename (repo )
267
+ for repo_info in get_repo_list (example ):
268
+ example_project_name = basename (repo_info [ ' repo' ] )
225
269
os .chdir (example_project_name )
226
270
# Check that the target, IDE, and features combinations are valid and return a
227
271
# list of valid combinations to work through
@@ -299,8 +343,9 @@ def compile_repos(config, toolchains):
299
343
if len (example ['toolchains' ]) > 0 :
300
344
toolchains = example ['toolchains' ]
301
345
302
- for repo in get_repo_list (example ):
303
- os .chdir (basename (repo ))
346
+ for repo_info in get_repo_list (example ):
347
+ name = basename (repo_info ['repo' ])
348
+ os .chdir (name )
304
349
305
350
# Check that the target, toolchain and features combinations are valid and return a
306
351
# list of valid combinations to work through
@@ -309,7 +354,7 @@ def compile_repos(config, toolchains):
309
354
proc = subprocess .Popen (["mbed-cli" , "compile" , "-t" , toolchain ,
310
355
"-m" , target , "--silent" ])
311
356
proc .wait ()
312
- example_summary = "{} {} {}" .format (basename ( repo ) , target , toolchain )
357
+ example_summary = "{} {} {}" .format (name , target , toolchain )
313
358
if proc .returncode :
314
359
failures .append (example_summary )
315
360
else :
@@ -339,8 +384,8 @@ def update_mbedos_version(config, tag):
339
384
"""
340
385
print ("Updating mbed-os in examples to version %s\n " % tag )
341
386
for example in config ['examples' ]:
342
- for repo in get_repo_list (example ):
343
- update_dir = basename (repo ) + "/mbed-os"
387
+ for repo_info in get_repo_list (example ):
388
+ update_dir = basename (repo_info [ ' repo' ] ) + "/mbed-os"
344
389
print ("\n Changing dir to %s\n " % update_dir )
345
390
os .chdir (update_dir )
346
391
subprocess .call (["mbed-cli" , "update" , tag , "--clean" ])
0 commit comments