Skip to content

Commit

Permalink
Add proto for Mechanism2d classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Jan 2, 2024
1 parent 783acb9 commit f0be729
Show file tree
Hide file tree
Showing 7 changed files with 1,884 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pregenerate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
run: ./hal/generate_usage_reporting.py
- name: Run ntcore
run: ./ntcore/generate_topics.py
- name: Run wpilibj
run: ./wpilibj/generate_quickbuf.py protoc protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
- name: Run wpimath
run: ./wpimath/generate_numbers.py && ./wpimath/generate_quickbuf.py protoc protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
- name: Add untracked files to index so they count as changes
Expand Down
1 change: 1 addition & 0 deletions wpilibj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ gradle.taskGraph.addTaskExecutionGraphListener { graph ->
}
}

sourceSets.main.java.srcDir "${projectDir}/src/generated/main/java"
sourceSets.main.java.srcDir "${buildDir}/generated/java/"

compileJava {
Expand Down
33 changes: 33 additions & 0 deletions wpilibj/generate_quickbuf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python3

# Copyright (c) FIRST and other WPILib contributors.
# Open Source Software; you can modify and/or share it under the terms of
# the WPILib BSD license file in the root directory of this project.
import os.path
import subprocess
import sys
from glob import glob

if __name__ == "__main__":
proto_files = glob("wpilibj/src/main/proto/*.proto")
for path in proto_files:
absolute_filename = os.path.abspath(path)
absolute_dir, filename = os.path.split(absolute_filename)
subprocess.run(
[
sys.argv[1],
f"--plugin=protoc-gen-quickbuf={sys.argv[2]}",
f"--quickbuf_out=allocation=lazymsg,gen_descriptors=true:{os.path.abspath('./wpilibj/src/generated/main/java')}",
f"-I{absolute_dir}",
absolute_filename,
]
)
java_files = glob("wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/proto/*.java")
for java_file in java_files:
with open(java_file) as file:
content = file.read()
with open(java_file, "tw") as file:
file.write(
"// 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"
+ content
)
Loading

0 comments on commit f0be729

Please sign in to comment.