28
28
sys .path .insert (0 , ROOT )
29
29
from tools .targets import Target , TARGET_MAP , TARGET_NAMES
30
30
31
- MAKE_PY_LOCATTION = os .path .join (ROOT , 'tools' , 'make.py' )
32
- TEST_PY_LOCATTION = os .path .join (ROOT , 'tools' , 'test.py' )
33
31
34
32
logging .basicConfig (level = logging .DEBUG ,
35
33
format = '[%(name)s] %(asctime)s: %(message)s.' ,
@@ -88,6 +86,33 @@ def _get_psa_secure_targets_list():
88
86
return [str (t ) for t in TARGET_NAMES if
89
87
Target .get_target (t ).is_PSA_secure_target ]
90
88
89
+
90
+ def _get_default_image_build_command (target , toolchain , profile ):
91
+ """
92
+ Creates a build command for a default image.
93
+
94
+ :param target: target to be built.
95
+ :param toolchain: toolchain to be used.
96
+ :param profile: build profile.
97
+ :return: Build command in a list form.
98
+ """
99
+ cmd = [
100
+ 'mbed' , 'compile' ,
101
+ '-t' , toolchain ,
102
+ '-m' , target ,
103
+ '--profile' , profile ,
104
+ '--source' , ROOT ,
105
+ '--build' , os .path .join (ROOT , 'BUILD' , target )
106
+ ]
107
+
108
+ if _psa_backend (target ) is 'TFM' :
109
+ cmd += ['--app-config' , TFM_MBED_APP ]
110
+ else :
111
+ cmd += ['--artifact-name' , 'psa_release_1.0' ]
112
+
113
+ return cmd
114
+
115
+
91
116
def get_mbed_official_psa_release (target = None ):
92
117
"""
93
118
Creates a list of PSA targets with default toolchain and
@@ -116,41 +141,28 @@ def create_mbed_ignore(build_dir):
116
141
f .write ('*\n ' )
117
142
118
143
119
- def build_mbed_spm_platform (target , toolchain , profile = 'release' ):
144
+ def build_tests_mbed_spm_platform (target , toolchain , profile ):
120
145
"""
121
146
Builds Secure images for MBED-SPM target.
122
147
123
148
:param target: target to be built.
124
149
:param toolchain: toolchain to be used.
125
150
:param profile: build profile.
126
151
"""
127
- subprocess .check_call ([
128
- sys .executable , TEST_PY_LOCATTION ,
129
- '--greentea' ,
130
- '--profile' , profile ,
131
- '-t' , toolchain ,
132
- '-m' , target ,
133
- '--source' , ROOT ,
134
- '--build' , os .path .join (ROOT , 'BUILD' , 'tests' , target ),
135
- '--test-spec' , os .path .join (ROOT , 'BUILD' , 'tests' ,
136
- target , 'test_spec.json' ),
137
- '--build-data' , os .path .join (ROOT , 'BUILD' , 'tests' ,
138
- target , 'build_data.json' ),
139
- '-n' , MBED_PSA_TESTS
140
- ])
141
152
logger .info (
142
153
"Building tests images({}) for {} using {} with {} profile" .format (
143
154
MBED_PSA_TESTS , target , toolchain , profile ))
144
155
145
156
subprocess .check_call ([
146
- sys . executable , MAKE_PY_LOCATTION ,
157
+ 'mbed' , 'test' , '--compile' ,
147
158
'-t' , toolchain ,
148
159
'-m' , target ,
149
160
'--profile' , profile ,
150
161
'--source' , ROOT ,
151
- '--build' , os .path .join (ROOT , 'BUILD' , target ),
152
- '--artifact-name' , 'psa_release_1.0'
153
- ])
162
+ '--build' , os .path .join (ROOT , 'BUILD' , 'tests' , target ),
163
+ '-n' , MBED_PSA_TESTS ],
164
+ stdout = subprocess_output , stderr = subprocess_err )
165
+
154
166
logger .info (
155
167
"Finished building tests images({}) for {} successfully" .format (
156
168
MBED_PSA_TESTS , target ))
@@ -166,7 +178,7 @@ def _tfm_test_defines(test):
166
178
return ['-D{}' .format (define ) for define in TFM_TESTS [test ]]
167
179
168
180
169
- def build_tfm_platform (target , toolchain , profile = 'release' ):
181
+ def build_tests_tfm_platform (target , toolchain , profile ):
170
182
"""
171
183
Builds Secure images for TF-M target.
172
184
@@ -179,29 +191,16 @@ def build_tfm_platform(target, toolchain, profile='release'):
179
191
"Building tests image({}) for {} using {} with {} profile" .format (
180
192
test , target , toolchain , profile ))
181
193
subprocess .check_call ([
182
- sys .executable , TEST_PY_LOCATTION ,
183
- '--greentea' ,
184
- '--profile' , profile ,
185
- '-t' , toolchain ,
186
- '-m' , target ,
187
- '--source' , ROOT ,
188
- '--build' , os .path .join (ROOT , 'BUILD' , 'tests' , target ),
189
- '--test-spec' , os .path .join (ROOT , 'BUILD' , 'tests' ,
190
- target , 'test_spec.json' ),
191
- '--build-data' , os .path .join (ROOT , 'BUILD' , 'tests' ,
192
- target , 'build_data.json' ),
193
- '--app-config' , TFM_MBED_APP , '-n' , test ] + _tfm_test_defines (test ),
194
- stdout = subprocess .PIPE )
194
+ 'mbed' , 'test' , '--compile' ,
195
+ '-t' , toolchain ,
196
+ '-m' , target ,
197
+ '--profile' , profile ,
198
+ '--source' , ROOT ,
199
+ '--build' , os .path .join (ROOT , 'BUILD' , 'tests' , target ),
200
+ '-n' , MBED_PSA_TESTS ,
201
+ '--app-config' , TFM_MBED_APP , '-n' , test ] + _tfm_test_defines (
202
+ test ), stdout = subprocess_output , stderr = subprocess_err )
195
203
196
- subprocess .check_call ([
197
- sys .executable , MAKE_PY_LOCATTION ,
198
- '-t' , toolchain ,
199
- '-m' , target ,
200
- '--profile' , profile ,
201
- '--source' , ROOT ,
202
- '--build' , os .path .join (ROOT , 'BUILD' , target ),
203
- '--app-config' , TFM_MBED_APP
204
- ])
205
204
logger .info (
206
205
"Finished Building tests image({}) for {}" .format (test , target ))
207
206
@@ -229,7 +228,6 @@ def commit_binaries(target, delivery_dir):
229
228
'add' , os .path .relpath (delivery_dir , ROOT )
230
229
], stdout = subprocess_output , stderr = subprocess_err )
231
230
232
- commit_message = '-m\" Update secure binaries for {}\" ' .format (target )
233
231
logger .info ("Committing images for {}" .format (target ))
234
232
commit_message = '--message="Update secure binaries for {}"' .format (
235
233
target )
@@ -244,7 +242,7 @@ def commit_binaries(target, delivery_dir):
244
242
245
243
246
244
def build_psa_platform (target , toolchain , delivery_dir , debug = False ,
247
- git_commit = False ):
245
+ git_commit = False , skip_tests = False ):
248
246
"""
249
247
Calls the correct build function and commits if requested.
250
248
@@ -253,15 +251,22 @@ def build_psa_platform(target, toolchain, delivery_dir, debug=False,
253
251
:param delivery_dir: Artifact directory, where images should be placed.
254
252
:param debug: Build with debug profile.
255
253
:param git_commit: Commit the changes.
254
+ :param skip_tests: skip the test images build phase.
256
255
"""
257
256
profile = 'debug' if debug else 'release'
258
- if _psa_backend (target ) is 'TFM' :
259
- build_tfm_platform (target , toolchain , profile )
260
- else :
261
- build_mbed_spm_platform (target , toolchain , profile )
257
+ if not skip_tests :
258
+ if _psa_backend (target ) is 'TFM' :
259
+ build_tests_tfm_platform (target , toolchain , profile )
260
+ else :
261
+ build_tests_mbed_spm_platform (target , toolchain , profile )
262
+
262
263
logger .info ("Building default image for {} using {} with {} profile" .format (
263
264
target , toolchain , profile ))
264
265
266
+ subprocess .check_call (
267
+ _get_default_image_build_command (target , toolchain , profile ),
268
+ stdout = subprocess_output , stderr = subprocess_err )
269
+
265
270
logger .info (
266
271
"Finished building default image for {} successfully" .format (target ))
267
272
@@ -291,6 +296,11 @@ def get_parser():
291
296
help = "create a git commit for each platform" ,
292
297
action = "store_true" ,
293
298
default = False )
299
+
300
+ parser .add_argument ('--skip-tests' ,
301
+ action = "store_true" ,
302
+ default = False ,
303
+ help = "skip the test build phase" )
294
304
295
305
return parser
296
306
@@ -324,7 +334,9 @@ def main():
324
334
', ' .join ([t [0 ] for t in psa_platforms_list ])))
325
335
326
336
for target , tc , directory in psa_platforms_list :
327
- build_psa_platform (target , tc , directory , options .debug , options .commit )
337
+ build_psa_platform (target , tc , directory , options .debug ,
338
+ options .commit , options .skip_tests )
339
+
328
340
logger .info ("Finished Updating PSA images" )
329
341
330
342
0 commit comments