1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

depends.py: merge set/unset config option into one function

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
Andrzej Kurek
2023-01-23 07:19:22 -05:00
parent 3f93012bf1
commit 3b0215d453

View File

@ -71,7 +71,7 @@ import shutil
import subprocess import subprocess
import sys import sys
import traceback import traceback
# Add the Mbed TLS Python library directory to the module search path
import scripts_path # pylint: disable=unused-import import scripts_path # pylint: disable=unused-import
import config import config
@ -140,22 +140,22 @@ def option_exists(conf, option):
return False return False
return True return True
def set_config_option(conf, option, colors, value=None): def set_config_option_value(conf, option, colors, value):
"""Set configuration option, optionally specifying a value""" """Set/unset a configuration option, optionally specifying a value"""
if not option_exists(conf, option): if not option_exists(conf, option):
log_line('Symbol {} was not found in {}'.format(option, conf.filename), color=colors.red) log_line('Symbol {} was not found in {}'.format(option, conf.filename), color=colors.red)
return False return False
log_command(['config.py', 'set', option])
conf.set(option, value)
return True
def unset_config_option(conf, option, colors): if value is False:
"""Unset configuration option if it exists""" log_command(['config.py', 'unset', option])
if not option_exists(conf, option): conf.unset(option)
log_line('Symbol {} was not found in {}'.format(option, conf.filename), color=colors.red) else:
return False if value is True:
log_command(['config.py', 'unset', option]) log_command(['config.py', 'set', option])
conf.unset(option) conf.set(option)
else:
log_command(['config.py', 'set', option, value])
conf.set(option, value)
return True return True
def set_reference_config(conf, options, colors): def set_reference_config(conf, options, colors):
@ -165,9 +165,9 @@ derived."""
# Turn off options that are not relevant to the tests and slow them down. # Turn off options that are not relevant to the tests and slow them down.
log_command(['config.py', 'full']) log_command(['config.py', 'full'])
conf.adapt(config.full_adapter) conf.adapt(config.full_adapter)
unset_config_option(conf, 'MBEDTLS_TEST_HOOKS', colors) set_config_option_value(conf, 'MBEDTLS_TEST_HOOKS', colors, False)
if options.unset_use_psa: if options.unset_use_psa:
unset_config_option(conf, 'MBEDTLS_USE_PSA_CRYPTO', colors) set_config_option_value(conf, 'MBEDTLS_USE_PSA_CRYPTO', colors, False)
class Job: class Job:
"""A job builds the library in a specific configuration and runs some tests.""" """A job builds the library in a specific configuration and runs some tests."""
@ -201,13 +201,7 @@ If what is False, announce that the job has failed.'''
'''Set library configuration options as required for the job.''' '''Set library configuration options as required for the job.'''
set_reference_config(conf, options, colors) set_reference_config(conf, options, colors)
for key, value in sorted(self.config_settings.items()): for key, value in sorted(self.config_settings.items()):
ret = False ret = set_config_option_value(conf, key, colors, value)
if value is True:
ret = set_config_option(conf, key, colors)
elif value is False:
ret = unset_config_option(conf, key, colors)
else:
ret = set_config_option(conf, key, colors, value)
if ret is False: if ret is False:
return False return False
return True return True