mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #5559 from yennster/tools-config-fix
Fix for default test config filepull/5723/head
commit
203fc36157
|
|
@ -372,6 +372,20 @@ class Config(object):
|
|||
"LOWPAN_BORDER_ROUTER", "LOWPAN_HOST", "LOWPAN_ROUTER", "NANOSTACK_FULL", "THREAD_BORDER_ROUTER", "THREAD_END_DEVICE", "THREAD_ROUTER", "ETHERNET_HOST"
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def find_app_config(cls, top_level_dirs):
|
||||
app_config_location = None
|
||||
for directory in top_level_dirs:
|
||||
full_path = os.path.join(directory, cls.__mbed_app_config_name)
|
||||
if os.path.isfile(full_path):
|
||||
if app_config_location is not None:
|
||||
raise ConfigException("Duplicate '%s' file in '%s' and '%s'"
|
||||
% (cls.__mbed_app_config_name,
|
||||
cls.app_config_location, full_path))
|
||||
else:
|
||||
app_config_location = full_path
|
||||
return app_config_location
|
||||
|
||||
def __init__(self, tgt, top_level_dirs=None, app_config=None):
|
||||
"""Construct a mbed configuration
|
||||
|
||||
|
|
@ -391,16 +405,8 @@ class Config(object):
|
|||
"""
|
||||
config_errors = []
|
||||
self.app_config_location = app_config
|
||||
if self.app_config_location is None:
|
||||
for directory in top_level_dirs or []:
|
||||
full_path = os.path.join(directory, self.__mbed_app_config_name)
|
||||
if os.path.isfile(full_path):
|
||||
if self.app_config_location is not None:
|
||||
raise ConfigException("Duplicate '%s' file in '%s' and '%s'"
|
||||
% (self.__mbed_app_config_name,
|
||||
self.app_config_location, full_path))
|
||||
else:
|
||||
self.app_config_location = full_path
|
||||
if self.app_config_location is None and top_level_dirs:
|
||||
self.app_config_location = self.find_app_config(top_level_dirs)
|
||||
try:
|
||||
self.app_config_data = json_file_to_dict(self.app_config_location) \
|
||||
if self.app_config_location else {}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ if __name__ == '__main__':
|
|||
if not config:
|
||||
args_error(parser, "argument --test-config contains invalid path or identifier")
|
||||
elif not options.app_config:
|
||||
config = TestConfig.get_default_config(mcu)
|
||||
config = TestConfig.get_default_config(options.source_dir or ['.'], mcu)
|
||||
else:
|
||||
config = options.app_config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from os.path import dirname, abspath, join
|
||||
from os.path import dirname, abspath, join, exists
|
||||
|
||||
from tools.utils import json_file_to_dict
|
||||
from tools.targets import TARGET_MAP
|
||||
from tools.config import Config
|
||||
|
||||
CONFIG_DIR = dirname(abspath(__file__))
|
||||
CONFIG_MAP = json_file_to_dict(join(CONFIG_DIR, "config_paths.json"))
|
||||
|
|
@ -28,12 +29,14 @@ def get_config_path(conf_name, target_name):
|
|||
else:
|
||||
return None
|
||||
|
||||
def get_default_config(target_name):
|
||||
def get_default_config(source_dir, target_name):
|
||||
if target_name in TARGET_CONFIGS:
|
||||
config_name = TARGET_CONFIGS[target_name]['default_test_configuration']
|
||||
if config_name == "NONE":
|
||||
return None
|
||||
return join(CONFIG_DIR, CONFIG_MAP[config_name])
|
||||
elif Config.find_app_config(source_dir):
|
||||
return None
|
||||
elif (target_name in TARGET_MAP and 'LWIP' in TARGET_MAP[target_name].features):
|
||||
return join(CONFIG_DIR, CONFIG_MAP["ETHERNET"])
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in New Issue