2025-05-14 01:01:47 -04:00
|
|
|
import argparse
|
|
|
|
|
import os
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-06-11 16:06:45 -07:00
|
|
|
from wpilibj.generate_first_ds_hids import generate_first_ds_hids
|
2025-05-14 01:01:47 -04:00
|
|
|
from wpilibj.generate_hids import generate_hids
|
|
|
|
|
from wpilibj.generate_pwm_motor_controllers import generate_pwm_motor_controllers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
dirname, _ = os.path.split(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--output_directory",
|
|
|
|
|
help="Optional. If set, will output the generated files to this directory, otherwise it will use a path relative to the script",
|
|
|
|
|
default=os.path.join(dirname, "src/generated"),
|
|
|
|
|
type=Path,
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--template_root",
|
|
|
|
|
help="Optional. If set, will use this directory as the root for the jinja templates",
|
|
|
|
|
default=os.path.join(dirname, "src/generate"),
|
|
|
|
|
type=Path,
|
|
|
|
|
)
|
2026-06-11 16:06:45 -07:00
|
|
|
parser.add_argument(
|
|
|
|
|
"--test_output_directory",
|
|
|
|
|
help="Optional. If set, will output generated tests to this directory",
|
|
|
|
|
default=os.path.join(dirname, "src/generated/test"),
|
|
|
|
|
type=Path,
|
|
|
|
|
)
|
2025-05-14 01:01:47 -04:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
generate_hids(args.output_directory, args.template_root)
|
2026-06-11 16:06:45 -07:00
|
|
|
test_output_directory = (
|
|
|
|
|
None
|
|
|
|
|
if args.test_output_directory.name == "__none__"
|
|
|
|
|
else args.test_output_directory
|
|
|
|
|
)
|
|
|
|
|
generate_first_ds_hids(
|
|
|
|
|
args.output_directory, args.template_root, test_output_directory
|
|
|
|
|
)
|
2025-05-14 01:01:47 -04:00
|
|
|
generate_pwm_motor_controllers(args.output_directory, args.template_root)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|