2024-04-09 07:33:47 -03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
script to automatically create a copy of a board for an OEM setup
|
|
|
|
usage example : ./Tools/scripts/create_OEM_board.py mRoPixracerPro mRoPixracerPro-MyCompany
|
2024-06-25 20:38:37 -03:00
|
|
|
|
|
|
|
AP_FLAKE8_CLEAN
|
2024-04-09 07:33:47 -03:00
|
|
|
"""
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
2024-06-25 20:39:51 -03:00
|
|
|
import pathlib
|
|
|
|
|
2024-04-09 07:33:47 -03:00
|
|
|
board_name = sys.argv[1]
|
|
|
|
oem_board_name = sys.argv[2]
|
|
|
|
|
|
|
|
|
|
|
|
# directory creation
|
|
|
|
if not os.path.exists("libraries/AP_HAL_ChibiOS/hwdef/%s" % oem_board_name):
|
|
|
|
subprocess.run(["mkdir", "libraries/AP_HAL_ChibiOS/hwdef/%s" % oem_board_name])
|
|
|
|
# create files and add reference to originals
|
2024-06-25 20:38:37 -03:00
|
|
|
f = open("libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat" % oem_board_name, "x")
|
2024-06-25 20:42:33 -03:00
|
|
|
f.write("include ../%s/hwdef.dat\n" % board_name)
|
2024-04-09 07:33:47 -03:00
|
|
|
f.close()
|
2024-06-25 20:38:37 -03:00
|
|
|
f = open("libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef-bl.dat" % oem_board_name, "x")
|
2024-06-25 20:42:33 -03:00
|
|
|
f.write("include ../%s/hwdef-bl.dat\n" % board_name)
|
2024-04-09 07:33:47 -03:00
|
|
|
f.close()
|
|
|
|
if os.path.exists("libraries/AP_HAL_ChibiOS/hwdef/%s/defaults.parm" % board_name):
|
2024-06-25 20:39:51 -03:00
|
|
|
path = pathlib.Path(f"libraries/AP_HAL_ChibiOS/hwdef/{oem_board_name}/defaults.parm")
|
|
|
|
path.write_text(f"@include ../{board_name}/defaults.parm\n") # noqa
|