2025-02-14 00:51:39 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
'''
|
|
|
|
setup board.h for Linux
|
|
|
|
|
|
|
|
AP_FLAKE8_CLEAN
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../../../libraries/AP_HAL/hwdef/scripts'))
|
|
|
|
import hwdef # noqa:E402
|
|
|
|
|
|
|
|
|
|
|
|
class LinuxHWDef(hwdef.HWDef):
|
|
|
|
|
|
|
|
def __init__(self, quiet=False, outdir=None, hwdef=[]):
|
|
|
|
super(LinuxHWDef, self).__init__(quiet=quiet, outdir=outdir, hwdef=hwdef)
|
|
|
|
|
|
|
|
def write_hwdef_header_content(self, f):
|
|
|
|
for d in self.alllines:
|
|
|
|
if d.startswith('define '):
|
|
|
|
f.write('#define %s\n' % d[7:])
|
|
|
|
|
2025-02-14 00:51:57 -04:00
|
|
|
def process_line(self, line, depth):
|
|
|
|
'''process one line of pin definition file'''
|
|
|
|
# keep all config lines for later use
|
|
|
|
self.all_lines.append(line)
|
|
|
|
self.alllines.append(line)
|
|
|
|
super(LinuxHWDef, self).process_line(line, depth)
|
|
|
|
|
2025-02-14 00:51:39 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser("linux_hwdef.py")
|
|
|
|
parser.add_argument(
|
|
|
|
'-D', '--outdir', type=str, default="/tmp", help='Output directory')
|
|
|
|
parser.add_argument(
|
|
|
|
'hwdef', type=str, nargs='+', default=None, help='hardware definition file')
|
|
|
|
parser.add_argument(
|
|
|
|
'--quiet', action='store_true', default=False, help='quiet running')
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
c = LinuxHWDef(
|
|
|
|
outdir=args.outdir,
|
|
|
|
hwdef=args.hwdef,
|
|
|
|
quiet=args.quiet,
|
|
|
|
)
|
|
|
|
c.run()
|