chibios_hwdef.py: print error message if a define is re-defined at top level with same value

This commit is contained in:
Peter Barker 2024-03-22 10:56:43 +11:00 committed by Andrew Tridgell
parent eca2fd92b2
commit 395f438b42
1 changed files with 12 additions and 5 deletions

View File

@ -2935,7 +2935,7 @@ Please run: Tools/scripts/build_bootloaders.py %s
return False
return True
def process_line(self, line):
def process_line(self, line, depth):
'''process one line of pin definition file'''
self.all_lines.append(line)
a = shlex.split(line, posix=False)
@ -3074,14 +3074,21 @@ Please run: Tools/scripts/build_bootloaders.py %s
# extract numerical defines for processing by other parts of the script
result = re.match(r'define\s*([A-Z_0-9]+)\s+([0-9]+)', line)
if result:
self.intdefines[result.group(1)] = int(result.group(2))
(name, intvalue) = (result.group(1), int(result.group(2)))
if name in self.intdefines and self.intdefines[name] == intvalue:
msg = f"{name} already in defines with same value"
if depth == 0:
print(msg)
# raise ValueError(msg)
self.intdefines[name] = intvalue
def progress(self, message):
if self.quiet:
return
print(message)
def process_file(self, filename):
def process_file(self, filename, depth=0):
'''process a hwdef.dat file'''
try:
f = open(filename, "r")
@ -3100,9 +3107,9 @@ Please run: Tools/scripts/build_bootloaders.py %s
include_file = os.path.normpath(
os.path.join(dir, include_file))
self.progress("Including %s" % include_file)
self.process_file(include_file)
self.process_file(include_file, depth+1)
else:
self.process_line(line)
self.process_line(line, depth)
def add_apperiph_defaults(self, f):
'''add default defines for peripherals'''