16
16
17
17
from tools .build_api import get_mbed_official_release
18
18
from tools .targets import TARGET_MAP
19
+ from tools .export import EXPORTERS
19
20
20
21
SUPPORTED_TOOLCHAINS = ["ARM" , "IAR" , "GCC_ARM" ]
22
+ SUPPORTED_IDES = ["iar" , "uvision" , "make_gcc_arm" , "make_iar" , "make_armc5" ]
21
23
22
24
def print_list (lst ):
23
25
"""Prints to screen the contents of a list
@@ -30,13 +32,13 @@ def print_list(lst):
30
32
for thing in lst :
31
33
print ("# %s" % thing )
32
34
33
- def print_compilation_summary (results ):
34
- """Prints to screen the results of compiling combinations of example programs,
35
- targets and compile chains .
35
+ def print_summary (results , export = False ):
36
+ """Prints to screen the results of compiling/exporting combinations of example programs,
37
+ targets and compile toolchains/IDEs .
36
38
37
39
Args:
38
- results - results of the compilation stage. See compile_repos() for
39
- details of the format.
40
+ results - results of the compilation stage. See compile_repos() and export_repos()
41
+ for details of the format.
40
42
41
43
"""
42
44
@@ -48,12 +50,23 @@ def print_compilation_summary(results):
48
50
print ("#" )
49
51
for key , val in results .iteritems ():
50
52
print_list (val [2 ])
53
+
54
+ second_result = "Failed example combinations" if not export else \
55
+ "Failed export example combinations"
51
56
52
57
print ("#" )
53
- print ("# Failed example combinations" )
58
+ print ("# %s" % second_result )
54
59
print ("#" )
55
60
for key , val in results .iteritems ():
56
61
print_list (val [3 ])
62
+
63
+ if export :
64
+ print ("#" )
65
+ print ("# Failed build example combinations" )
66
+ print ("#" )
67
+ for key , val in results .iteritems ():
68
+ print_list (val [4 ])
69
+
57
70
print ("#" )
58
71
print ("#" * 80 )
59
72
@@ -81,18 +94,30 @@ def target_cross_toolchain(allowed_toolchains,
81
94
for feature in features )):
82
95
yield target , toolchain
83
96
97
+
84
98
def target_cross_ide (allowed_ides ,
85
- targets = TARGET_MAP . keys () ):
99
+ features = [], targets = [] ):
86
100
"""Generate pairs of target and ides
87
101
88
102
Args:
89
103
allowed_ides - a list of all possible IDEs
90
104
105
+ Kwargs:
106
+ features - the features that must be in the features array of a
107
+ target
108
+ targets - a list of available targets
91
109
"""
92
- for release_target , release_toolchains in get_mbed_official_release ("5" ):
110
+ if len (targets ) == 0 :
111
+ targets = TARGET_MAP .keys ()
112
+
113
+ for target , toolchains in get_mbed_official_release ("5" ):
93
114
for ide in allowed_ides :
94
- if release_target in EXPORTERS [ide ].TARGETS :
95
- yield release_target , ide
115
+ if (EXPORTERS [ide ].TOOLCHAIN in toolchains and
116
+ target in EXPORTERS [ide ].TARGETS and
117
+ target in targets and
118
+ all (feature in TARGET_MAP [target ].features
119
+ for feature in features )):
120
+ yield target , ide
96
121
97
122
98
123
def get_repo_list (example ):
@@ -134,7 +159,7 @@ def source_repos(config):
134
159
135
160
subprocess .call (["mbed-cli" , "import" , repo ])
136
161
137
- def get_num_failures (results ):
162
+ def get_num_failures (results , export = False ):
138
163
""" Returns the number of failed compilations from the results summary
139
164
Args:
140
165
results - results summary of the compilation stage. See compile_repos() for
@@ -146,9 +171,68 @@ def get_num_failures(results):
146
171
147
172
for key , val in results .iteritems ():
148
173
num_failures = num_failures + len (val [3 ])
174
+ if export :
175
+ num_failures += len (val [4 ])
149
176
150
177
return num_failures
151
-
178
+
179
+
180
+ def export_repos (config , ides ):
181
+ def print_message (message , name ):
182
+ print (message + " %s" % name )
183
+ sys .stdout .flush ()
184
+
185
+ results = {}
186
+ print ("\n Exporting example repos....\n " )
187
+ for example in config ['examples' ]:
188
+ export_failures = []
189
+ build_failures = []
190
+ successes = []
191
+ exported = True
192
+ pass_status = True
193
+ if example ['export' ]:
194
+ for repo in get_repo_list (example ):
195
+ example_project_name = basename (repo )
196
+ os .chdir (example_project_name )
197
+ # Check that the target, IDE, and features combinations are valid and return a
198
+ # list of valid combinations to work through
199
+ for target , ide in target_cross_ide (ides ,
200
+ example ['features' ],
201
+ example ['targets' ]):
202
+ example_name = "{} {} {}" .format (example_project_name , target ,
203
+ ide )
204
+ def status (message ):
205
+ print (message + " %s" % example_name )
206
+ sys .stdout .flush ()
207
+
208
+ status ("Exporting" )
209
+ proc = subprocess .Popen (["mbed-cli" , "export" , "-i" , ide ,
210
+ "-m" , target ])
211
+ proc .wait ()
212
+ if proc .returncode :
213
+ export_failures .append (example_name )
214
+ status ("FAILURE exporting" )
215
+ else :
216
+ status ("SUCCESS exporting" )
217
+ status ("Building" )
218
+ if EXPORTERS [ide ].build (example_project_name ):
219
+ status ("FAILURE building" )
220
+ build_failures .append (example_name )
221
+ else :
222
+ status ("SUCCESS building" )
223
+ successes .append (example_name )
224
+ os .chdir (".." )
225
+
226
+ if len (build_failures + export_failures ) > 0 :
227
+ pass_status = False
228
+ else :
229
+ exported = False
230
+
231
+ results [example ['name' ]] = [exported , pass_status , successes , export_failures , build_failures ]
232
+
233
+ return results
234
+
235
+
152
236
def compile_repos (config , toolchains ):
153
237
"""Compiles combinations of example programs, targets and compile chains.
154
238
0 commit comments