mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[robotpy][examples] Split examples and snippets (#8944)
This also updates the bazel scripts to behave more like the C++ and Java examples, and updates the copybara scripts to be able to sync up `mostrobotpy`
This commit is contained in:
@@ -175,7 +175,13 @@ def define_mostrobotpy_to_allwpilib():
|
|||||||
"examples/robot/**",
|
"examples/robot/**",
|
||||||
], exclude = EXCLUDES)
|
], exclude = EXCLUDES)
|
||||||
destination_files += glob(["robotpyExamples/**"], exclude = ["robotpyExamples/define_examples.bzl", "robotpyExamples/example_projects.bzl", "robotpyExamples/generate_bazel_files.py", "robotpyExamples/BUILD.bazel"])
|
destination_files += glob(["robotpyExamples/**"], exclude = ["robotpyExamples/define_examples.bzl", "robotpyExamples/example_projects.bzl", "robotpyExamples/generate_bazel_files.py", "robotpyExamples/BUILD.bazel"])
|
||||||
transformations.append(core.move("examples/robot/", "robotpyExamples/"))
|
transformations.append(core.move("examples/robot/", "robotpyExamples/examples"))
|
||||||
|
|
||||||
|
origin_files += glob([
|
||||||
|
"examples/snippets/**",
|
||||||
|
], exclude = EXCLUDES)
|
||||||
|
destination_files += glob(["robotpyExamples/**"], exclude = ["robotpyExamples/define_examples.bzl", "robotpyExamples/example_projects.bzl", "robotpyExamples/generate_bazel_files.py", "robotpyExamples/BUILD.bazel"])
|
||||||
|
transformations.append(core.move("examples/snippets/", "robotpyExamples/snippets"))
|
||||||
|
|
||||||
# Some tests seem to fail in mostrobotpy, but don't in allwpilib
|
# Some tests seem to fail in mostrobotpy, but don't in allwpilib
|
||||||
# We will leave them turned on in allwpilib, and mark them as xfail in mostrobotpy.
|
# We will leave them turned on in allwpilib, and mark them as xfail in mostrobotpy.
|
||||||
@@ -189,11 +195,11 @@ def define_mostrobotpy_to_allwpilib():
|
|||||||
name = "mostrobotpy_to_allwpilib",
|
name = "mostrobotpy_to_allwpilib",
|
||||||
origin = git.origin(
|
origin = git.origin(
|
||||||
url = "https://github.com/robotpy/mostrobotpy.git",
|
url = "https://github.com/robotpy/mostrobotpy.git",
|
||||||
ref = "2027",
|
ref = "main",
|
||||||
),
|
),
|
||||||
destination = git.destination(
|
destination = git.destination(
|
||||||
url = "https://github.com/OVERRIDE_ME/OVERRIDE_ME",
|
url = "https://github.com/OVERRIDE_ME/OVERRIDE_ME",
|
||||||
fetch = "2027",
|
fetch = "main",
|
||||||
push = "copybara_mostrobotpy_to_allwpilib",
|
push = "copybara_mostrobotpy_to_allwpilib",
|
||||||
),
|
),
|
||||||
destination_files = destination_files,
|
destination_files = destination_files,
|
||||||
@@ -226,7 +232,9 @@ def define_allwpilib_to_mostrobotpy():
|
|||||||
"robotpyExamples/**",
|
"robotpyExamples/**",
|
||||||
], exclude = ["robotpyExamples/BUILD.bazel", "robotpyExamples/define_examples.bzl", "robotpyExamples/example_projects.bzl", "robotpyExamples/generate_bazel_files.py"])
|
], exclude = ["robotpyExamples/BUILD.bazel", "robotpyExamples/define_examples.bzl", "robotpyExamples/example_projects.bzl", "robotpyExamples/generate_bazel_files.py"])
|
||||||
destination_files += glob(["examples/robot/**"], exclude = ["examples/robot/.gitignore"])
|
destination_files += glob(["examples/robot/**"], exclude = ["examples/robot/.gitignore"])
|
||||||
transformations.append(core.move("robotpyExamples/", "examples/robot/"))
|
destination_files += glob(["examples/snippets/**"], exclude = ["examples/snippets/.gitignore"])
|
||||||
|
transformations.append(core.move("robotpyExamples/examples", "examples/robot/"))
|
||||||
|
transformations.append(core.move("robotpyExamples/snippets", "snippets/robot/"))
|
||||||
|
|
||||||
# Some tests seem to fail in mostrobotpy, but don't in allwpilib
|
# Some tests seem to fail in mostrobotpy, but don't in allwpilib
|
||||||
# We will leave them turned on in allwpilib, and mark them as xfail in mostrobotpy.
|
# We will leave them turned on in allwpilib, and mark them as xfail in mostrobotpy.
|
||||||
@@ -240,11 +248,11 @@ def define_allwpilib_to_mostrobotpy():
|
|||||||
name = "allwpilib_to_mostrobotpy",
|
name = "allwpilib_to_mostrobotpy",
|
||||||
origin = git.origin(
|
origin = git.origin(
|
||||||
url = "https://github.com/wpilibsuite/allwpilib.git",
|
url = "https://github.com/wpilibsuite/allwpilib.git",
|
||||||
ref = "2027",
|
ref = "main",
|
||||||
),
|
),
|
||||||
destination = git.github_destination(
|
destination = git.github_destination(
|
||||||
url = "https://github.com/OVERRIDE_ME/OVERRIDE_ME",
|
url = "https://github.com/OVERRIDE_ME/OVERRIDE_ME",
|
||||||
fetch = "2027",
|
fetch = "main",
|
||||||
push = "copybara_allwpilib_to_mostrobotpy",
|
push = "copybara_allwpilib_to_mostrobotpy",
|
||||||
),
|
),
|
||||||
destination_files = destination_files,
|
destination_files = destination_files,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
|
|||||||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
|
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
|
||||||
load("@rules_python//python:defs.bzl", "py_binary")
|
load("@rules_python//python:defs.bzl", "py_binary")
|
||||||
load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
|
load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
|
||||||
load(":define_examples.bzl", "define_examples")
|
load(":define_examples.bzl", "define_examples", "define_snippets")
|
||||||
|
|
||||||
py_binary(
|
py_binary(
|
||||||
name = "generate_bazel_files",
|
name = "generate_bazel_files",
|
||||||
@@ -22,7 +22,8 @@ cmd = "$(locations :generate_bazel_files) $(OUTS)"
|
|||||||
genrule(
|
genrule(
|
||||||
name = "generate_bazel_files_rule",
|
name = "generate_bazel_files_rule",
|
||||||
srcs = [
|
srcs = [
|
||||||
"examples.toml",
|
"examples/examples.toml",
|
||||||
|
"snippets/snippets.toml",
|
||||||
],
|
],
|
||||||
outs = ["gen/example_projects.bzl"],
|
outs = ["gen/example_projects.bzl"],
|
||||||
cmd = cmd,
|
cmd = cmd,
|
||||||
@@ -45,3 +46,5 @@ py_console_script_binary(
|
|||||||
)
|
)
|
||||||
|
|
||||||
define_examples()
|
define_examples()
|
||||||
|
|
||||||
|
define_snippets()
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
|
load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
|
||||||
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
|
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
|
||||||
load("//robotpyExamples:example_projects.bzl", "PROJECTS")
|
load("//robotpyExamples:example_projects.bzl", "EXAMPLE_PROJECTS", "SNIPPET_PROJECTS")
|
||||||
|
|
||||||
def define_examples():
|
def _define_robot_project(projects, project_type):
|
||||||
for example_folder in PROJECTS:
|
for example_folder in projects:
|
||||||
base_name = example_folder.replace("/", "_")
|
base_name = example_folder.replace("/", "_")
|
||||||
common_kwargs = dict(
|
common_kwargs = dict(
|
||||||
srcs = [":robotpy_entry_point.py"],
|
srcs = [":robotpy_entry_point.py"],
|
||||||
@@ -42,3 +42,9 @@ def define_examples():
|
|||||||
deps = common_deps + ["//simulation/halsim_gui:robotpy-halsim-gui"],
|
deps = common_deps + ["//simulation/halsim_gui:robotpy-halsim-gui"],
|
||||||
**common_kwargs
|
**common_kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def define_examples():
|
||||||
|
_define_robot_project(EXAMPLE_PROJECTS, "example")
|
||||||
|
|
||||||
|
def define_snippets():
|
||||||
|
_define_robot_project(SNIPPET_PROJECTS, "snippet")
|
||||||
|
|||||||
@@ -1,51 +1,53 @@
|
|||||||
PROJECTS = [
|
EXAMPLE_PROJECTS = [
|
||||||
"AddressableLED",
|
"examples/ArcadeDrive",
|
||||||
"AprilTagsVision",
|
"examples/ArcadeDriveXboxController",
|
||||||
"ArcadeDrive",
|
"examples/ArmSimulation",
|
||||||
"ArcadeDriveXboxController",
|
"examples/DifferentialDriveBot",
|
||||||
"ArmSimulation",
|
"examples/DifferentialDrivePoseEstimator",
|
||||||
"CANPDP",
|
"examples/DriveDistanceOffboard",
|
||||||
"DifferentialDriveBot",
|
"examples/DutyCycleEncoder",
|
||||||
"DifferentialDrivePoseEstimator",
|
"examples/ElevatorExponentialProfile",
|
||||||
"DigitalCommunication",
|
"examples/ElevatorExponentialSimulation",
|
||||||
"DriveDistanceOffboard",
|
"examples/ElevatorProfiledPID",
|
||||||
"DutyCycleEncoder",
|
"examples/ElevatorSimulation",
|
||||||
"DutyCycleInput",
|
"examples/ElevatorTrapezoidProfile",
|
||||||
"ElevatorExponentialProfile",
|
"examples/Encoder",
|
||||||
"ElevatorExponentialSimulation",
|
"examples/GettingStarted",
|
||||||
"ElevatorProfiledPID",
|
"examples/Gyro",
|
||||||
"ElevatorSimulation",
|
"examples/HatchbotInlined",
|
||||||
"ElevatorTrapezoidProfile",
|
"examples/HatchbotTraditional",
|
||||||
"Encoder",
|
"examples/MecanumBot",
|
||||||
"EventLoop",
|
"examples/MecanumDrive",
|
||||||
"FlywheelBangBangController",
|
"examples/MecanumDrivePoseEstimator",
|
||||||
"GettingStarted",
|
"examples/Mechanism2d",
|
||||||
"Gyro",
|
"examples/RapidReactCommandBot",
|
||||||
"HatchbotInlined",
|
"examples/RomiReference",
|
||||||
"HatchbotTraditional",
|
"examples/SimpleDifferentialDriveSimulation",
|
||||||
"HttpCamera",
|
"examples/StateSpaceArm",
|
||||||
"I2CCommunication",
|
"examples/StateSpaceElevator",
|
||||||
"IntermediateVision",
|
"examples/StateSpaceFlywheel",
|
||||||
"MecanumBot",
|
"examples/StateSpaceFlywheelSysId",
|
||||||
"MecanumDrive",
|
"examples/SwerveBot",
|
||||||
"MecanumDrivePoseEstimator",
|
"examples/SwerveDrivePoseEstimator",
|
||||||
"Mechanism2d",
|
"examples/SysId",
|
||||||
"MotorControl",
|
"examples/TankDrive",
|
||||||
"QuickVision",
|
"examples/TankDriveXboxController",
|
||||||
"RapidReactCommandBot",
|
"examples/UnitTest",
|
||||||
"RomiReference",
|
"examples/XrpReference",
|
||||||
"SelectCommand",
|
]
|
||||||
"SimpleDifferentialDriveSimulation",
|
SNIPPET_PROJECTS = [
|
||||||
"Solenoid",
|
"snippets/AddressableLED",
|
||||||
"StateSpaceArm",
|
"snippets/AprilTagsVision",
|
||||||
"StateSpaceElevator",
|
"snippets/CANPDP",
|
||||||
"StateSpaceFlywheel",
|
"snippets/DigitalCommunication",
|
||||||
"StateSpaceFlywheelSysId",
|
"snippets/DutyCycleInput",
|
||||||
"SwerveBot",
|
"snippets/EventLoop",
|
||||||
"SwerveDrivePoseEstimator",
|
"snippets/FlywheelBangBangController",
|
||||||
"SysId",
|
"snippets/HttpCamera",
|
||||||
"TankDrive",
|
"snippets/I2CCommunication",
|
||||||
"TankDriveXboxController",
|
"snippets/IntermediateVision",
|
||||||
"UnitTest",
|
"snippets/MotorControl",
|
||||||
"XrpReference",
|
"snippets/QuickVision",
|
||||||
|
"snippets/SelectCommand",
|
||||||
|
"snippets/Solenoid",
|
||||||
]
|
]
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user