Skip to content

Commit d3080e7

Browse files
authored
Slight tweak to the config-extraction scripts. (#2070)
* Slight tweak to the config-extraction scripts. A small logic bug meant they were reporting more false-positive warnings than they should have been. * Small code tidy-up
1 parent 54d4f3a commit d3080e7

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

tools/extract_build_defines.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def ValidateAttrs(config_name, config_attrs, file_path, linenum):
9999
_default = config_attrs.get('default', None)
100100
if _default is not None:
101101
if '/' not in _default:
102-
if (_default.lower() != '0') and (config_attrs['default'].lower() != '1') and ( _default not in all_configs):
102+
if (_default not in ('0', '1')) and (_default not in all_config_names):
103103
logger.info('{} at {}:{} has non-integer default value "{}"'.format(config_name, file_path, linenum, config_attrs['default']))
104104

105105
elif _type == 'string':
@@ -185,6 +185,10 @@ def ValidateAttrs(config_name, config_attrs, file_path, linenum):
185185
all_configs[config_name] = {'attrs': config_attrs, 'filename': os.path.relpath(file_path, scandir), 'line_number': linenum, 'description': config_description}
186186

187187

188+
all_config_names = set()
189+
for all_configs in chips_all_configs.values():
190+
all_config_names.update(all_configs.keys())
191+
188192
for applicable, all_configs in chips_all_configs.items():
189193
for config_name, config_obj in all_configs.items():
190194
file_path = os.path.join(scandir, config_obj['filename'])

tools/extract_cmake_configs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def ValidateAttrs(config_name, config_attrs, file_path, linenum):
9999
_default = config_attrs.get('default', None)
100100
if _default is not None:
101101
if '/' not in _default:
102-
if (_default.lower() != '0') and (config_attrs['default'].lower() != '1') and (_default not in all_configs):
102+
if (_default not in ('0', '1')) and (_default not in all_config_names):
103103
logger.info('{} at {}:{} has non-integer default value "{}"'.format(config_name, file_path, linenum, config_attrs['default']))
104104

105105
elif _type == 'string':
@@ -185,6 +185,10 @@ def ValidateAttrs(config_name, config_attrs, file_path, linenum):
185185
all_configs[config_name] = {'attrs': config_attrs, 'filename': os.path.relpath(file_path, scandir), 'line_number': linenum, 'description': config_description}
186186

187187

188+
all_config_names = set()
189+
for all_configs in chips_all_configs.values():
190+
all_config_names.update(all_configs.keys())
191+
188192
for applicable, all_configs in chips_all_configs.items():
189193
for config_name, config_obj in all_configs.items():
190194
file_path = os.path.join(scandir, config_obj['filename'])

tools/extract_configs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def ValidateAttrs(config_name, config_attrs, file_path, linenum):
105105
_default = config_attrs.get('default', None)
106106
if _default is not None:
107107
if '/' not in _default:
108-
if (_default.lower() != '0') and (config_attrs['default'].lower() != '1') and ( _default not in all_configs):
108+
if (_default not in ('0', '1')) and (_default not in all_config_names):
109109
logger.info('{} at {}:{} has non-integer default value "{}"'.format(config_name, file_path, linenum, config_attrs['default']))
110110

111111
elif _type == 'enum':
@@ -217,11 +217,15 @@ def ValidateAttrs(config_name, config_attrs, file_path, linenum):
217217
all_defines[name][value] = set()
218218
all_defines[name][value] = (file_path, linenum)
219219

220+
all_config_names = set()
221+
for all_configs in chips_all_configs.values():
222+
all_config_names.update(all_configs.keys())
223+
220224
# Check for defines with missing PICO_CONFIG entries
221225
chips_resolved_defines = defaultdict(dict)
222226
for applicable, all_defines in chips_all_defines.items():
223227
for d in all_defines:
224-
if d not in all_configs and d.startswith("PICO_"):
228+
if d not in all_config_names and d.startswith("PICO_"):
225229
logger.warning("Potential unmarked PICO define {}".format(d))
226230
resolved_defines = chips_resolved_defines[applicable]
227231
# resolve "nested defines" - this allows e.g. USB_DPRAM_MAX to resolve to USB_DPRAM_SIZE which is set to 4096 (which then matches the relevant PICO_CONFIG entry)

0 commit comments

Comments
 (0)