|
19 | 19 | logger = logging.getLogger(__name__)
|
20 | 20 |
|
21 | 21 | # Mbed program file names and constants.
|
22 |
| -APP_CONFIG_FILE_NAME = "mbed_app.json" |
| 22 | +APP_CONFIG_FILE_NAME_JSON = "mbed_app.json" |
| 23 | +APP_CONFIG_FILE_NAME_JSON5 = "mbed_app.json5" |
23 | 24 | BUILD_DIR = "cmake_build"
|
24 | 25 | CMAKELISTS_FILE_NAME = "CMakeLists.txt"
|
25 | 26 | MAIN_CPP_FILE_NAME = "main.cpp"
|
26 | 27 | MBED_OS_REFERENCE_FILE_NAME = "mbed-os.lib"
|
27 | 28 | MBED_OS_DIR_NAME = "mbed-os"
|
28 |
| -TARGETS_JSON_FILE_PATH = Path("targets", "targets.json") |
| 29 | +TARGETS_JSON_FILE_PATH = Path("targets", "targets.json5") |
29 | 30 | CUSTOM_TARGETS_JSON_FILE_NAME = "custom_targets.json"
|
| 31 | +CUSTOM_TARGETS_JSON5_FILE_NAME = "custom_targets.json5" |
30 | 32 |
|
31 | 33 | # Information written to mbed-os.lib
|
32 | 34 | MBED_OS_REFERENCE_URL = "https://github.com/ARMmbed/mbed-os"
|
@@ -71,7 +73,7 @@ def from_new(cls, root_path: Path) -> "MbedProgramFiles":
|
71 | 73 | Raises:
|
72 | 74 | ValueError: A program .mbed or mbed-os.lib file already exists at this path.
|
73 | 75 | """
|
74 |
| - app_config = root_path / APP_CONFIG_FILE_NAME |
| 76 | + app_config = root_path / APP_CONFIG_FILE_NAME_JSON5 |
75 | 77 | mbed_os_ref = root_path / MBED_OS_REFERENCE_FILE_NAME
|
76 | 78 | cmakelists_file = root_path / CMAKELISTS_FILE_NAME
|
77 | 79 | main_cpp = root_path / MAIN_CPP_FILE_NAME
|
@@ -103,13 +105,21 @@ def from_existing(cls, root_path: Path, build_subdir: Path) -> "MbedProgramFiles
|
103 | 105 | root_path: The path containing the MbedProgramFiles.
|
104 | 106 | build_subdir: The subdirectory of BUILD_DIR to use for CMake build.
|
105 | 107 | """
|
106 |
| - app_config: Optional[Path] |
107 |
| - app_config = root_path / APP_CONFIG_FILE_NAME |
108 |
| - if not app_config.exists(): |
| 108 | + app_config: Optional[Path] = None |
| 109 | + if (root_path / APP_CONFIG_FILE_NAME_JSON5).exists(): |
| 110 | + app_config = root_path / APP_CONFIG_FILE_NAME_JSON5 |
| 111 | + elif (root_path / APP_CONFIG_FILE_NAME_JSON).exists(): |
| 112 | + app_config = root_path / APP_CONFIG_FILE_NAME_JSON |
| 113 | + else: |
109 | 114 | logger.info("This program does not contain an mbed_app.json config file.")
|
110 |
| - app_config = None |
111 | 115 |
|
112 |
| - custom_targets_json = root_path / CUSTOM_TARGETS_JSON_FILE_NAME |
| 116 | + # If there's already a custom_targets.json5, use that. |
| 117 | + # Otherwise, assume json. |
| 118 | + if (root_path / CUSTOM_TARGETS_JSON5_FILE_NAME).exists(): |
| 119 | + custom_targets_json = root_path / CUSTOM_TARGETS_JSON5_FILE_NAME |
| 120 | + else: |
| 121 | + custom_targets_json = root_path / CUSTOM_TARGETS_JSON_FILE_NAME |
| 122 | + |
113 | 123 | mbed_os_file = root_path / MBED_OS_REFERENCE_FILE_NAME
|
114 | 124 |
|
115 | 125 | cmakelists_file = root_path / CMAKELISTS_FILE_NAME
|
|
0 commit comments