Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | # Copyright (c) FIRST and other WPILib contributors. |
| 4 | # Open Source Software; you can modify and/or share it under the terms of |
| 5 | # the WPILib BSD license file in the root directory of this project. |
| 6 | import os.path |
| 7 | import subprocess |
| 8 | import sys |
| 9 | from glob import glob |
| 10 | |
| 11 | if __name__ == "__main__": |
| 12 | proto_files = glob("wpimath/src/main/proto/*.proto") |
| 13 | for path in proto_files: |
| 14 | absolute_filename = os.path.abspath(path) |
| 15 | absolute_dir, filename = os.path.split(absolute_filename) |
| 16 | subprocess.run( |
| 17 | [ |
| 18 | sys.argv[1], |
| 19 | f"--plugin=protoc-gen-quickbuf={sys.argv[2]}", |
| 20 | f"--quickbuf_out=gen_descriptors=true:{os.path.abspath('./wpimath/src/generated/main/java')}", |
| 21 | f"-I{absolute_dir}", |
| 22 | absolute_filename, |
| 23 | ] |
| 24 | ) |
| 25 | java_files = glob("wpimath/src/generated/main/java/edu/wpi/first/math/proto/*.java") |
| 26 | for java_file in java_files: |
| 27 | with open(java_file) as file: |
| 28 | content = file.read() |
| 29 | with open(java_file, "tw") as file: |
| 30 | file.write( |
| 31 | "// Copyright (c) FIRST and other WPILib contributors.\n// Open Source Software; you can modify and/or share it under the terms of\n// the WPILib BSD license file in the root directory of this project.\n" |
| 32 | + content |
| 33 | ) |