[examples] Clean up examples (#8674)

Move various "examples" into snippets. Several examples that were less
than a full mechanism or robot were moved to snippets. `arcadedrive` and
`tankdrive` were removed in favor of their Gamepad variants. `hidrumble`
was removed due to being too simple. `potentiometerpid` was removed
because of low utility. `gyromecanum` replaced `mecanumdrive` for
deduplication and because very few teams run holonomic drivetrains
without gyros.
This commit is contained in:
Gold856
2026-03-14 17:13:45 -04:00
committed by GitHub
parent 62ce8944aa
commit f1adce4cf7
78 changed files with 569 additions and 1665 deletions

View File

@@ -1,7 +1,7 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//:pkg.bzl", "pkg_zip")
load("//wpilibcExamples:example_projects.bzl", "COMMANDS_V2_FOLDERS", "EXAMPLE_FOLDERS", "SNIPPETS_FOLDERS", "TEMPLATES_FOLDERS", "TESTS_FOLDERS")
load("//wpilibcExamples:example_projects.bzl", "COMMANDS_V2_FOLDERS", "EXAMPLE_FOLDERS", "EXAMPLE_TESTS_FOLDERS", "SNIPPET_FOLDERS", "SNIPPET_TESTS_FOLDERS", "TEMPLATE_FOLDERS")
def _package_type(package_type):
pkg_files(
@@ -40,11 +40,10 @@ def build_examples(halsim_deps = []):
name = folder + "-example",
srcs = native.glob(["src/main/cpp/examples/" + folder + "/cpp/**/*.cpp", "src/main/cpp/examples/" + folder + "/c/**/*.c"], allow_empty = True),
deps = [
"//commandsv2",
"//apriltag",
"//commandsv2",
"//romiVendordep",
"//xrpVendordep",
"//cameraserver",
":{}-examples-headers".format(folder),
],
tags = ["wpi-example"],
@@ -68,13 +67,21 @@ def build_commands():
def build_snippets():
_package_type("snippets")
for folder in SNIPPETS_FOLDERS:
for folder in SNIPPET_FOLDERS:
cc_library(
name = folder + "-template",
name = folder + "-snippets-headers",
hdrs = native.glob(["src/main/cpp/snippets/" + folder + "/include/**/*.hpp"], allow_empty = True),
strip_include_prefix = "src/main/cpp/snippets/" + folder + "/include",
tags = ["wpi-example"],
)
cc_library(
name = folder + "-snippet",
srcs = native.glob(["src/main/cpp/snippets/" + folder + "/**/*.cpp"]),
hdrs = native.glob(["src/main/cpp/snippets/" + folder + "/**/*.hpp"], allow_empty = True),
deps = [
"//apriltag",
"//commandsv2",
"//cameraserver",
":{}-snippets-headers".format(folder),
],
strip_include_prefix = "src/main/cpp/snippets/" + folder + "/include",
tags = ["wpi-example"],
@@ -83,7 +90,7 @@ def build_snippets():
def build_templates():
_package_type("templates")
for folder in TEMPLATES_FOLDERS:
for folder in TEMPLATE_FOLDERS:
cc_library(
name = folder + "-template",
srcs = native.glob(["src/main/cpp/templates/" + folder + "/**/*.cpp"]),
@@ -96,7 +103,7 @@ def build_templates():
)
def build_tests():
for folder in TESTS_FOLDERS:
for folder in EXAMPLE_TESTS_FOLDERS:
example_src_folder = "src/main/cpp/examples/" + folder
example_test_folder = "src/test/cpp/examples/" + folder
cc_test(
@@ -111,3 +118,18 @@ def build_tests():
defines = ["RUNNING_WPILIB_TESTS=1"],
tags = ["wpi-example", "no-tsan", "no-asan", "no-ubsan", "exclusive"],
)
for folder in SNIPPET_TESTS_FOLDERS:
snippet_src_folder = "src/main/cpp/snippets/" + folder
snippet_test_folder = "src/test/cpp/snippets/" + folder
cc_test(
name = folder + "-test",
size = "small",
srcs = native.glob([snippet_test_folder + "/**/*.cpp", snippet_src_folder + "/**/*.cpp"], allow_empty = True),
deps = [
"//commandsv2",
":{}-snippets-headers".format(folder),
"//thirdparty/googletest",
],
defines = ["RUNNING_WPILIB_TESTS=1"],
tags = ["wpi-example", "no-tsan", "no-asan", "no-ubsan", "exclusive"],
)