[bazel] Clean up bazel scripts (#7984)

This commit is contained in:
PJ Reiniger
2025-06-13 23:53:09 -04:00
committed by GitHub
parent 5dfc664b93
commit fbbc4bc53c
54 changed files with 1774 additions and 854 deletions

View File

@@ -1,6 +1,6 @@
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
load("@rules_python//python:defs.bzl", "py_binary")
load("//wpilibjExamples:build_java_examples.bzl", "build_commands", "build_examples", "build_snippets", "build_templates")
load("//wpilibjExamples:build_java_examples.bzl", "build_commands", "build_examples", "build_snippets", "build_templates", "build_tests")
py_binary(
name = "generate_bazel_files",
@@ -44,3 +44,5 @@ build_examples(halsim_deps = halsim_deps)
build_snippets()
build_templates()
build_tests()

View File

@@ -1,5 +1,6 @@
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("//wpilibjExamples:example_projects.bzl", "COMMANDS_V2_FOLDERS", "EXAMPLES_FOLDERS", "SNIPPETS_FOLDERS", "TEMPLATES_FOLDERS")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
load("//wpilibjExamples:example_projects.bzl", "COMMANDS_V2_FOLDERS", "EXAMPLES_FOLDERS", "SNIPPETS_FOLDERS", "TEMPLATES_FOLDERS", "TEST_FOLDERS")
def build_examples(halsim_deps):
for folder in EXAMPLES_FOLDERS:
@@ -69,3 +70,20 @@ def build_templates():
],
tags = ["wpi-example"],
)
def build_tests():
for folder in TEST_FOLDERS:
wpilib_java_junit5_test(
name = folder + "-test",
srcs = native.glob(["src/test/java/edu/wpi/first/wpilibj/examples/" + folder + "/**/*.java"]),
deps = [
":" + folder + "-example",
"//hal:hal-java",
"//ntcore:networktables-java",
"//wpilibj:wpilibj",
"//wpilibNewCommands:wpilibNewCommands-java",
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
],
tags = ["wpi-example"],
)

View File

@@ -97,5 +97,10 @@ TEMPLATES_FOLDERS = [
]
TEST_FOLDERS = [
"armsimulation",
"digitalcommunication",
"elevatorsimulation",
"i2ccommunication",
"potentiometerpid",
"unittest",
]

View File

@@ -114,7 +114,8 @@
"foldername": "potentiometerpid",
"gradlebase": "java",
"mainclass": "Main",
"commandversion": 2
"commandversion": 2,
"hasunittests": true
},
{
"name": "Elevator with trapezoid profiled PID",
@@ -607,7 +608,8 @@
"foldername": "elevatorsimulation",
"gradlebase": "java",
"mainclass": "Main",
"commandversion": 2
"commandversion": 2,
"hasunittests": true
},
{
"name": "Elevator Exponential Profile Simulation",
@@ -640,7 +642,8 @@
"foldername": "armsimulation",
"gradlebase": "java",
"mainclass": "Main",
"commandversion": 2
"commandversion": 2,
"hasunittests": true
},
{
"name": "UnitTesting",
@@ -749,7 +752,8 @@
"foldername": "digitalcommunication",
"gradlebase": "java",
"commandversion": 2,
"mainclass": "Main"
"mainclass": "Main",
"hasunittests": true
},
{
"name": "I2C Communication Sample",
@@ -761,7 +765,8 @@
"foldername": "i2ccommunication",
"gradlebase": "java",
"commandversion": 2,
"mainclass": "Main"
"mainclass": "Main",
"hasunittests": true
},
{
"name": "Flywheel BangBangController",