mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 00:04:02 -04:00
chibios_hwdef.py: print error message if a define is re-defined at top level with same value
This commit is contained in:
parent
eca2fd92b2
commit
395f438b42
@ -2935,7 +2935,7 @@ Please run: Tools/scripts/build_bootloaders.py %s
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def process_line(self, line):
|
def process_line(self, line, depth):
|
||||||
'''process one line of pin definition file'''
|
'''process one line of pin definition file'''
|
||||||
self.all_lines.append(line)
|
self.all_lines.append(line)
|
||||||
a = shlex.split(line, posix=False)
|
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
|
# 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)
|
result = re.match(r'define\s*([A-Z_0-9]+)\s+([0-9]+)', line)
|
||||||
if result:
|
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):
|
def progress(self, message):
|
||||||
if self.quiet:
|
if self.quiet:
|
||||||
return
|
return
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
def process_file(self, filename):
|
def process_file(self, filename, depth=0):
|
||||||
'''process a hwdef.dat file'''
|
'''process a hwdef.dat file'''
|
||||||
try:
|
try:
|
||||||
f = open(filename, "r")
|
f = open(filename, "r")
|
||||||
@ -3100,9 +3107,9 @@ Please run: Tools/scripts/build_bootloaders.py %s
|
|||||||
include_file = os.path.normpath(
|
include_file = os.path.normpath(
|
||||||
os.path.join(dir, include_file))
|
os.path.join(dir, include_file))
|
||||||
self.progress("Including %s" % include_file)
|
self.progress("Including %s" % include_file)
|
||||||
self.process_file(include_file)
|
self.process_file(include_file, depth+1)
|
||||||
else:
|
else:
|
||||||
self.process_line(line)
|
self.process_line(line, depth)
|
||||||
|
|
||||||
def add_apperiph_defaults(self, f):
|
def add_apperiph_defaults(self, f):
|
||||||
'''add default defines for peripherals'''
|
'''add default defines for peripherals'''
|
||||||
|
Loading…
Reference in New Issue
Block a user