blob: 506c5bc92d22024b53bff9e88f0841616c65f26e [file] [log] [blame]
Maxwell Henderson80bec322024-01-09 15:48:44 -08001#!/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.
6import os.path
7import subprocess
8import sys
9from glob import glob
10
11if __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 )