2018-07-05 01:15:19 -03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
script to run configre for all hwdef.dat, to check for syntax errors
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import fnmatch
|
|
|
|
|
2019-03-14 20:39:27 -03:00
|
|
|
import argparse
|
2018-07-05 01:15:19 -03:00
|
|
|
|
2019-03-14 20:39:27 -03:00
|
|
|
parser = argparse.ArgumentParser(description='configure all ChibiOS boards')
|
|
|
|
parser.add_argument('--build', action='store_true', default=False, help='build as well as configure')
|
2019-03-14 23:13:48 -03:00
|
|
|
parser.add_argument('--stop', action='store_true', default=False, help='stop on build fail')
|
2019-03-14 20:39:27 -03:00
|
|
|
parser.add_argument('--pattern', default='*')
|
|
|
|
args = parser.parse_args()
|
2018-07-05 01:15:19 -03:00
|
|
|
|
|
|
|
os.environ['PYTHONUNBUFFERED'] = '1'
|
|
|
|
|
2019-03-14 23:13:48 -03:00
|
|
|
failures = []
|
|
|
|
|
2018-07-05 01:15:19 -03:00
|
|
|
def get_board_list():
|
|
|
|
'''add boards based on existance of hwdef-bl.dat in subdirectories for ChibiOS'''
|
|
|
|
board_list = []
|
|
|
|
dirname, dirlist, filenames = next(os.walk('libraries/AP_HAL_ChibiOS/hwdef'))
|
|
|
|
for d in dirlist:
|
|
|
|
hwdef = os.path.join(dirname, d, 'hwdef.dat')
|
|
|
|
if os.path.exists(hwdef):
|
|
|
|
board_list.append(d)
|
|
|
|
return board_list
|
|
|
|
|
2019-03-14 23:13:48 -03:00
|
|
|
def run_program(cmd_list, build):
|
2018-07-05 01:15:19 -03:00
|
|
|
print("Running (%s)" % " ".join(cmd_list))
|
|
|
|
retcode = subprocess.call(cmd_list)
|
|
|
|
if retcode != 0:
|
2019-03-14 23:13:48 -03:00
|
|
|
print("Build failed: %s %s" % (build, ' '.join(cmd_list)))
|
|
|
|
global failures
|
|
|
|
failures.append(build)
|
|
|
|
if args.stop:
|
|
|
|
sys.exit(1)
|
2018-07-05 01:15:19 -03:00
|
|
|
|
|
|
|
for board in get_board_list():
|
2019-03-14 20:39:27 -03:00
|
|
|
if not fnmatch.fnmatch(board, args.pattern):
|
2018-07-05 01:15:19 -03:00
|
|
|
continue
|
2019-03-14 19:30:59 -03:00
|
|
|
print("Configuring for %s" % board)
|
2019-03-14 23:13:48 -03:00
|
|
|
run_program(["./waf", "configure", "--board", board], "configure: " + board)
|
2019-03-14 20:39:27 -03:00
|
|
|
if args.build:
|
2019-03-15 00:12:14 -03:00
|
|
|
if board == "iomcu":
|
|
|
|
target = "iofirmware"
|
|
|
|
else:
|
|
|
|
target = "copter"
|
|
|
|
run_program(["./waf", target], "build: " + board)
|
2019-03-14 19:30:59 -03:00
|
|
|
# check for bootloader def
|
|
|
|
hwdef_bl = os.path.join('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef-bl.dat' % board)
|
|
|
|
if os.path.exists(hwdef_bl):
|
|
|
|
print("Configuring bootloader for %s" % board)
|
2019-03-14 23:13:48 -03:00
|
|
|
run_program(["./waf", "configure", "--board", board, "--bootloader"], "configure: " + board + "-bl")
|
2019-03-14 20:39:27 -03:00
|
|
|
if args.build:
|
2019-03-14 23:13:48 -03:00
|
|
|
run_program(["./waf", "bootloader"], "build: " + board + "-bl")
|
|
|
|
|
|
|
|
if len(failures) > 0:
|
|
|
|
print("Failed builds:")
|
|
|
|
for f in failures:
|
|
|
|
print(' ' + f)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
sys.exit(0)
|