mirror of https://github.com/ARMmbed/mbed-os.git
Refactor
* Use default image command generator. * Call directly to mbed-cli. * Add --skip-tests.pull/10070/head
parent
16bcd5f8e3
commit
654882453b
|
@ -28,8 +28,6 @@ ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||||
sys.path.insert(0, ROOT)
|
sys.path.insert(0, ROOT)
|
||||||
from tools.targets import Target, TARGET_MAP, TARGET_NAMES
|
from tools.targets import Target, TARGET_MAP, TARGET_NAMES
|
||||||
|
|
||||||
MAKE_PY_LOCATTION = os.path.join(ROOT, 'tools', 'make.py')
|
|
||||||
TEST_PY_LOCATTION = os.path.join(ROOT, 'tools', 'test.py')
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG,
|
logging.basicConfig(level=logging.DEBUG,
|
||||||
format='[%(name)s] %(asctime)s: %(message)s.',
|
format='[%(name)s] %(asctime)s: %(message)s.',
|
||||||
|
@ -88,6 +86,33 @@ def _get_psa_secure_targets_list():
|
||||||
return [str(t) for t in TARGET_NAMES if
|
return [str(t) for t in TARGET_NAMES if
|
||||||
Target.get_target(t).is_PSA_secure_target]
|
Target.get_target(t).is_PSA_secure_target]
|
||||||
|
|
||||||
|
|
||||||
|
def _get_default_image_build_command(target, toolchain, profile):
|
||||||
|
"""
|
||||||
|
Creates a build command for a default image.
|
||||||
|
|
||||||
|
:param target: target to be built.
|
||||||
|
:param toolchain: toolchain to be used.
|
||||||
|
:param profile: build profile.
|
||||||
|
:return: Build command in a list form.
|
||||||
|
"""
|
||||||
|
cmd = [
|
||||||
|
'mbed', 'compile',
|
||||||
|
'-t', toolchain,
|
||||||
|
'-m', target,
|
||||||
|
'--profile', profile,
|
||||||
|
'--source', ROOT,
|
||||||
|
'--build', os.path.join(ROOT, 'BUILD', target)
|
||||||
|
]
|
||||||
|
|
||||||
|
if _psa_backend(target) is 'TFM':
|
||||||
|
cmd += ['--app-config', TFM_MBED_APP]
|
||||||
|
else:
|
||||||
|
cmd += ['--artifact-name', 'psa_release_1.0']
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def get_mbed_official_psa_release(target=None):
|
def get_mbed_official_psa_release(target=None):
|
||||||
"""
|
"""
|
||||||
Creates a list of PSA targets with default toolchain and
|
Creates a list of PSA targets with default toolchain and
|
||||||
|
@ -116,7 +141,7 @@ def create_mbed_ignore(build_dir):
|
||||||
f.write('*\n')
|
f.write('*\n')
|
||||||
|
|
||||||
|
|
||||||
def build_mbed_spm_platform(target, toolchain, profile='release'):
|
def build_tests_mbed_spm_platform(target, toolchain, profile):
|
||||||
"""
|
"""
|
||||||
Builds Secure images for MBED-SPM target.
|
Builds Secure images for MBED-SPM target.
|
||||||
|
|
||||||
|
@ -124,33 +149,20 @@ def build_mbed_spm_platform(target, toolchain, profile='release'):
|
||||||
:param toolchain: toolchain to be used.
|
:param toolchain: toolchain to be used.
|
||||||
:param profile: build profile.
|
:param profile: build profile.
|
||||||
"""
|
"""
|
||||||
subprocess.check_call([
|
|
||||||
sys.executable, TEST_PY_LOCATTION,
|
|
||||||
'--greentea',
|
|
||||||
'--profile', profile,
|
|
||||||
'-t', toolchain,
|
|
||||||
'-m', target,
|
|
||||||
'--source', ROOT,
|
|
||||||
'--build', os.path.join(ROOT, 'BUILD', 'tests', target),
|
|
||||||
'--test-spec', os.path.join(ROOT, 'BUILD', 'tests',
|
|
||||||
target, 'test_spec.json'),
|
|
||||||
'--build-data', os.path.join(ROOT, 'BUILD', 'tests',
|
|
||||||
target, 'build_data.json'),
|
|
||||||
'-n', MBED_PSA_TESTS
|
|
||||||
])
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Building tests images({}) for {} using {} with {} profile".format(
|
"Building tests images({}) for {} using {} with {} profile".format(
|
||||||
MBED_PSA_TESTS, target, toolchain, profile))
|
MBED_PSA_TESTS, target, toolchain, profile))
|
||||||
|
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
sys.executable, MAKE_PY_LOCATTION,
|
'mbed', 'test', '--compile',
|
||||||
'-t', toolchain,
|
'-t', toolchain,
|
||||||
'-m', target,
|
'-m', target,
|
||||||
'--profile', profile,
|
'--profile', profile,
|
||||||
'--source', ROOT,
|
'--source', ROOT,
|
||||||
'--build', os.path.join(ROOT, 'BUILD', target),
|
'--build', os.path.join(ROOT, 'BUILD', 'tests', target),
|
||||||
'--artifact-name', 'psa_release_1.0'
|
'-n', MBED_PSA_TESTS],
|
||||||
])
|
stdout=subprocess_output, stderr=subprocess_err)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Finished building tests images({}) for {} successfully".format(
|
"Finished building tests images({}) for {} successfully".format(
|
||||||
MBED_PSA_TESTS, target))
|
MBED_PSA_TESTS, target))
|
||||||
|
@ -166,7 +178,7 @@ def _tfm_test_defines(test):
|
||||||
return ['-D{}'.format(define) for define in TFM_TESTS[test]]
|
return ['-D{}'.format(define) for define in TFM_TESTS[test]]
|
||||||
|
|
||||||
|
|
||||||
def build_tfm_platform(target, toolchain, profile='release'):
|
def build_tests_tfm_platform(target, toolchain, profile):
|
||||||
"""
|
"""
|
||||||
Builds Secure images for TF-M target.
|
Builds Secure images for TF-M target.
|
||||||
|
|
||||||
|
@ -179,29 +191,16 @@ def build_tfm_platform(target, toolchain, profile='release'):
|
||||||
"Building tests image({}) for {} using {} with {} profile".format(
|
"Building tests image({}) for {} using {} with {} profile".format(
|
||||||
test, target, toolchain, profile))
|
test, target, toolchain, profile))
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
sys.executable, TEST_PY_LOCATTION,
|
'mbed', 'test', '--compile',
|
||||||
'--greentea',
|
'-t', toolchain,
|
||||||
'--profile', profile,
|
'-m', target,
|
||||||
'-t', toolchain,
|
'--profile', profile,
|
||||||
'-m', target,
|
'--source', ROOT,
|
||||||
'--source', ROOT,
|
'--build', os.path.join(ROOT, 'BUILD', 'tests', target),
|
||||||
'--build', os.path.join(ROOT, 'BUILD', 'tests', target),
|
'-n', MBED_PSA_TESTS,
|
||||||
'--test-spec', os.path.join(ROOT, 'BUILD', 'tests',
|
'--app-config', TFM_MBED_APP, '-n', test] + _tfm_test_defines(
|
||||||
target, 'test_spec.json'),
|
test), stdout=subprocess_output, stderr=subprocess_err)
|
||||||
'--build-data', os.path.join(ROOT, 'BUILD', 'tests',
|
|
||||||
target, 'build_data.json'),
|
|
||||||
'--app-config', TFM_MBED_APP, '-n', test] + _tfm_test_defines(test),
|
|
||||||
stdout=subprocess.PIPE)
|
|
||||||
|
|
||||||
subprocess.check_call([
|
|
||||||
sys.executable, MAKE_PY_LOCATTION,
|
|
||||||
'-t', toolchain,
|
|
||||||
'-m', target,
|
|
||||||
'--profile', profile,
|
|
||||||
'--source', ROOT,
|
|
||||||
'--build', os.path.join(ROOT, 'BUILD', target),
|
|
||||||
'--app-config', TFM_MBED_APP
|
|
||||||
])
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Finished Building tests image({}) for {}".format(test, target))
|
"Finished Building tests image({}) for {}".format(test, target))
|
||||||
|
|
||||||
|
@ -229,7 +228,6 @@ def commit_binaries(target, delivery_dir):
|
||||||
'add', os.path.relpath(delivery_dir, ROOT)
|
'add', os.path.relpath(delivery_dir, ROOT)
|
||||||
], stdout=subprocess_output, stderr=subprocess_err)
|
], stdout=subprocess_output, stderr=subprocess_err)
|
||||||
|
|
||||||
commit_message = '-m\"Update secure binaries for {}\"'.format(target)
|
|
||||||
logger.info("Committing images for {}".format(target))
|
logger.info("Committing images for {}".format(target))
|
||||||
commit_message = '--message="Update secure binaries for {}"'.format(
|
commit_message = '--message="Update secure binaries for {}"'.format(
|
||||||
target)
|
target)
|
||||||
|
@ -244,7 +242,7 @@ def commit_binaries(target, delivery_dir):
|
||||||
|
|
||||||
|
|
||||||
def build_psa_platform(target, toolchain, delivery_dir, debug=False,
|
def build_psa_platform(target, toolchain, delivery_dir, debug=False,
|
||||||
git_commit=False):
|
git_commit=False, skip_tests=False):
|
||||||
"""
|
"""
|
||||||
Calls the correct build function and commits if requested.
|
Calls the correct build function and commits if requested.
|
||||||
|
|
||||||
|
@ -253,15 +251,22 @@ def build_psa_platform(target, toolchain, delivery_dir, debug=False,
|
||||||
:param delivery_dir: Artifact directory, where images should be placed.
|
:param delivery_dir: Artifact directory, where images should be placed.
|
||||||
:param debug: Build with debug profile.
|
:param debug: Build with debug profile.
|
||||||
:param git_commit: Commit the changes.
|
:param git_commit: Commit the changes.
|
||||||
|
:param skip_tests: skip the test images build phase.
|
||||||
"""
|
"""
|
||||||
profile = 'debug' if debug else 'release'
|
profile = 'debug' if debug else 'release'
|
||||||
if _psa_backend(target) is 'TFM':
|
if not skip_tests:
|
||||||
build_tfm_platform(target, toolchain, profile)
|
if _psa_backend(target) is 'TFM':
|
||||||
else:
|
build_tests_tfm_platform(target, toolchain, profile)
|
||||||
build_mbed_spm_platform(target, toolchain, profile)
|
else:
|
||||||
|
build_tests_mbed_spm_platform(target, toolchain, profile)
|
||||||
|
|
||||||
logger.info("Building default image for {} using {} with {} profile".format(
|
logger.info("Building default image for {} using {} with {} profile".format(
|
||||||
target, toolchain, profile))
|
target, toolchain, profile))
|
||||||
|
|
||||||
|
subprocess.check_call(
|
||||||
|
_get_default_image_build_command(target, toolchain, profile),
|
||||||
|
stdout=subprocess_output, stderr=subprocess_err)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Finished building default image for {} successfully".format(target))
|
"Finished building default image for {} successfully".format(target))
|
||||||
|
|
||||||
|
@ -291,6 +296,11 @@ def get_parser():
|
||||||
help="create a git commit for each platform",
|
help="create a git commit for each platform",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False)
|
default=False)
|
||||||
|
|
||||||
|
parser.add_argument('--skip-tests',
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="skip the test build phase")
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -324,7 +334,9 @@ def main():
|
||||||
', '.join([t[0] for t in psa_platforms_list])))
|
', '.join([t[0] for t in psa_platforms_list])))
|
||||||
|
|
||||||
for target, tc, directory in psa_platforms_list:
|
for target, tc, directory in psa_platforms_list:
|
||||||
build_psa_platform(target, tc, directory, options.debug, options.commit)
|
build_psa_platform(target, tc, directory, options.debug,
|
||||||
|
options.commit, options.skip_tests)
|
||||||
|
|
||||||
logger.info("Finished Updating PSA images")
|
logger.info("Finished Updating PSA images")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue