@@ -130,34 +130,78 @@ def get_repo_list(example):
130
130
131
131
Args:
132
132
example - Example for which the repo list is requested
133
- repos - The list of repos contained within that example in the json file
133
+ repos - The list of repos and types contained within that example in the json file
134
134
135
135
"""
136
136
repos = []
137
137
if len (example ['mbed' ]) > 0 :
138
138
for repo in example ['mbed' ]:
139
- repos .append (repo )
139
+ repos .append ({
140
+ 'repo' : repo ,
141
+ 'type' : 'hg'
142
+ })
140
143
else :
141
- repos .append (example ['github' ])
144
+ repos .append ({
145
+ 'repo' : example ['github' ],
146
+ 'type' : 'git'
147
+ })
142
148
return repos
143
149
144
150
def source_repos (config ):
145
- """ Clones each of the repos associated with the specific examples name from the
146
- json config file. Note if there is already a clone of the repo then it will first
147
- be removed to ensure a clean, up to date cloning.
151
+ """ Imports each of the repos and its dependencies (.lib files) associated
152
+ with the specific examples name from the json config file. Note if
153
+ there is already a clone of the repo then it will first be removed to
154
+ ensure a clean, up to date cloning.
148
155
Args:
149
156
config - the json object imported from the file.
150
157
151
158
"""
152
159
print ("\n Importing example repos....\n " )
153
160
for example in config ['examples' ]:
154
- for repo in get_repo_list (example ):
155
- name = basename (repo )
161
+ for repo_info in get_repo_list (example ):
162
+ name = basename (repo_info [ ' repo' ] )
156
163
if os .path .exists (name ):
157
164
print ("'%s' example directory already exists. Deleting..." % name )
158
165
rmtree (name )
159
166
160
- subprocess .call (["mbed-cli" , "import" , repo ])
167
+ subprocess .call (["mbed-cli" , "import" , repo_info ['repo' ]])
168
+
169
+ def clone_repos (config ):
170
+ """ Clones each of the repos associated with the specific examples name from the
171
+ json config file. Note if there is already a clone of the repo then it will first
172
+ be removed to ensure a clean, up to date cloning.
173
+ Args:
174
+ config - the json object imported from the file.
175
+
176
+ """
177
+ print ("\n Cloning example repos....\n " )
178
+ for example in config ['examples' ]:
179
+ for repo_info in get_repo_list (example ):
180
+ name = basename (repo_info ['repo' ])
181
+ if os .path .exists (name ):
182
+ print ("'%s' example directory already exists. Deleting..." % name )
183
+ rmtree (name )
184
+
185
+ subprocess .call ([repo_info ['type' ], "clone" , repo_info ['repo' ]])
186
+
187
+ def deploy_repos (config ):
188
+ """ If the example directory exists as provided by the json config file,
189
+ pull in the examples dependencies by using `mbed-cli deploy`.
190
+ Args:
191
+ config - the json object imported from the file.
192
+
193
+ """
194
+ print ("\n Deploying example repos....\n " )
195
+ for example in config ['examples' ]:
196
+ for repo_info in get_repo_list (example ):
197
+ name = basename (repo_info ['repo' ])
198
+
199
+ if os .path .exists (name ):
200
+ os .chdir (name )
201
+ subprocess .call (["mbed-cli" , "deploy" ])
202
+ os .chdir (".." )
203
+ else :
204
+ print ("'%s' example directory doesn't exist. Skipping..." % name )
161
205
162
206
def get_num_failures (results , export = False ):
163
207
""" Returns the number of failed compilations from the results summary
@@ -191,8 +235,8 @@ def print_message(message, name):
191
235
exported = True
192
236
pass_status = True
193
237
if example ['export' ]:
194
- for repo in get_repo_list (example ):
195
- example_project_name = basename (repo )
238
+ for repo_info in get_repo_list (example ):
239
+ example_project_name = basename (repo_info [ ' repo' ] )
196
240
os .chdir (example_project_name )
197
241
# Check that the target, IDE, and features combinations are valid and return a
198
242
# list of valid combinations to work through
@@ -265,8 +309,9 @@ def compile_repos(config, toolchains):
265
309
if len (example ['toolchains' ]) > 0 :
266
310
toolchains = example ['toolchains' ]
267
311
268
- for repo in get_repo_list (example ):
269
- os .chdir (basename (repo ))
312
+ for repo_info in get_repo_list (example ):
313
+ name = basename (repo_info ['repo' ])
314
+ os .chdir (name )
270
315
271
316
# Check that the target, toolchain and features combinations are valid and return a
272
317
# list of valid combinations to work through
@@ -275,7 +320,7 @@ def compile_repos(config, toolchains):
275
320
proc = subprocess .Popen (["mbed-cli" , "compile" , "-t" , toolchain ,
276
321
"-m" , target , "--silent" ])
277
322
proc .wait ()
278
- example_summary = "{} {} {}" .format (basename ( repo ) , target , toolchain )
323
+ example_summary = "{} {} {}" .format (name , target , toolchain )
279
324
if proc .returncode :
280
325
failures .append (example_summary )
281
326
else :
@@ -305,8 +350,8 @@ def update_mbedos_version(config, tag):
305
350
"""
306
351
print ("Updating mbed-os in examples to version %s\n " % tag )
307
352
for example in config ['examples' ]:
308
- for repo in get_repo_list (example ):
309
- update_dir = basename (repo ) + "/mbed-os"
353
+ for repo_info in get_repo_list (example ):
354
+ update_dir = basename (repo_info [ ' repo' ] ) + "/mbed-os"
310
355
print ("\n Changing dir to %s\n " % update_dir )
311
356
os .chdir (update_dir )
312
357
subprocess .call (["mbed-cli" , "update" , tag , "--clean" ])
0 commit comments