|
35 | 35 | TARGETS_JSON5_PATH = MBED_OS_DIR / "targets" / "targets.json5" |
36 | 36 | CMSIS_MCU_DESCRIPTIONS_JSON_PATH = MBED_OS_DIR / "targets" / "cmsis_mcu_descriptions.json5" |
37 | 37 |
|
| 38 | +CUSTOM_DIR = THIS_SCRIPT_DIR.parent.parent.parent.parent.parent |
| 39 | +CUSTOM_TARGETS_JSON5_PATH = CUSTOM_DIR / "custom_targets" / "custom_targets.json5" |
38 | 40 |
|
39 | 41 | # Top-level command |
40 | 42 | @click.group( |
@@ -69,12 +71,16 @@ def open_cmsis_cache(*, must_exist: bool = True) -> cmsis_pack_manager.Cache: |
69 | 71 |
|
70 | 72 | def get_mcu_names_used_by_targets_json5() -> Set[str]: |
71 | 73 | """ |
72 | | - Accumulate set of all `device_name` properties used by all targets defined in targets.json5 |
| 74 | + Accumulate set of all `device_name` properties used by all targets defined in targets.json5 and custom_targets.json5 |
73 | 75 | """ |
74 | | - LOGGER.info("Scanning targets.json5 for used MCU names...") |
75 | 76 | used_mcu_names = set() |
76 | | - targets_json5_contents = decode_json_file(TARGETS_JSON5_PATH) |
77 | | - for target_details in targets_json5_contents.values(): |
| 77 | + LOGGER.info("Scanning targets.json5 for used MCU names...") |
| 78 | + json5_contents = decode_json_file(TARGETS_JSON5_PATH) |
| 79 | + if os.path.exists(CUSTOM_TARGETS_JSON5_PATH): |
| 80 | + LOGGER.info("Scanning custom_targets.json5 for used MCU names...") |
| 81 | + json5_contents.update(decode_json_file(CUSTOM_TARGETS_JSON5_PATH)) |
| 82 | + |
| 83 | + for target_details in json5_contents.values(): |
78 | 84 | if "device_name" in target_details: |
79 | 85 | used_mcu_names.add(target_details["device_name"]) |
80 | 86 | return used_mcu_names |
@@ -153,12 +159,12 @@ def check_missing(): |
153 | 159 |
|
154 | 160 | @cmsis_mcu_descr.command( |
155 | 161 | name="fetch-missing", |
156 | | - short_help="Fetch any missing MCU descriptions used by targets.json5." |
| 162 | + short_help="Fetch any missing MCU descriptions used by targets.json5 or custom_targets.json5." |
157 | 163 | ) |
158 | 164 | def fetch_missing(): |
159 | 165 | """ |
160 | | - Scans through cmsis_mcu_descriptions.json for any missing MCU descriptions that are referenced by |
161 | | - targets.json5. If any are found, they are imported from the CMSIS cache. |
| 166 | + Scans through cmsis_mcu_descriptions.json for any missing MCU descriptions that are referenced by |
| 167 | + targets.json5 or custom_targets.json5. If any are found, they are imported from the CMSIS cache. |
162 | 168 |
|
163 | 169 | Note that downloaded descriptions should be checked for accuracy before they are committed. |
164 | 170 | """ |
@@ -186,8 +192,11 @@ def fetch_missing(): |
186 | 192 | f"wrong part number, or this MCU simply doesn't exist in the CMSIS index and has " |
187 | 193 | f"to be added manually?") |
188 | 194 | missing_mcus_dict[mcu] = cmsis_cache.index[mcu] |
| 195 | + |
| 196 | + if os.path.exists(CUSTOM_TARGETS_JSON5_PATH): |
| 197 | + print(f"Remove 'device_name' and add the 'memories' section as 'memory_banks' section\nfrom following entries to {CUSTOM_TARGETS_JSON5_PATH}:") |
| 198 | + else: |
| 199 | + print(f"Add the following entries to {CMSIS_MCU_DESCRIPTIONS_JSON_PATH}:") |
189 | 200 |
|
190 | | - print(f"Add the following entries to {CMSIS_MCU_DESCRIPTIONS_JSON_PATH}:") |
191 | 201 | print(json.dumps(missing_mcus_dict, indent=4, sort_keys=True)) |
192 | | - |
193 | | - sys.exit(1) |
| 202 | + sys.exit(1) |
0 commit comments