mirror of https://github.com/ARMmbed/mbed-os.git
Use Config class to find mbed_app.json
parent
5f5014ef42
commit
b3ba9a55b9
|
@ -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 {}
|
||||
|
|
|
@ -2,6 +2,7 @@ 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"))
|
||||
|
@ -34,8 +35,8 @@ def get_default_config(source_dir, target_name):
|
|||
if config_name == "NONE":
|
||||
return None
|
||||
return join(CONFIG_DIR, CONFIG_MAP[config_name])
|
||||
elif any(exists(join(dir or ".", "mbed_app.json")) for dir in source_dir):
|
||||
config = None
|
||||
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