From 892666fbbe8753167e91e1b02e8611173d365521 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 9 Nov 2025 13:32:58 -0500 Subject: [PATCH] [robotpy] Add build scripts for wpilib and dependencies (#8348) This gets the majority of projects from mostrobotpy building in this mirror. Projects missing still are cscore and the halsim wrappers. --- .github/workflows/bazel.yml | 33 + BUILD.bazel | 135 +- README-RobotPy.md | 52 + apriltag/BUILD.bazel | 58 + apriltag/robotpy_native_build_info.bzl | 39 + apriltag/robotpy_pybind_build_info.bzl | 242 ++ datalog/BUILD.bazel | 50 + datalog/robotpy_native_build_info.bzl | 34 + datalog/robotpy_pybind_build_info.bzl | 235 ++ hal/BUILD.bazel | 62 + hal/robotpy_native_build_info.bzl | 36 + hal/robotpy_pybind_build_info.bzl | 665 ++++++ ntcore/BUILD.bazel | 57 + ntcore/robotpy_native_build_info.bzl | 38 + ntcore/robotpy_pybind_build_info.bzl | 514 +++++ romiVendordep/BUILD.bazel | 59 + romiVendordep/robotpy_native_build_info.bzl | 34 + romiVendordep/robotpy_pybind_build_info.bzl | 208 ++ shared/bazel/rules/robotpy/BUILD.bazel | 5 +- .../robotpy/generate_pybind_build_file.py | 14 + .../robotpy/pybind_build_file_template.jinja2 | 22 +- .../rules/robotpy/semiwrap_tool_helpers.bzl | 2 + .../bazel/rules/robotpy/version_template.in | 3 + wpilibc/BUILD.bazel | 97 + wpilibc/robotpy_native_build_info.bzl | 42 + wpilibc/robotpy_pybind_build_info.bzl | 1974 +++++++++++++++++ wpilibc/src/main/python/pyproject.toml | 155 +- wpimath/BUILD.bazel | 139 ++ wpimath/robotpy_native_build_info.bzl | 39 + wpimath/robotpy_pybind_build_info.bzl | 1785 +++++++++++++++ wpimath/robotpy_pybind_test_info.bzl | 157 ++ wpimath/src/main/python/pyproject.toml | 30 +- .../test/python/cpp/wpimath_test/__init__.py | 2 +- wpinet/robotpy_pybind_build_info.bzl | 9 + wpiutil/robotpy_pybind_build_info.bzl | 8 + xrpVendordep/BUILD.bazel | 59 + xrpVendordep/robotpy_native_build_info.bzl | 34 + xrpVendordep/robotpy_pybind_build_info.bzl | 238 ++ 38 files changed, 7273 insertions(+), 92 deletions(-) create mode 100644 apriltag/robotpy_native_build_info.bzl create mode 100644 apriltag/robotpy_pybind_build_info.bzl create mode 100644 datalog/robotpy_native_build_info.bzl create mode 100644 datalog/robotpy_pybind_build_info.bzl create mode 100644 hal/robotpy_native_build_info.bzl create mode 100644 hal/robotpy_pybind_build_info.bzl create mode 100644 ntcore/robotpy_native_build_info.bzl create mode 100644 ntcore/robotpy_pybind_build_info.bzl create mode 100644 romiVendordep/robotpy_native_build_info.bzl create mode 100644 romiVendordep/robotpy_pybind_build_info.bzl create mode 100644 shared/bazel/rules/robotpy/version_template.in create mode 100644 wpilibc/robotpy_native_build_info.bzl create mode 100644 wpilibc/robotpy_pybind_build_info.bzl create mode 100644 wpimath/robotpy_native_build_info.bzl create mode 100644 wpimath/robotpy_pybind_build_info.bzl create mode 100644 wpimath/robotpy_pybind_test_info.bzl create mode 100644 xrpVendordep/robotpy_native_build_info.bzl create mode 100644 xrpVendordep/robotpy_pybind_build_info.bzl diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 3f6584cb9d..ff89a35a5c 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -121,3 +121,36 @@ jobs: name: ${{ matrix.platform }}-bazel-lint-fixes path: bazel-lint-fixes.patch if: ${{ failure() }} + + robotpy_pregeneration: + name: "Robotpy Pregeneration" + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - id: Setup_build_buddy + uses: ./.github/actions/setup-build-buddy + with: + token: ${{ secrets.BUILDBUDDY_API_KEY }} + + # You should ensure the headers are correct before trying to pregen files + - name: Test Scan Headers + run: bazel test //... -k --test_tag_filters=robotpy_scan_headers --build_tests_only + shell: bash + + - name: Run robotpy pregeneration + run: bazel run //:write_robotpy_files + + - name: Check Output + run: git --no-pager diff --exit-code HEAD + + - name: Generate diff + run: git diff HEAD > robotpy-pregeneration.patch + if: ${{ failure() }} + + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-robotpy-pregeneration-fixes + path: robotpy-pregeneration-fixes.patch + if: ${{ failure() }} diff --git a/BUILD.bazel b/BUILD.bazel index 11b2d3942a..cf7e7ee180 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -2,6 +2,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") load("@rules_pkg//:mappings.bzl", "pkg_files") load("@rules_python//python:pip.bzl", "compile_pip_requirements") load("//shared/bazel/rules:publishing.bzl", "publish_all") +load("//shared/bazel/rules/robotpy:compatibility_select.bzl", "robotpy_compatibility_select") exports_files([ "LICENSE.md", @@ -42,7 +43,7 @@ alias( # This is a helper to run all of the pregeneration scripts at once. write_source_files( - name = "write_all", + name = "write_pregenerated_files", additional_update_targets = [ "//hal:write_hal", "//ntcore:write_ntcore", @@ -126,3 +127,135 @@ publish_all( "//conditions:default": [], }), ) + +write_source_files( + name = "write_robotpy_generated_native_files", + additional_update_targets = [ + "//apriltag:robotpy-native-apriltag-generator.generate_build_info", + "//datalog:robotpy-native-datalog-generator.generate_build_info", + "//hal:robotpy-native-wpihal-generator.generate_build_info", + "//ntcore:robotpy-native-ntcore-generator.generate_build_info", + "//romiVendordep:robotpy-native-xrp-generator.generate_build_info", + "//wpilibc:robotpy-native-wpilib-generator.generate_build_info", + "//wpinet:robotpy-native-wpinet-generator.generate_build_info", + "//wpimath:robotpy-native-wpimath-generator.generate_build_info", + "//wpiutil:robotpy-native-wpiutil-generator.generate_build_info", + "//xrpVendordep:robotpy-native-xrp-generator.generate_build_info", + ], + tags = [ + "pregeneration", + "robotpy", + ], + target_compatible_with = robotpy_compatibility_select(), +) + +write_source_files( + name = "write_robotpy_generated_pybind_files", + additional_update_targets = [ + "//apriltag:robotpy-apriltag-generator.generate_build_info", + "//datalog:robotpy-datalog-generator.generate_build_info", + "//hal:robotpy-hal-generator.generate_build_info", + "//ntcore:pyntcore-generator.generate_build_info", + "//romiVendordep:robotpy-romi-generator.generate_build_info", + "//wpilibc:robotpy-wpilib-generator.generate_build_info", + "//wpinet:robotpy-wpinet-generator.generate_build_info", + "//wpimath:robotpy-wpimath-generator.generate_build_info", + "//wpimath:robotpy-wpimath_test-generator.generate_build_info", + "//wpiutil:robotpy-wpiutil-generator.generate_build_info", + "//xrpVendordep:robotpy-xrp-generator.generate_build_info", + ], + tags = [ + "pregeneration", + "robotpy", + ], + target_compatible_with = robotpy_compatibility_select(), +) + +write_source_files( + name = "write_robotpy_update_yaml_files", + additional_update_targets = [ + "//apriltag:write_robotpy-apriltag-update-yaml", + "//datalog:write_robotpy-wpilog-update-yaml", + "//hal:write_robotpy-hal-update-yaml", + "//ntcore:write_pyntcore-update-yaml", + "//romiVendordep:write_robotpy-romi-update-yaml", + "//wpilibc:write_robotpy-wpilib-update-yaml", + "//wpinet:write_robotpy-wpinet-update-yaml", + "//wpimath:write_robotpy-wpimath-update-yaml", + "//wpimath:write_robotpy-wpimath-test-update-yaml", + "//wpiutil:write_robotpy-wpiutil-update-yaml", + "//xrpVendordep:write_robotpy-xrp-update-yaml", + ], + tags = [ + "manual", + "pregeneration", + "robotpy", + ], + target_compatible_with = robotpy_compatibility_select(), +) + +write_source_files( + name = "write_robotpy_create_imports", + additional_update_targets = [ + "//apriltag:robotpy-apriltag-create-imports", + "//datalog:robotpy-wpilog-create-imports", + "//hal:robotpy-hal-create-imports", + "//ntcore:pyntcore-create-imports", + "//romiVendordep:robotpy-romi-create-imports", + "//wpilibc:robotpy-wpilib-create-imports", + "//wpinet:robotpy-wpinet-create-imports", + "//wpimath:robotpy-wpimath-create-imports", + "//wpimath:robotpy-wpimath-test-create-imports", + "//wpiutil:robotpy-wpiutil-create-imports", + "//xrpVendordep:robotpy-xrp-create-imports", + ], + tags = [ + "manual", + "pregeneration", + "robotpy", + ], + target_compatible_with = robotpy_compatibility_select(), +) + +write_source_files( + name = "write_robotpy_files", + additional_update_targets = [ + ":write_robotpy_generated_native_files", + ":write_robotpy_generated_pybind_files", + ":write_robotpy_update_yaml_files", + ], + tags = [ + "manual", + "pregeneration", + ], +) + +write_source_files( + name = "write_all", + additional_update_targets = [ + ":write_pregenerated_files", + ":write_robotpy_files", + ], + tags = [ + "manual", + "pregeneration", + ], +) + +# Helper easily run the semiwrap parsing tools on all of the robotpy projects. +filegroup( + name = "robotpy_generated_files", + srcs = [ + "//apriltag:robotpy-apriltag.generated_files", + "//datalog:robotpy-wpilog.generated_files", + "//hal:robotpy-hal.generated_files", + "//ntcore:pyntcore.generated_files", + "//wpilibc:robotpy-wpilib.generated_files", + "//wpimath:robotpy-wpimath.generated_files", + "//wpimath:robotpy-wpimath-test.generated_files", + "//wpinet:robotpy-wpinet.generated_files", + "//wpiutil:robotpy-wpiutil.generated_files", + ], + tags = ["manual"], + target_compatible_with = robotpy_compatibility_select(), +) diff --git a/README-RobotPy.md b/README-RobotPy.md index e703065a59..e99cb70ff5 100644 --- a/README-RobotPy.md +++ b/README-RobotPy.md @@ -11,3 +11,55 @@ Building the robotpy software on top of the standard C++/Java software can resul NOTE: This process is currently unlanded while robotpy gets the 2027 branch stable [Copybara](https://github.com/google/copybara) is used to maintin synchronization between the upstream robotpy repositories and the allwpilib mirror. Github actions can be manually run which will create pull requests that will update all of the robotpy files between the two repositories. The ideal process is that the allwpilib mirror is always building in CI, and once a release is created the RobotPy team can run the `wpilib -> robotpy` copybara task, make any fine tuned adjustements and create their release. In the event that additional changes are made on the robotpy side, they can run the `robotpy -> wpilib` task to push the updates back to the mirror. However the goal of the mirroring the software here is to be able to more rapidly test changes and will hopefully overwhelmingly eliminate the need for syncs this direction. + + +# Debugging Build Errors +The build process is highly automated and automatically parses C++ header files to generate pybind11 bindings. Some of these steps here are considered "pregeneration" steps, and the bazel build system will update build files as necessary. If a new header is added, or if the contents of a header file has changed, some of the pregeneration scripts might need to be run. If you encounter an error building `robotpy` code, it is recommended that you go through these steps to make sure everything is set up correctly. The examples are for `wpilibc`, but similar build tasks and tests exist for each wrapped project + +## 1. scan-headers +This can be the first source of problems if a new header file has been added. `semiwrap` will look through all of the headers for a library and notify you if a file is not covered by the projects `pyproject.toml` file. Bazel has a test case to ensure the files are up to date. + +An example test failure when a new header being introduced. You can run the test with the following command + +bazel run //wpilibc:robotpy-wpilib-scan-headers + +``` +# wpi +ExpansionHub = "wpi/ExpansionHub.hpp" +ExpansionHubMotor = "wpi/ExpansionHubMotor.hpp" +ExpansionHubPidConstants = "wpi/ExpansionHubPidConstants.hpp" +ExpansionHubServo = "wpi/ExpansionHubServo.hpp" + +``` + +To fix this, you can copy the lines from the console, and add them to the pyproject.toml file, located here `wpilibc/src/main/python/pyproject.toml` + +## 2. update-yaml +This process parses all of the header files, and creates a representation of the classes / enums / etc in yaml. Occasionally some functions might be ignored or need custom pybind code, which can be added to these files by the user. + +There is a bazel task that you can run to automatically update the files: + +`bazel run //wpilibc:write_robotpy-wpilib-update-yaml` + + +## 3. generate-build-info +This step takes the yaml files, and auto generates a bazel build script for the library. + +There is a bazel task that you can run to automatically update the files: + +`bazel run //wpilibc:robotpy-wpilib-generator.generate_build_info` + +## semiwrap errors +If all of these steps above go smoothly and have their tests pass, but the generated cpp files still won't compile, it is possible that either an update needs to be made to the semiwrap tool to handle the new complex functionality, the new functionality can be ignored, or the new functionality might be better handled with a custom pybind11 implementation. In any case, it is best to reach out to the robotpy team for guidance. + +## Running multiple projects at once +Each project has its own `scan-headers` and various pregeneration tools, but you can run all of them at once with the following commands. Note: Sometimes if something in the dependency chain for a library fails, these amalgamation commands will also fail. If that happens, fix your way up the dependency chain project by project. + +``` +# Scan Headers +bazel test //... -k --test_tag_filters=robotpy_scan_headers --build_tests_only + +# All pregen +bazel run //:write_robotpy_files + +``` diff --git a/apriltag/BUILD.bazel b/apriltag/BUILD.bazel index 01f771c83f..b51d967f1f 100644 --- a/apriltag/BUILD.bazel +++ b/apriltag/BUILD.bazel @@ -1,12 +1,17 @@ +load("@allwpilib_pip_deps//:requirements.bzl", "requirement") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load("@rules_java//java:defs.bzl", "java_binary") load("@rules_pkg//:mappings.bzl", "pkg_files") load("@rules_python//python:defs.bzl", "py_binary") +load("//apriltag:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//apriltag:robotpy_pybind_build_info.bzl", "apriltag_extension", "define_pybind_library") load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library") load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules:packaging.bzl", "package_minimal_jni_project") load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") filegroup( name = "doxygen-files", @@ -212,3 +217,56 @@ package_minimal_jni_project( maven_artifact_name = "apriltag-cpp", maven_group_id = "org.wpilib.apriltag", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-apriltag-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", + third_party_dirs = ["apriltag"], +) + +define_native_wrapper( + name = "robotpy-native-apriltag", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +PYBIND_PKGCFG_DEPS = [ + "//apriltag:native/apriltag/robotpy-native-apriltag.pc", + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpimath:robotpy-wpimath.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", +] + +generate_robotpy_pybind_build_info( + name = "robotpy-apriltag-generator", + additional_srcs = [":robotpy-native-apriltag.copy_headers"], + package_root_file = "src/main/python/robotpy_apriltag/__init__.py", + pkgcfgs = PYBIND_PKGCFG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/*.yml"]), +) + +apriltag_extension( + srcs = ["src/main/python/robotpy_apriltag/src/main.cpp"], + includes = [ + "src/main/python/datalog/", + ], +) + +define_pybind_library( + name = "robotpy-apriltag", + pkgcfgs = PYBIND_PKGCFG_DEPS, +) + +robotpy_py_test( + "python_tests", + srcs = glob(["src/test/python/**/*.py"]), + data = glob([ + "src/test/python/*.png", + "src/test/python/*.jpg", + ]), + deps = [ + ":robotpy-apriltag", + requirement("pytest"), + requirement("opencv-python"), + ], +) diff --git a/apriltag/robotpy_native_build_info.bzl b/apriltag/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..6e11869911 --- /dev/null +++ b/apriltag/robotpy_native_build_info.bzl @@ -0,0 +1,39 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True) + native.glob([ + "src/main/native/thirdparty/apriltag/include/**", + ]), + out = "native/apriltag/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "apriltag/src/generated/main/native/include": "", + "apriltag/src/main/native/include": "", + "apriltag/src/main/native/thirdparty/apriltag/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/apriltag/_init_robotpy_native_apriltag.py", + pc_file = "native/apriltag/robotpy-native-apriltag.pc", + pc_deps = [ + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + ], + deps = [ + "//wpimath:robotpy-native-wpimath", + "//wpiutil:robotpy-native-wpiutil", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/apriltag", + install_path = "native/apriltag/", + ) diff --git a/apriltag/robotpy_pybind_build_info.bzl b/apriltag/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..d5a16ab4f7 --- /dev/null +++ b/apriltag/robotpy_pybind_build_info.bzl @@ -0,0 +1,242 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def apriltag_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + APRILTAG_HEADER_GEN = [ + struct( + class_name = "AprilTag", + yml_file = "semiwrap/AprilTag.yml", + header_root = "$(execpath :robotpy-native-apriltag.copy_headers)", + header_file = "$(execpath :robotpy-native-apriltag.copy_headers)/wpi/apriltag/AprilTag.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::apriltag::AprilTag", "wpi__apriltag__AprilTag.hpp"), + ], + ), + struct( + class_name = "AprilTagDetection", + yml_file = "semiwrap/AprilTagDetection.yml", + header_root = "$(execpath :robotpy-native-apriltag.copy_headers)", + header_file = "$(execpath :robotpy-native-apriltag.copy_headers)/wpi/apriltag/AprilTagDetection.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::apriltag::AprilTagDetection", "wpi__apriltag__AprilTagDetection.hpp"), + ("wpi::apriltag::AprilTagDetection::Point", "wpi__apriltag__AprilTagDetection__Point.hpp"), + ], + ), + struct( + class_name = "AprilTagDetector", + yml_file = "semiwrap/AprilTagDetector.yml", + header_root = "$(execpath :robotpy-native-apriltag.copy_headers)", + header_file = "$(execpath :robotpy-native-apriltag.copy_headers)/wpi/apriltag/AprilTagDetector.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::apriltag::AprilTagDetector", "wpi__apriltag__AprilTagDetector.hpp"), + ("wpi::apriltag::AprilTagDetector::Config", "wpi__apriltag__AprilTagDetector__Config.hpp"), + ("wpi::apriltag::AprilTagDetector::QuadThresholdParameters", "wpi__apriltag__AprilTagDetector__QuadThresholdParameters.hpp"), + ("wpi::apriltag::AprilTagDetector::Results", "wpi__apriltag__AprilTagDetector__Results.hpp"), + ], + ), + struct( + class_name = "AprilTagFieldLayout", + yml_file = "semiwrap/AprilTagFieldLayout.yml", + header_root = "$(execpath :robotpy-native-apriltag.copy_headers)", + header_file = "$(execpath :robotpy-native-apriltag.copy_headers)/wpi/apriltag/AprilTagFieldLayout.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::apriltag::AprilTagFieldLayout", "wpi__apriltag__AprilTagFieldLayout.hpp"), + ], + ), + struct( + class_name = "AprilTagFields", + yml_file = "semiwrap/AprilTagFields.yml", + header_root = "$(execpath :robotpy-native-apriltag.copy_headers)", + header_file = "$(execpath :robotpy-native-apriltag.copy_headers)/wpi/apriltag/AprilTagFields.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "AprilTagPoseEstimate", + yml_file = "semiwrap/AprilTagPoseEstimate.yml", + header_root = "$(execpath :robotpy-native-apriltag.copy_headers)", + header_file = "$(execpath :robotpy-native-apriltag.copy_headers)/wpi/apriltag/AprilTagPoseEstimate.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::apriltag::AprilTagPoseEstimate", "wpi__apriltag__AprilTagPoseEstimate.hpp"), + ], + ), + struct( + class_name = "AprilTagPoseEstimator", + yml_file = "semiwrap/AprilTagPoseEstimator.yml", + header_root = "$(execpath :robotpy-native-apriltag.copy_headers)", + header_file = "$(execpath :robotpy-native-apriltag.copy_headers)/wpi/apriltag/AprilTagPoseEstimator.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::apriltag::AprilTagPoseEstimator", "wpi__apriltag__AprilTagPoseEstimator.hpp"), + ("wpi::apriltag::AprilTagPoseEstimator::Config", "wpi__apriltag__AprilTagPoseEstimator__Config.hpp"), + ], + ), + ] + + resolve_casters( + name = "apriltag.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "apriltag.casters.pkl", + dep_file = "apriltag.casters.d", + ) + + gen_libinit( + name = "apriltag.gen_lib_init", + output_file = "src/main/python/robotpy_apriltag/_init__apriltag.py", + modules = ["native.apriltag._init_robotpy_native_apriltag", "wpiutil._init__wpiutil", "wpimath._init__wpimath"], + ) + + gen_pkgconf( + name = "apriltag.gen_pkgconf", + libinit_py = "robotpy_apriltag._init__apriltag", + module_pkg_name = "robotpy_apriltag._apriltag", + output_file = "apriltag.pc", + pkg_name = "apriltag", + install_path = "src/main/python/robotpy_apriltag", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/robotpy_apriltag/__init__.py", + ) + + gen_modinit_hpp( + name = "apriltag.gen_modinit_hpp", + input_dats = [x.class_name for x in APRILTAG_HEADER_GEN], + libname = "_apriltag", + output_file = "semiwrap_init.robotpy_apriltag._apriltag.hpp", + ) + + run_header_gen( + name = "apriltag", + casters_pickle = "apriltag.casters.pkl", + header_gen_config = APRILTAG_HEADER_GEN, + trampoline_subpath = "src/main/python/robotpy_apriltag", + deps = header_to_dat_deps, + local_native_libraries = [ + "//apriltag:robotpy-native-apriltag.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "apriltag", + install_path = "src/main/python/robotpy_apriltag/", + extension_name = "_apriltag", + generated_srcs = [":apriltag.generated_srcs"], + semiwrap_header = [":apriltag.gen_modinit_hpp"], + deps = [ + ":apriltag.tmpl_hdrs", + ":apriltag.trampoline_hdrs", + "//apriltag:apriltag", + "//wpimath:wpimath", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//apriltag:shared/apriltag", + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "apriltag.generated_files", + srcs = [ + "apriltag.gen_modinit_hpp.gen", + "apriltag.header_gen_files", + "apriltag.gen_pkgconf", + "apriltag.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "apriltag.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/robotpy_apriltag/apriltag.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/robotpy_apriltag/**"], exclude = ["src/main/python/robotpy_apriltag/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/robotpy_apriltag/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/robotpy_apriltag/**/*.py"]) + [ + "src/main/python/robotpy_apriltag/_init__apriltag.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/robotpy_apriltag/_apriltag", + ":apriltag.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//apriltag:robotpy-native-apriltag", + "//wpimath:robotpy-wpimath", + "//wpiutil:robotpy-wpiutil", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//apriltag:robotpy-native-apriltag.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + package_root_file = "src/main/python/robotpy_apriltag/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//apriltag:robotpy-native-apriltag.copy_headers", + ], + package_root_file = "src/main/python/robotpy_apriltag/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + ) diff --git a/datalog/BUILD.bazel b/datalog/BUILD.bazel index 510e3564fe..8301dfb6a5 100644 --- a/datalog/BUILD.bazel +++ b/datalog/BUILD.bazel @@ -1,10 +1,15 @@ +load("@allwpilib_pip_deps//:requirements.bzl", "requirement") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test") load("@rules_java//java:defs.bzl", "java_binary") load("@rules_python//python:defs.bzl", "py_binary") +load("//datalog:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//datalog:robotpy_pybind_build_info.bzl", "define_pybind_library", "wpilog_extension") load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library") load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules:packaging.bzl", "package_minimal_jni_project") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") wpilib_cc_library( name = "datalog", @@ -146,3 +151,48 @@ package_minimal_jni_project( maven_artifact_name = "datalog-cpp", maven_group_id = "org.wpilib.datalog", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-datalog-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +define_native_wrapper( + name = "robotpy-native-datalog", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +PYBIND_PKGCFG_DEPS = [ + "//datalog:native/datalog/robotpy-native-datalog.pc", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", +] + +generate_robotpy_pybind_build_info( + name = "robotpy-datalog-generator", + additional_srcs = [":robotpy-native-datalog.copy_headers"], + package_root_file = "src/main/python/wpilog/__init__.py", + pkgcfgs = PYBIND_PKGCFG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/*.yml"]), +) + +wpilog_extension( + srcs = ["src/main/python/src/main.cpp"], + includes = [ + "src/main/python/datalog/", + ], +) + +define_pybind_library( + name = "robotpy-wpilog", + pkgcfgs = PYBIND_PKGCFG_DEPS, +) + +robotpy_py_test( + "datalog_tests", + srcs = glob(["src/test/python/**/*.py"]), + deps = [ + ":robotpy-wpilog", + requirement("pytest"), + ], +) diff --git a/datalog/robotpy_native_build_info.bzl b/datalog/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..67f7f33f2b --- /dev/null +++ b/datalog/robotpy_native_build_info.bzl @@ -0,0 +1,34 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True), + out = "native/datalog/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "datalog/src/generated/main/native/include": "", + "datalog/src/main/native/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/datalog/_init_robotpy_native_datalog.py", + pc_file = "native/datalog/robotpy-native-datalog.pc", + pc_deps = [ + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + ], + deps = [ + "//wpiutil:robotpy-native-wpiutil", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/datalog", + install_path = "native/datalog/", + ) diff --git a/datalog/robotpy_pybind_build_info.bzl b/datalog/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..8ad4c950a0 --- /dev/null +++ b/datalog/robotpy_pybind_build_info.bzl @@ -0,0 +1,235 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def wpilog_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPILOG_HEADER_GEN = [ + struct( + class_name = "DataLog", + yml_file = "semiwrap/DataLog.yml", + header_root = "$(execpath :robotpy-native-datalog.copy_headers)", + header_file = "$(execpath :robotpy-native-datalog.copy_headers)/wpi/datalog/DataLog.hpp", + tmpl_class_names = [ + ("DataLog_tmpl1", "StructLogEntry"), + ("DataLog_tmpl2", "StructArrayLogEntry"), + ("DataLog_tmpl3", "_RawLogEntryImpl"), + ("DataLog_tmpl4", "_BooleanLogEntryImpl"), + ("DataLog_tmpl5", "_IntegerLogEntryImpl"), + ("DataLog_tmpl6", "_FloatLogEntryImpl"), + ("DataLog_tmpl7", "_DoubleLogEntryImpl"), + ("DataLog_tmpl8", "_StringLogEntryImpl"), + ("DataLog_tmpl9", "_BooleanArrayLogEntryImpl"), + ("DataLog_tmpl10", "_IntegerArrayLogEntryImpl"), + ("DataLog_tmpl11", "_FloatArrayLogEntryImpl"), + ("DataLog_tmpl12", "_DoubleArrayLogEntryImpl"), + ("DataLog_tmpl13", "_StringArrayLogEntryImpl"), + ], + trampolines = [ + ("wpi::log::DataLog", "wpi__log__DataLog.hpp"), + ("wpi::log::DataLogEntry", "wpi__log__DataLogEntry.hpp"), + ("wpi::log::DataLogValueEntryImpl", "wpi__log__DataLogValueEntryImpl.hpp"), + ("wpi::log::RawLogEntry", "wpi__log__RawLogEntry.hpp"), + ("wpi::log::BooleanLogEntry", "wpi__log__BooleanLogEntry.hpp"), + ("wpi::log::IntegerLogEntry", "wpi__log__IntegerLogEntry.hpp"), + ("wpi::log::FloatLogEntry", "wpi__log__FloatLogEntry.hpp"), + ("wpi::log::DoubleLogEntry", "wpi__log__DoubleLogEntry.hpp"), + ("wpi::log::StringLogEntry", "wpi__log__StringLogEntry.hpp"), + ("wpi::log::BooleanArrayLogEntry", "wpi__log__BooleanArrayLogEntry.hpp"), + ("wpi::log::IntegerArrayLogEntry", "wpi__log__IntegerArrayLogEntry.hpp"), + ("wpi::log::FloatArrayLogEntry", "wpi__log__FloatArrayLogEntry.hpp"), + ("wpi::log::DoubleArrayLogEntry", "wpi__log__DoubleArrayLogEntry.hpp"), + ("wpi::log::StringArrayLogEntry", "wpi__log__StringArrayLogEntry.hpp"), + ("wpi::log::StructLogEntry", "wpi__log__StructLogEntry.hpp"), + ("wpi::log::StructArrayLogEntry", "wpi__log__StructArrayLogEntry.hpp"), + ], + ), + struct( + class_name = "DataLogBackgroundWriter", + yml_file = "semiwrap/DataLogBackgroundWriter.yml", + header_root = "$(execpath :robotpy-native-datalog.copy_headers)", + header_file = "$(execpath :robotpy-native-datalog.copy_headers)/wpi/datalog/DataLogBackgroundWriter.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::log::DataLogBackgroundWriter", "wpi__log__DataLogBackgroundWriter.hpp"), + ], + ), + struct( + class_name = "DataLogReader", + yml_file = "semiwrap/DataLogReader.yml", + header_root = "$(execpath :robotpy-native-datalog.copy_headers)", + header_file = "$(execpath :robotpy-native-datalog.copy_headers)/wpi/datalog/DataLogReader.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::log::StartRecordData", "wpi__log__StartRecordData.hpp"), + ("wpi::log::MetadataRecordData", "wpi__log__MetadataRecordData.hpp"), + ("wpi::log::DataLogRecord", "wpi__log__DataLogRecord.hpp"), + ("wpi::log::DataLogReader", "wpi__log__DataLogReader.hpp"), + ], + ), + struct( + class_name = "DataLogWriter", + yml_file = "semiwrap/DataLogWriter.yml", + header_root = "$(execpath :robotpy-native-datalog.copy_headers)", + header_file = "$(execpath :robotpy-native-datalog.copy_headers)/wpi/datalog/DataLogWriter.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::log::DataLogWriter", "wpi__log__DataLogWriter.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpilog.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpilog.casters.pkl", + dep_file = "wpilog.casters.d", + ) + + gen_libinit( + name = "wpilog.gen_lib_init", + output_file = "src/main/python/wpilog/_init__wpilog.py", + modules = ["native.datalog._init_robotpy_native_datalog", "wpiutil._init__wpiutil"], + ) + + gen_pkgconf( + name = "wpilog.gen_pkgconf", + libinit_py = "wpilog._init__wpilog", + module_pkg_name = "wpilog._wpilog", + output_file = "wpilog.pc", + pkg_name = "wpilog", + install_path = "src/main/python/wpilog", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpilog/__init__.py", + ) + + gen_modinit_hpp( + name = "wpilog.gen_modinit_hpp", + input_dats = [x.class_name for x in WPILOG_HEADER_GEN], + libname = "_wpilog", + output_file = "semiwrap_init.wpilog._wpilog.hpp", + ) + + run_header_gen( + name = "wpilog", + casters_pickle = "wpilog.casters.pkl", + header_gen_config = WPILOG_HEADER_GEN, + trampoline_subpath = "src/main/python/wpilog", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpilog", + install_path = "src/main/python/wpilog/", + extension_name = "_wpilog", + generated_srcs = [":wpilog.generated_srcs"], + semiwrap_header = [":wpilog.gen_modinit_hpp"], + deps = [ + ":wpilog.tmpl_hdrs", + ":wpilog.trampoline_hdrs", + "//datalog:datalog", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//datalog:shared/datalog", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpilog.generated_files", + srcs = [ + "wpilog.gen_modinit_hpp.gen", + "wpilog.header_gen_files", + "wpilog.gen_pkgconf", + "wpilog.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "wpilog.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/wpilog/wpilog.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/wpilog/**"], exclude = ["src/main/python/wpilog/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/wpilog/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/wpilog/**/*.py"]) + [ + "src/main/python/wpilog/_init__wpilog.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/wpilog/_wpilog", + ":wpilog.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//datalog:robotpy-native-datalog", + "//wpiutil:robotpy-wpiutil", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//datalog:robotpy-native-datalog.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + package_root_file = "src/main/python/wpilog/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//datalog:robotpy-native-datalog.copy_headers", + ], + package_root_file = "src/main/python/wpilog/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + ) diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index d80a8a94a6..53d5e31a1b 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -1,13 +1,18 @@ +load("@allwpilib_pip_deps//:requirements.bzl", "requirement") load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load("@rules_java//java:defs.bzl", "java_binary") load("@rules_pkg//:mappings.bzl", "pkg_files") load("@rules_python//python:defs.bzl", "py_binary") load("//hal:generate.bzl", "generate_hal") +load("//hal:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//hal:robotpy_pybind_build_info.bzl", "define_pybind_library", "hal_simulation_extension", "wpihal_extension") load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library") load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules:packaging.bzl", "package_minimal_jni_project") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") filegroup( name = "doxygen-files", @@ -232,3 +237,60 @@ package_minimal_jni_project( maven_artifact_name = "hal-cpp", maven_group_id = "org.wpilib.hal", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-wpihal-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +define_native_wrapper( + name = "robotpy-native-wpihal", +) + +PYBIND_PKGCFG_DEPS = [ + "//datalog:native/datalog/robotpy-native-datalog.pc", + "//datalog:robotpy-wpilog.generated_pkgcfg_files", + "//hal:native/wpihal/robotpy-native-wpihal.pc", + "//ntcore:native/ntcore/robotpy-native-ntcore.pc", + "//ntcore:pyntcore.generated_pkgcfg_files", + "//wpinet:native/wpinet/robotpy-native-wpinet.pc", + "//wpinet:robotpy-wpinet.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", +] + +generate_robotpy_pybind_build_info( + name = "robotpy-hal-generator", + additional_srcs = [":robotpy-native-wpihal.copy_headers"], + package_root_file = "src/main/python/hal/__init__.py", + pkgcfgs = PYBIND_PKGCFG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/**/*.yml"]), +) + +hal_simulation_extension( + srcs = glob(["src/main/python/hal/simulation/*.cpp"]), + extra_hdrs = glob(["src/main/python/hal/simulation/*.h"]), + includes = ["src/main/python/hal/simulation"], +) + +wpihal_extension( + srcs = ["src/main/python/hal/src/hal.cpp"], + extra_hdrs = ["src/main/python/hal/src/ds_types_fmt.h"], + includes = [ + "src/main/python/hal", + ], +) + +define_pybind_library( + name = "robotpy-hal", + pkgcfgs = PYBIND_PKGCFG_DEPS, +) + +robotpy_py_test( + "python_tests", + srcs = glob(["src/test/python/**/*.py"]), + deps = [ + ":robotpy-hal", + requirement("pytest"), + ], +) diff --git a/hal/robotpy_native_build_info.bzl b/hal/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..9a58e6d195 --- /dev/null +++ b/hal/robotpy_native_build_info.bzl @@ -0,0 +1,36 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True), + out = "native/wpihal/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "hal/src/generated/main/native/include": "", + "hal/src/main/native/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/wpihal/_init_robotpy_native_wpihal.py", + pc_file = "native/wpihal/robotpy-native-wpihal.pc", + pc_deps = [ + "//ntcore:native/ntcore/robotpy-native-ntcore.pc", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + ], + deps = [ + "//ntcore:robotpy-native-ntcore", + "//wpiutil:robotpy-native-wpiutil", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/wpiHal", + install_path = "native/wpihal/", + ) diff --git a/hal/robotpy_pybind_build_info.bzl b/hal/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..b84f829cc6 --- /dev/null +++ b/hal/robotpy_pybind_build_info.bzl @@ -0,0 +1,665 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def hal_simulation_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + HAL_SIMULATION_HEADER_GEN = [ + struct( + class_name = "AddressableLEDData", + yml_file = "semiwrap/simulation/AddressableLEDData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/AddressableLEDData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "AnalogInData", + yml_file = "semiwrap/simulation/AnalogInData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/AnalogInData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "CTREPCMData", + yml_file = "semiwrap/simulation/CTREPCMData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/CTREPCMData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DIOData", + yml_file = "semiwrap/simulation/DIOData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/DIOData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DigitalPWMData", + yml_file = "semiwrap/simulation/DigitalPWMData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/DigitalPWMData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DriverStationData", + yml_file = "semiwrap/simulation/DriverStationData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/DriverStationData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DutyCycleData", + yml_file = "semiwrap/simulation/DutyCycleData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/DutyCycleData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "EncoderData", + yml_file = "semiwrap/simulation/EncoderData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/EncoderData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "MockHooks", + yml_file = "semiwrap/simulation/MockHooks.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/MockHooks.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "NotifierData", + yml_file = "semiwrap/simulation/NotifierData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/NotifierData.h", + tmpl_class_names = [], + trampolines = [ + ("HALSIM_NotifierInfo", "__HALSIM_NotifierInfo.hpp"), + ], + ), + struct( + class_name = "PWMData", + yml_file = "semiwrap/simulation/PWMData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/PWMData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "PowerDistributionData", + yml_file = "semiwrap/simulation/PowerDistributionData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/PowerDistributionData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "REVPHData", + yml_file = "semiwrap/simulation/REVPHData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/REVPHData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Reset", + yml_file = "semiwrap/simulation/Reset.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/Reset.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "RoboRioData", + yml_file = "semiwrap/simulation/RoboRioData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/RoboRioData.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "SimDeviceData", + yml_file = "semiwrap/simulation/SimDeviceData.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/simulation/SimDeviceData.h", + tmpl_class_names = [], + trampolines = [], + ), + ] + + resolve_casters( + name = "hal_simulation.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "hal_simulation.casters.pkl", + dep_file = "hal_simulation.casters.d", + ) + + gen_libinit( + name = "hal_simulation.gen_lib_init", + output_file = "src/main/python/hal/simulation/_init__simulation.py", + modules = ["native.wpihal._init_robotpy_native_wpihal", "wpiutil._init__wpiutil", "ntcore._init__ntcore"], + ) + + gen_pkgconf( + name = "hal_simulation.gen_pkgconf", + libinit_py = "hal.simulation._init__simulation", + module_pkg_name = "hal.simulation._simulation", + output_file = "hal_simulation.pc", + pkg_name = "hal_simulation", + install_path = "src/main/python/hal/simulation", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/hal/__init__.py", + ) + + gen_modinit_hpp( + name = "hal_simulation.gen_modinit_hpp", + input_dats = [x.class_name for x in HAL_SIMULATION_HEADER_GEN], + libname = "_simulation", + output_file = "semiwrap_init.hal.simulation._simulation.hpp", + ) + + run_header_gen( + name = "hal_simulation", + casters_pickle = "hal_simulation.casters.pkl", + header_gen_config = HAL_SIMULATION_HEADER_GEN, + trampoline_subpath = "src/main/python/hal/simulation", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "hal_simulation", + install_path = "src/main/python/hal/simulation/", + extension_name = "_simulation", + generated_srcs = [":hal_simulation.generated_srcs"], + semiwrap_header = [":hal_simulation.gen_modinit_hpp"], + deps = [ + ":hal_simulation.tmpl_hdrs", + ":hal_simulation.trampoline_hdrs", + "//hal:wpiHal", + "//ntcore:ntcore", + "//ntcore:ntcore_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//hal:shared/wpiHal", + "//ntcore:shared/ntcore", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "hal_simulation.generated_files", + srcs = [ + "hal_simulation.gen_modinit_hpp.gen", + "hal_simulation.header_gen_files", + "hal_simulation.gen_pkgconf", + "hal_simulation.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpihal_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIHAL_HEADER_GEN = [ + struct( + class_name = "AddressableLED", + yml_file = "semiwrap/AddressableLED.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/AddressableLED.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "AddressableLEDTypes", + yml_file = "semiwrap/AddressableLEDTypes.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/AddressableLEDTypes.h", + tmpl_class_names = [], + trampolines = [ + ("HAL_AddressableLEDData", "__HAL_AddressableLEDData.hpp"), + ], + ), + struct( + class_name = "AnalogInput", + yml_file = "semiwrap/AnalogInput.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/AnalogInput.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "CAN", + yml_file = "semiwrap/CAN.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/CAN.h", + tmpl_class_names = [], + trampolines = [ + ("HAL_CANStreamMessage", "__HAL_CANStreamMessage.hpp"), + ], + ), + struct( + class_name = "CANAPI", + yml_file = "semiwrap/CANAPI.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/CANAPI.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "CANAPITypes", + yml_file = "semiwrap/CANAPITypes.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/CANAPITypes.h", + tmpl_class_names = [], + trampolines = [ + ("HAL_CANMessage", "__HAL_CANMessage.hpp"), + ("HAL_CANReceiveMessage", "__HAL_CANReceiveMessage.hpp"), + ], + ), + struct( + class_name = "CTREPCM", + yml_file = "semiwrap/CTREPCM.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/CTREPCM.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Constants", + yml_file = "semiwrap/Constants.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Constants.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Counter", + yml_file = "semiwrap/Counter.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Counter.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DIO", + yml_file = "semiwrap/DIO.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/DIO.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DriverStation", + yml_file = "semiwrap/DriverStation.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/DriverStation.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DriverStationTypes", + yml_file = "semiwrap/DriverStationTypes.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/DriverStationTypes.h", + tmpl_class_names = [], + trampolines = [ + ("HAL_ControlWord", "__HAL_ControlWord.hpp"), + ("HAL_JoystickAxes", "__HAL_JoystickAxes.hpp"), + ("HAL_JoystickPOVs", "__HAL_JoystickPOVs.hpp"), + ("HAL_JoystickButtons", "__HAL_JoystickButtons.hpp"), + ("HAL_JoystickDescriptor", "__HAL_JoystickDescriptor.hpp"), + ("HAL_MatchInfo", "__HAL_MatchInfo.hpp"), + ], + ), + struct( + class_name = "DutyCycle", + yml_file = "semiwrap/DutyCycle.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/DutyCycle.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Encoder", + yml_file = "semiwrap/Encoder.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Encoder.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Extensions", + yml_file = "semiwrap/Extensions.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Extensions.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "HALBase", + yml_file = "semiwrap/HALBase.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/HALBase.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "I2C", + yml_file = "semiwrap/I2C.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/I2C.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "I2CTypes", + yml_file = "semiwrap/I2CTypes.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/I2CTypes.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Main", + yml_file = "semiwrap/Main.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Main.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Notifier", + yml_file = "semiwrap/Notifier.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Notifier.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "PWM", + yml_file = "semiwrap/PWM.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/PWM.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Ports", + yml_file = "semiwrap/Ports.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Ports.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Power", + yml_file = "semiwrap/Power.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Power.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "PowerDistribution", + yml_file = "semiwrap/PowerDistribution.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/PowerDistribution.h", + tmpl_class_names = [], + trampolines = [ + ("HAL_PowerDistributionVersion", "__HAL_PowerDistributionVersion.hpp"), + ("HAL_PowerDistributionFaults", "__HAL_PowerDistributionFaults.hpp"), + ("HAL_PowerDistributionStickyFaults", "__HAL_PowerDistributionStickyFaults.hpp"), + ], + ), + struct( + class_name = "REVPH", + yml_file = "semiwrap/REVPH.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/REVPH.h", + tmpl_class_names = [], + trampolines = [ + ("HAL_REVPHVersion", "__HAL_REVPHVersion.hpp"), + ("HAL_REVPHCompressorConfig", "__HAL_REVPHCompressorConfig.hpp"), + ("HAL_REVPHFaults", "__HAL_REVPHFaults.hpp"), + ("HAL_REVPHStickyFaults", "__HAL_REVPHStickyFaults.hpp"), + ], + ), + struct( + class_name = "SerialPort", + yml_file = "semiwrap/SerialPort.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/SerialPort.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "SimDevice", + yml_file = "semiwrap/SimDevice.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/SimDevice.h", + tmpl_class_names = [], + trampolines = [ + ("wpi::hal::SimValue", "wpi__hal__SimValue.hpp"), + ("wpi::hal::SimInt", "wpi__hal__SimInt.hpp"), + ("wpi::hal::SimLong", "wpi__hal__SimLong.hpp"), + ("wpi::hal::SimDouble", "wpi__hal__SimDouble.hpp"), + ("wpi::hal::SimEnum", "wpi__hal__SimEnum.hpp"), + ("wpi::hal::SimBoolean", "wpi__hal__SimBoolean.hpp"), + ("wpi::hal::SimDevice", "wpi__hal__SimDevice.hpp"), + ], + ), + struct( + class_name = "UsageReporting", + yml_file = "semiwrap/UsageReporting.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/UsageReporting.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Threads", + yml_file = "semiwrap/Threads.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/Threads.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "HandlesInternal", + yml_file = "semiwrap/HandlesInternal.yml", + header_root = "$(execpath :robotpy-native-wpihal.copy_headers)", + header_file = "$(execpath :robotpy-native-wpihal.copy_headers)/wpi/hal/handles/HandlesInternal.h", + tmpl_class_names = [], + trampolines = [], + ), + ] + + resolve_casters( + name = "wpihal.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpihal.casters.pkl", + dep_file = "wpihal.casters.d", + ) + + gen_libinit( + name = "wpihal.gen_lib_init", + output_file = "src/main/python/hal/_init__wpiHal.py", + modules = ["native.wpihal._init_robotpy_native_wpihal", "wpiutil._init__wpiutil", "ntcore._init__ntcore"], + ) + + gen_pkgconf( + name = "wpihal.gen_pkgconf", + libinit_py = "hal._init__wpiHal", + module_pkg_name = "hal._wpiHal", + output_file = "wpihal.pc", + pkg_name = "wpihal", + install_path = "src/main/python/hal", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/hal/__init__.py", + ) + + gen_modinit_hpp( + name = "wpihal.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIHAL_HEADER_GEN], + libname = "_wpiHal", + output_file = "semiwrap_init.hal._wpiHal.hpp", + ) + + run_header_gen( + name = "wpihal", + casters_pickle = "wpihal.casters.pkl", + header_gen_config = WPIHAL_HEADER_GEN, + trampoline_subpath = "src/main/python/hal", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpihal", + install_path = "src/main/python/hal/", + extension_name = "_wpiHal", + generated_srcs = [":wpihal.generated_srcs"], + semiwrap_header = [":wpihal.gen_modinit_hpp"], + deps = [ + ":wpihal.tmpl_hdrs", + ":wpihal.trampoline_hdrs", + "//hal:wpiHal", + "//ntcore:ntcore", + "//ntcore:ntcore_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//hal:shared/wpiHal", + "//ntcore:shared/ntcore", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpihal.generated_files", + srcs = [ + "wpihal.gen_modinit_hpp.gen", + "wpihal.header_gen_files", + "wpihal.gen_pkgconf", + "wpihal.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "hal_simulation.generated_files", + "wpihal.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/hal/simulation/hal_simulation.pc", + "src/main/python/hal/wpihal.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/hal/**"], exclude = ["src/main/python/hal/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/hal/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/hal/**/*.py"]) + [ + "src/main/python/hal/simulation/_init__simulation.py", + "src/main/python/hal/_init__wpiHal.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/hal/simulation/_simulation", + ":src/main/python/hal/_wpiHal", + ":hal_simulation.trampoline_hdr_files", + ":wpihal.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//hal:robotpy-native-wpihal", + "//ntcore:pyntcore", + "//wpiutil:robotpy-wpiutil", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + package_root_file = "src/main/python/hal/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//hal:robotpy-native-wpihal.copy_headers", + ], + package_root_file = "src/main/python/hal/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + ) diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel index 1f70ad922e..af07a45114 100644 --- a/ntcore/BUILD.bazel +++ b/ntcore/BUILD.bazel @@ -4,10 +4,14 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load("@rules_java//java:defs.bzl", "java_binary") load("@rules_python//python:defs.bzl", "py_binary") load("//ntcore:generate_ntcore.bzl", "generate_ntcore") +load("//ntcore:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//ntcore:robotpy_pybind_build_info.bzl", "define_pybind_library", "ntcore_extension") load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library") load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules:packaging.bzl", "package_default_jni_project") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") filegroup( name = "doxygen-files", @@ -224,3 +228,56 @@ package_default_jni_project( maven_artifact_name = "ntcore-cpp", maven_group_id = "org.wpilib.ntcore", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-ntcore-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +define_native_wrapper( + name = "robotpy-native-ntcore", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +PYBIND_PKGCFG_DEPS = [ + "//datalog:native/datalog/robotpy-native-datalog.pc", + "//datalog:robotpy-wpilog.generated_pkgcfg_files", + "//ntcore:native/ntcore/robotpy-native-ntcore.pc", + "//wpinet:native/wpinet/robotpy-native-wpinet.pc", + "//wpinet:robotpy-wpinet.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", +] + +generate_robotpy_pybind_build_info( + name = "pyntcore-generator", + additional_srcs = [":robotpy-native-ntcore.copy_headers"], + package_root_file = "src/main/python/ntcore/__init__.py", + pkgcfgs = PYBIND_PKGCFG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/*.yml"]), +) + +ntcore_extension( + srcs = glob(["src/main/python/ntcore/src/*.cpp"]), + extra_hdrs = glob([ + "src/main/python/ntcore/src/*.h", + "src/main/python/ntcore/src/*.inl", + ]), + includes = [ + "src/main/python/ntcore/", + ], +) + +define_pybind_library( + name = "pyntcore", + pkgcfgs = PYBIND_PKGCFG_DEPS, +) + +robotpy_py_test( + "python_tests", + srcs = glob(["src/test/python/**/*.py"]), + deps = [ + ":pyntcore", + requirement("pytest"), + ], +) diff --git a/ntcore/robotpy_native_build_info.bzl b/ntcore/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..b9e58ffa56 --- /dev/null +++ b/ntcore/robotpy_native_build_info.bzl @@ -0,0 +1,38 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True), + out = "native/ntcore/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "ntcore/src/generated/main/native/include": "", + "ntcore/src/main/native/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/ntcore/_init_robotpy_native_ntcore.py", + pc_file = "native/ntcore/robotpy-native-ntcore.pc", + pc_deps = [ + "//datalog:native/datalog/robotpy-native-datalog.pc", + "//wpinet:native/wpinet/robotpy-native-wpinet.pc", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + ], + deps = [ + "//datalog:robotpy-native-datalog", + "//wpinet:robotpy-native-wpinet", + "//wpiutil:robotpy-native-wpiutil", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/ntcore", + install_path = "native/ntcore/", + ) diff --git a/ntcore/robotpy_pybind_build_info.bzl b/ntcore/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..0d3178a5ca --- /dev/null +++ b/ntcore/robotpy_pybind_build_info.bzl @@ -0,0 +1,514 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def ntcore_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + NTCORE_HEADER_GEN = [ + struct( + class_name = "BooleanArrayTopic", + yml_file = "semiwrap/BooleanArrayTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/BooleanArrayTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::BooleanArraySubscriber", "wpi__nt__BooleanArraySubscriber.hpp"), + ("wpi::nt::BooleanArrayPublisher", "wpi__nt__BooleanArrayPublisher.hpp"), + ("wpi::nt::BooleanArrayEntry", "wpi__nt__BooleanArrayEntry.hpp"), + ("wpi::nt::BooleanArrayTopic", "wpi__nt__BooleanArrayTopic.hpp"), + ], + ), + struct( + class_name = "BooleanTopic", + yml_file = "semiwrap/BooleanTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/BooleanTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::BooleanSubscriber", "wpi__nt__BooleanSubscriber.hpp"), + ("wpi::nt::BooleanPublisher", "wpi__nt__BooleanPublisher.hpp"), + ("wpi::nt::BooleanEntry", "wpi__nt__BooleanEntry.hpp"), + ("wpi::nt::BooleanTopic", "wpi__nt__BooleanTopic.hpp"), + ], + ), + struct( + class_name = "DoubleArrayTopic", + yml_file = "semiwrap/DoubleArrayTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/DoubleArrayTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::DoubleArraySubscriber", "wpi__nt__DoubleArraySubscriber.hpp"), + ("wpi::nt::DoubleArrayPublisher", "wpi__nt__DoubleArrayPublisher.hpp"), + ("wpi::nt::DoubleArrayEntry", "wpi__nt__DoubleArrayEntry.hpp"), + ("wpi::nt::DoubleArrayTopic", "wpi__nt__DoubleArrayTopic.hpp"), + ], + ), + struct( + class_name = "DoubleTopic", + yml_file = "semiwrap/DoubleTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/DoubleTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::DoubleSubscriber", "wpi__nt__DoubleSubscriber.hpp"), + ("wpi::nt::DoublePublisher", "wpi__nt__DoublePublisher.hpp"), + ("wpi::nt::DoubleEntry", "wpi__nt__DoubleEntry.hpp"), + ("wpi::nt::DoubleTopic", "wpi__nt__DoubleTopic.hpp"), + ], + ), + struct( + class_name = "FloatArrayTopic", + yml_file = "semiwrap/FloatArrayTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/FloatArrayTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::FloatArraySubscriber", "wpi__nt__FloatArraySubscriber.hpp"), + ("wpi::nt::FloatArrayPublisher", "wpi__nt__FloatArrayPublisher.hpp"), + ("wpi::nt::FloatArrayEntry", "wpi__nt__FloatArrayEntry.hpp"), + ("wpi::nt::FloatArrayTopic", "wpi__nt__FloatArrayTopic.hpp"), + ], + ), + struct( + class_name = "FloatTopic", + yml_file = "semiwrap/FloatTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/FloatTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::FloatSubscriber", "wpi__nt__FloatSubscriber.hpp"), + ("wpi::nt::FloatPublisher", "wpi__nt__FloatPublisher.hpp"), + ("wpi::nt::FloatEntry", "wpi__nt__FloatEntry.hpp"), + ("wpi::nt::FloatTopic", "wpi__nt__FloatTopic.hpp"), + ], + ), + struct( + class_name = "GenericEntry", + yml_file = "semiwrap/GenericEntry.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/GenericEntry.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::GenericSubscriber", "wpi__nt__GenericSubscriber.hpp"), + ("wpi::nt::GenericPublisher", "wpi__nt__GenericPublisher.hpp"), + ("wpi::nt::GenericEntry", "wpi__nt__GenericEntry.hpp"), + ], + ), + struct( + class_name = "IntegerArrayTopic", + yml_file = "semiwrap/IntegerArrayTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/IntegerArrayTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::IntegerArraySubscriber", "wpi__nt__IntegerArraySubscriber.hpp"), + ("wpi::nt::IntegerArrayPublisher", "wpi__nt__IntegerArrayPublisher.hpp"), + ("wpi::nt::IntegerArrayEntry", "wpi__nt__IntegerArrayEntry.hpp"), + ("wpi::nt::IntegerArrayTopic", "wpi__nt__IntegerArrayTopic.hpp"), + ], + ), + struct( + class_name = "IntegerTopic", + yml_file = "semiwrap/IntegerTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/IntegerTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::IntegerSubscriber", "wpi__nt__IntegerSubscriber.hpp"), + ("wpi::nt::IntegerPublisher", "wpi__nt__IntegerPublisher.hpp"), + ("wpi::nt::IntegerEntry", "wpi__nt__IntegerEntry.hpp"), + ("wpi::nt::IntegerTopic", "wpi__nt__IntegerTopic.hpp"), + ], + ), + struct( + class_name = "MultiSubscriber", + yml_file = "semiwrap/MultiSubscriber.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/MultiSubscriber.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::MultiSubscriber", "wpi__nt__MultiSubscriber.hpp"), + ], + ), + struct( + class_name = "NTSendable", + yml_file = "semiwrap/NTSendable.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NTSendable.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::NTSendable", "wpi__nt__NTSendable.hpp"), + ], + ), + struct( + class_name = "NTSendableBuilder", + yml_file = "semiwrap/NTSendableBuilder.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NTSendableBuilder.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::NTSendableBuilder", "wpi__nt__NTSendableBuilder.hpp"), + ], + ), + struct( + class_name = "NetworkTable", + yml_file = "semiwrap/NetworkTable.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NetworkTable.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::NetworkTable", "wpi__nt__NetworkTable.hpp"), + ], + ), + struct( + class_name = "NetworkTableEntry", + yml_file = "semiwrap/NetworkTableEntry.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NetworkTableEntry.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::NetworkTableEntry", "wpi__nt__NetworkTableEntry.hpp"), + ], + ), + struct( + class_name = "NetworkTableInstance", + yml_file = "semiwrap/NetworkTableInstance.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NetworkTableInstance.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::NetworkTableInstance", "wpi__nt__NetworkTableInstance.hpp"), + ], + ), + struct( + class_name = "NetworkTableListener", + yml_file = "semiwrap/NetworkTableListener.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NetworkTableListener.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::NetworkTableListener", "wpi__nt__NetworkTableListener.hpp"), + ("wpi::nt::NetworkTableListenerPoller", "wpi__nt__NetworkTableListenerPoller.hpp"), + ], + ), + struct( + class_name = "NetworkTableType", + yml_file = "semiwrap/NetworkTableType.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NetworkTableType.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "NetworkTableValue", + yml_file = "semiwrap/NetworkTableValue.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/NetworkTableValue.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::Value", "wpi__nt__Value.hpp"), + ], + ), + struct( + class_name = "RawTopic", + yml_file = "semiwrap/RawTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/RawTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::RawSubscriber", "wpi__nt__RawSubscriber.hpp"), + ("wpi::nt::RawPublisher", "wpi__nt__RawPublisher.hpp"), + ("wpi::nt::RawEntry", "wpi__nt__RawEntry.hpp"), + ("wpi::nt::RawTopic", "wpi__nt__RawTopic.hpp"), + ], + ), + struct( + class_name = "StructTopic", + yml_file = "semiwrap/StructTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/StructTopic.hpp", + tmpl_class_names = [ + ("StructTopic_tmpl1", "StructSubscriber"), + ("StructTopic_tmpl2", "StructPublisher"), + ("StructTopic_tmpl3", "StructEntry"), + ("StructTopic_tmpl4", "StructTopic"), + ], + trampolines = [ + ("wpi::nt::StructSubscriber", "wpi__nt__StructSubscriber.hpp"), + ("wpi::nt::StructPublisher", "wpi__nt__StructPublisher.hpp"), + ("wpi::nt::StructEntry", "wpi__nt__StructEntry.hpp"), + ("wpi::nt::StructTopic", "wpi__nt__StructTopic.hpp"), + ], + ), + struct( + class_name = "StructArrayTopic", + yml_file = "semiwrap/StructArrayTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/StructArrayTopic.hpp", + tmpl_class_names = [ + ("StructArrayTopic_tmpl1", "StructArraySubscriber"), + ("StructArrayTopic_tmpl2", "StructArrayPublisher"), + ("StructArrayTopic_tmpl3", "StructArrayEntry"), + ("StructArrayTopic_tmpl4", "StructArrayTopic"), + ], + trampolines = [ + ("wpi::nt::StructArraySubscriber", "wpi__nt__StructArraySubscriber.hpp"), + ("wpi::nt::StructArrayPublisher", "wpi__nt__StructArrayPublisher.hpp"), + ("wpi::nt::StructArrayEntry", "wpi__nt__StructArrayEntry.hpp"), + ("wpi::nt::StructArrayTopic", "wpi__nt__StructArrayTopic.hpp"), + ], + ), + struct( + class_name = "StringArrayTopic", + yml_file = "semiwrap/StringArrayTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/StringArrayTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::StringArraySubscriber", "wpi__nt__StringArraySubscriber.hpp"), + ("wpi::nt::StringArrayPublisher", "wpi__nt__StringArrayPublisher.hpp"), + ("wpi::nt::StringArrayEntry", "wpi__nt__StringArrayEntry.hpp"), + ("wpi::nt::StringArrayTopic", "wpi__nt__StringArrayTopic.hpp"), + ], + ), + struct( + class_name = "StringTopic", + yml_file = "semiwrap/StringTopic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/StringTopic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::StringSubscriber", "wpi__nt__StringSubscriber.hpp"), + ("wpi::nt::StringPublisher", "wpi__nt__StringPublisher.hpp"), + ("wpi::nt::StringEntry", "wpi__nt__StringEntry.hpp"), + ("wpi::nt::StringTopic", "wpi__nt__StringTopic.hpp"), + ], + ), + struct( + class_name = "Topic", + yml_file = "semiwrap/Topic.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/Topic.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::Topic", "wpi__nt__Topic.hpp"), + ("wpi::nt::Subscriber", "wpi__nt__Subscriber.hpp"), + ("wpi::nt::Publisher", "wpi__nt__Publisher.hpp"), + ], + ), + struct( + class_name = "ntcore_cpp", + yml_file = "semiwrap/ntcore_cpp.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/ntcore_cpp.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::nt::EventFlags", "wpi__nt__EventFlags.hpp"), + ("wpi::nt::TopicInfo", "wpi__nt__TopicInfo.hpp"), + ("wpi::nt::ConnectionInfo", "wpi__nt__ConnectionInfo.hpp"), + ("wpi::nt::ValueEventData", "wpi__nt__ValueEventData.hpp"), + ("wpi::nt::LogMessage", "wpi__nt__LogMessage.hpp"), + ("wpi::nt::TimeSyncEventData", "wpi__nt__TimeSyncEventData.hpp"), + ("wpi::nt::Event", "wpi__nt__Event.hpp"), + ("wpi::nt::PubSubOptions", "wpi__nt__PubSubOptions.hpp"), + ("wpi::nt::meta::SubscriberOptions", "wpi__nt__meta__SubscriberOptions.hpp"), + ("wpi::nt::meta::TopicPublisher", "wpi__nt__meta__TopicPublisher.hpp"), + ("wpi::nt::meta::TopicSubscriber", "wpi__nt__meta__TopicSubscriber.hpp"), + ("wpi::nt::meta::ClientPublisher", "wpi__nt__meta__ClientPublisher.hpp"), + ("wpi::nt::meta::ClientSubscriber", "wpi__nt__meta__ClientSubscriber.hpp"), + ("wpi::nt::meta::Client", "wpi__nt__meta__Client.hpp"), + ], + ), + struct( + class_name = "ntcore_cpp_types", + yml_file = "semiwrap/ntcore_cpp_types.yml", + header_root = "$(execpath :robotpy-native-ntcore.copy_headers)", + header_file = "$(execpath :robotpy-native-ntcore.copy_headers)/wpi/nt/ntcore_cpp_types.hpp", + tmpl_class_names = [ + ("ntcore_cpp_types_tmpl1", "TimestampedBoolean"), + ("ntcore_cpp_types_tmpl2", "TimestampedInteger"), + ("ntcore_cpp_types_tmpl3", "TimestampedFloat"), + ("ntcore_cpp_types_tmpl4", "TimestampedDouble"), + ("ntcore_cpp_types_tmpl5", "TimestampedString"), + ("ntcore_cpp_types_tmpl6", "TimestampedRaw"), + ("ntcore_cpp_types_tmpl7", "TimestampedBooleanArray"), + ("ntcore_cpp_types_tmpl8", "TimestampedIntegerArray"), + ("ntcore_cpp_types_tmpl9", "TimestampedFloatArray"), + ("ntcore_cpp_types_tmpl10", "TimestampedDoubleArray"), + ("ntcore_cpp_types_tmpl11", "TimestampedStringArray"), + ("ntcore_cpp_types_tmpl12", "TimestampedStruct"), + ("ntcore_cpp_types_tmpl13", "TimestampedStructArray"), + ], + trampolines = [ + ("wpi::nt::Timestamped", "wpi__nt__Timestamped.hpp"), + ], + ), + ] + + resolve_casters( + name = "ntcore.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "ntcore.casters.pkl", + dep_file = "ntcore.casters.d", + ) + + gen_libinit( + name = "ntcore.gen_lib_init", + output_file = "src/main/python/ntcore/_init__ntcore.py", + modules = ["native.ntcore._init_robotpy_native_ntcore", "wpiutil._init__wpiutil", "wpinet._init__wpinet", "wpilog._init__wpilog"], + ) + + gen_pkgconf( + name = "ntcore.gen_pkgconf", + libinit_py = "ntcore._init__ntcore", + module_pkg_name = "ntcore._ntcore", + output_file = "ntcore.pc", + pkg_name = "ntcore", + install_path = "src/main/python/ntcore", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/ntcore/__init__.py", + ) + + gen_modinit_hpp( + name = "ntcore.gen_modinit_hpp", + input_dats = [x.class_name for x in NTCORE_HEADER_GEN], + libname = "_ntcore", + output_file = "semiwrap_init.ntcore._ntcore.hpp", + ) + + run_header_gen( + name = "ntcore", + casters_pickle = "ntcore.casters.pkl", + header_gen_config = NTCORE_HEADER_GEN, + trampoline_subpath = "src/main/python/ntcore", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "ntcore", + install_path = "src/main/python/ntcore/", + extension_name = "_ntcore", + generated_srcs = [":ntcore.generated_srcs"], + semiwrap_header = [":ntcore.gen_modinit_hpp"], + deps = [ + ":ntcore.tmpl_hdrs", + ":ntcore.trampoline_hdrs", + "//datalog:datalog", + "//datalog:wpilog_pybind_library", + "//ntcore:ntcore", + "//wpinet:wpinet", + "//wpinet:wpinet_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//datalog:shared/datalog", + "//ntcore:shared/ntcore", + "//wpinet:shared/wpinet", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "ntcore.generated_files", + srcs = [ + "ntcore.gen_modinit_hpp.gen", + "ntcore.header_gen_files", + "ntcore.gen_pkgconf", + "ntcore.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "ntcore.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/ntcore/ntcore.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/ntcore/**"], exclude = ["src/main/python/ntcore/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/ntcore/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/ntcore/**/*.py"]) + [ + "src/main/python/ntcore/_init__ntcore.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/ntcore/_ntcore", + ":ntcore.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//datalog:robotpy-wpilog", + "//ntcore:robotpy-native-ntcore", + "//wpinet:robotpy-wpinet", + "//wpiutil:robotpy-wpiutil", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//datalog:robotpy-native-datalog.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + package_root_file = "src/main/python/ntcore/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//ntcore:robotpy-native-ntcore.copy_headers", + ], + package_root_file = "src/main/python/ntcore/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + ) diff --git a/romiVendordep/BUILD.bazel b/romiVendordep/BUILD.bazel index 5692046935..c7c31ffbcc 100644 --- a/romiVendordep/BUILD.bazel +++ b/romiVendordep/BUILD.bazel @@ -1,8 +1,13 @@ +load("@allwpilib_pip_deps//:requirements.bzl", "requirement") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test") load("@rules_java//java:defs.bzl", "java_binary") +load("//romiVendordep:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//romiVendordep:robotpy_pybind_build_info.bzl", "define_pybind_library", "romi_extension") load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library") load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_library") load("//shared/bazel/rules:packaging.bzl", "package_minimal_cc_project") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") filegroup( name = "doxygen-files", @@ -101,3 +106,57 @@ package_minimal_cc_project( maven_artifact_name = "romiVendordep-cpp", maven_group_id = "org.wpilib.romiVendordep", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-xrp-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +define_native_wrapper( + name = "robotpy-native-romi", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +PKG_CONFIG_DEPS = [ + "//datalog:native/datalog/robotpy-native-datalog.pc", + "//datalog:robotpy-wpilog.generated_pkgcfg_files", + "//hal:native/wpihal/robotpy-native-wpihal.pc", + "//hal:robotpy-hal.generated_pkgcfg_files", + "//ntcore:native/ntcore/robotpy-native-ntcore.pc", + "//ntcore:pyntcore.generated_pkgcfg_files", + "//wpilibc:native/wpilib/robotpy-native-wpilib.pc", + "//wpilibc:robotpy-wpilib.generated_pkgcfg_files", + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpimath:robotpy-wpimath.generated_pkgcfg_files", + "//wpinet:native/wpinet/robotpy-native-wpinet.pc", + "//wpinet:robotpy-wpinet.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", + "//romiVendordep:native/romi/robotpy-native-romi.pc", +] + +generate_robotpy_pybind_build_info( + name = "robotpy-romi-generator", + additional_srcs = [":robotpy-native-romi.copy_headers"], + package_root_file = "src/main/python/romi/__init__.py", + pkgcfgs = PKG_CONFIG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/**/*.yml"]), +) + +romi_extension( + srcs = ["src/main/python/romi/src/main.cpp"], +) + +define_pybind_library( + name = "robotpy-romi", + pkgcfgs = PKG_CONFIG_DEPS, +) + +robotpy_py_test( + "python_tests", + srcs = glob(["src/test/python/**/*.py"]), + deps = [ + ":robotpy-romi", + requirement("pytest"), + ], +) diff --git a/romiVendordep/robotpy_native_build_info.bzl b/romiVendordep/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..65380d0345 --- /dev/null +++ b/romiVendordep/robotpy_native_build_info.bzl @@ -0,0 +1,34 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True), + out = "native/romi/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "romiVendordep/src/generated/main/native/include": "", + "romiVendordep/src/main/native/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/romi/_init_robotpy_native_romi.py", + pc_file = "native/romi/robotpy-native-romi.pc", + pc_deps = [ + "//wpilibc:native/wpilib/robotpy-native-wpilib.pc", + ], + deps = [ + "//wpilibc:robotpy-native-wpilib", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/romiVendordep", + install_path = "native/romi/", + ) diff --git a/romiVendordep/robotpy_pybind_build_info.bzl b/romiVendordep/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..6521194588 --- /dev/null +++ b/romiVendordep/robotpy_pybind_build_info.bzl @@ -0,0 +1,208 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def romi_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + ROMI_HEADER_GEN = [ + struct( + class_name = "OnBoardIO", + yml_file = "semiwrap/OnBoardIO.yml", + header_root = "$(execpath :robotpy-native-romi.copy_headers)", + header_file = "$(execpath :robotpy-native-romi.copy_headers)/wpi/romi/OnBoardIO.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::romi::OnBoardIO", "wpi__romi__OnBoardIO.hpp"), + ], + ), + struct( + class_name = "RomiGyro", + yml_file = "semiwrap/RomiGyro.yml", + header_root = "$(execpath :robotpy-native-romi.copy_headers)", + header_file = "$(execpath :robotpy-native-romi.copy_headers)/wpi/romi/RomiGyro.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::romi::RomiGyro", "wpi__romi__RomiGyro.hpp"), + ], + ), + struct( + class_name = "RomiMotor", + yml_file = "semiwrap/RomiMotor.yml", + header_root = "$(execpath :robotpy-native-romi.copy_headers)", + header_file = "$(execpath :robotpy-native-romi.copy_headers)/wpi/romi/RomiMotor.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::romi::RomiMotor", "wpi__romi__RomiMotor.hpp"), + ], + ), + ] + + resolve_casters( + name = "romi.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "romi.casters.pkl", + dep_file = "romi.casters.d", + ) + + gen_libinit( + name = "romi.gen_lib_init", + output_file = "src/main/python/romi/_init__romi.py", + modules = ["native.romi._init_robotpy_native_romi", "wpilib._init__wpilib", "wpimath.geometry._init__geometry"], + ) + + gen_pkgconf( + name = "romi.gen_pkgconf", + libinit_py = "romi._init__romi", + module_pkg_name = "romi._romi", + output_file = "romi.pc", + pkg_name = "romi", + install_path = "src/main/python/romi", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/romi/__init__.py", + ) + + gen_modinit_hpp( + name = "romi.gen_modinit_hpp", + input_dats = [x.class_name for x in ROMI_HEADER_GEN], + libname = "_romi", + output_file = "semiwrap_init.romi._romi.hpp", + ) + + run_header_gen( + name = "romi", + casters_pickle = "romi.casters.pkl", + header_gen_config = ROMI_HEADER_GEN, + trampoline_subpath = "src/main/python/romi", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//romiVendordep:robotpy-native-romi.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "romi", + install_path = "src/main/python/romi/", + extension_name = "_romi", + generated_srcs = [":romi.generated_srcs"], + semiwrap_header = [":romi.gen_modinit_hpp"], + deps = [ + ":romi.tmpl_hdrs", + ":romi.trampoline_hdrs", + "//romiVendordep:romiVendordep", + "//wpilibc:wpilib_pybind_library", + "//wpilibc:wpilibc", + "//wpimath:wpimath", + "//wpimath:wpimath_geometry_pybind_library", + ], + dynamic_deps = [ + "//romiVendordep:shared/romiVendordep", + "//wpilibc:shared/wpilibc", + "//wpimath:shared/wpimath", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "romi.generated_files", + srcs = [ + "romi.gen_modinit_hpp.gen", + "romi.header_gen_files", + "romi.gen_pkgconf", + "romi.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "romi.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/romi/romi.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/romi/**"], exclude = ["src/main/python/romi/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/romi/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/romi/**/*.py"]) + [ + "src/main/python/romi/_init__romi.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/romi/_romi", + ":romi.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//romiVendordep:robotpy-native-romi", + "//wpilibc:robotpy-wpilib", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//romiVendordep:robotpy-native-romi.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + package_root_file = "src/main/python/romi/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//romiVendordep:robotpy-native-romi.copy_headers", + ], + package_root_file = "src/main/python/romi/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + ) diff --git a/shared/bazel/rules/robotpy/BUILD.bazel b/shared/bazel/rules/robotpy/BUILD.bazel index fceab14eff..a4646c3918 100644 --- a/shared/bazel/rules/robotpy/BUILD.bazel +++ b/shared/bazel/rules/robotpy/BUILD.bazel @@ -3,7 +3,10 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_python//python:defs.bzl", "py_binary", "py_library") load("@rules_python//python:pip.bzl", "whl_filegroup") -exports_files(["wrapper.py"]) +exports_files([ + "wrapper.py", + "version_template.in", +]) py_library( name = "hack_pkgcfgs", diff --git a/shared/bazel/rules/robotpy/generate_pybind_build_file.py b/shared/bazel/rules/robotpy/generate_pybind_build_file.py index b56a682d40..a6bb12e125 100644 --- a/shared/bazel/rules/robotpy/generate_pybind_build_file.py +++ b/shared/bazel/rules/robotpy/generate_pybind_build_file.py @@ -384,6 +384,18 @@ def generate_pybind_build_file( env.filters["jsonify"] = jsonify template = env.from_string(template_contents) + all_local_native_deps = set() + for em in extension_modules: + all_local_native_deps.update(em.native_wrapper_dependencies) + all_local_native_deps = sorted(all_local_native_deps) + + try: + version_file = raw_config["tool"]["hatch"]["build"]["hooks"]["robotpy"][ + "version_file" + ] + except: + version_file = None + with open(output_file, "w") as f: f.write( template.render( @@ -391,11 +403,13 @@ def generate_pybind_build_file( top_level_name=top_level_name, publish_casters_targets=publish_casters_targets, python_deps=sorted(python_deps), + all_local_native_deps=all_local_native_deps, stripped_include_prefix=stripped_include_prefix, yml_prefix=yml_prefix, package_root_file=package_root_file, raw_project_config=raw_config["project"], entry_points=entry_points, + version_file=version_file, ) + "\n" ) diff --git a/shared/bazel/rules/robotpy/pybind_build_file_template.jinja2 b/shared/bazel/rules/robotpy/pybind_build_file_template.jinja2 index 9edeaf7137..7d90d1e86d 100644 --- a/shared/bazel/rules/robotpy/pybind_build_file_template.jinja2 +++ b/shared/bazel/rules/robotpy/pybind_build_file_template.jinja2 @@ -2,6 +2,9 @@ {% if publish_casters_targets %} load("@rules_cc//cc:cc_library.bzl", "cc_library") {%- endif %} +{%- if version_file %} +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +{%- endif %} load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", {% if publish_casters_targets %}"publish_casters", {% endif %}"resolve_casters", "run_header_gen") load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") @@ -178,13 +181,22 @@ def define_pybind_library(name, pkgcfgs = []): srcs = native.glob(["{{stripped_include_prefix}}/{{top_level_name}}/**"], exclude = ["{{stripped_include_prefix}}/{{top_level_name}}/**/*.py"], allow_empty = True), tags = ["manual", "robotpy"], ) - +{% if version_file %} + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "{{stripped_include_prefix}}/{{version_file}}", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) +{% endif %} robotpy_library( name = name, srcs = native.glob(["{{stripped_include_prefix}}/{{top_level_name}}/**/*.py"]) + [ {%- for em in extension_modules %} "{{stripped_include_prefix}}/{{ em.gen_pkgconf.libinit_py.replace(".", "/") }}.py", {%- endfor %} + {%- if version_file %} + "{}.generate_version".format(name), + {%- endif %} ], data = [ "{}.generated_pkgcfg_files".format(name), @@ -209,11 +221,9 @@ def define_pybind_library(name, pkgcfgs = []): name = "{}-update-yaml".format(name), yaml_output_directory = "{{ stripped_include_prefix }}/semiwrap", extra_hdrs = native.glob(["{{stripped_include_prefix}}/**/*.h"], allow_empty = True) + [ -{%- if python_deps %} - {% for d in python_deps %} - {%- if "native" in d %}"{{d}}.copy_headers",{%- endif %} - {%- endfor %} -{%- endif %} +{%- for d in all_local_native_deps %} + "{{d}}", +{%- endfor %} ], package_root_file = "{{package_root_file}}", pkgcfgs = pkgcfgs, diff --git a/shared/bazel/rules/robotpy/semiwrap_tool_helpers.bzl b/shared/bazel/rules/robotpy/semiwrap_tool_helpers.bzl index fb4840dd18..2c947e1e25 100644 --- a/shared/bazel/rules/robotpy/semiwrap_tool_helpers.bzl +++ b/shared/bazel/rules/robotpy/semiwrap_tool_helpers.bzl @@ -84,9 +84,11 @@ def scan_headers(name, pyproject_toml, package_root_file, extra_hdrs, pkgcfgs): "semiwrap.tool", "scan-headers", "--pyproject=$(location " + pyproject_toml + ")", + "--check", ] + pkgcfg_args, data = extra_hdrs + pkgcfgs + [pyproject_toml, package_root_file], main = "shared/bazel/rules/robotpy/wrapper.py", size = "small", target_compatible_with = robotpy_compatibility_select(), + tags = ["robotpy_scan_headers"], ) diff --git a/shared/bazel/rules/robotpy/version_template.in b/shared/bazel/rules/robotpy/version_template.in new file mode 100644 index 0000000000..828971e274 --- /dev/null +++ b/shared/bazel/rules/robotpy/version_template.in @@ -0,0 +1,3 @@ +# This file is automatically generated, DO NOT EDIT + +version = __version__ = "${wpilib_version}" diff --git a/wpilibc/BUILD.bazel b/wpilibc/BUILD.bazel index c8a8da971c..e06c2f94d4 100644 --- a/wpilibc/BUILD.bazel +++ b/wpilibc/BUILD.bazel @@ -6,7 +6,11 @@ load("@rules_python//python:defs.bzl", "py_binary") load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library") load("//shared/bazel/rules:packaging.bzl", "package_minimal_cc_project") load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") load("//wpilibc:generate.bzl", "generate_wpilibc") +load("//wpilibc:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//wpilibc:robotpy_pybind_build_info.bzl", "define_pybind_library", "wpilib_counter_extension", "wpilib_drive_extension", "wpilib_event_extension", "wpilib_extension", "wpilib_simulation_extension") filegroup( name = "doxygen-files", @@ -199,3 +203,96 @@ package_minimal_cc_project( maven_artifact_name = "wpilibc-cpp", maven_group_id = "org.wpilib.wpilibc", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-wpilib-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +define_native_wrapper( + name = "robotpy-native-wpilib", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +PKG_CONFIG_DEPS = [ + "//datalog:native/datalog/robotpy-native-datalog.pc", + "//datalog:robotpy-wpilog.generated_pkgcfg_files", + "//hal:native/wpihal/robotpy-native-wpihal.pc", + "//hal:robotpy-hal.generated_pkgcfg_files", + "//ntcore:native/ntcore/robotpy-native-ntcore.pc", + "//ntcore:pyntcore.generated_pkgcfg_files", + "//wpilibc:native/wpilib/robotpy-native-wpilib.pc", + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpimath:robotpy-wpimath.generated_pkgcfg_files", + "//wpinet:native/wpinet/robotpy-native-wpinet.pc", + "//wpinet:robotpy-wpinet.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", +] + +generate_robotpy_pybind_build_info( + name = "robotpy-wpilib-generator", + additional_srcs = [ + "src/main/python/wpilib/src/rpy/Filesystem.h", + "src/main/python/wpilib/src/rpy/Notifier.h", + "src/main/python/wpilib/src/rpy/MotorControllerGroup.h", + ] + [":robotpy-native-wpilib.copy_headers"], + package_root_file = "src/main/python/wpilib/__init__.py", + pkgcfgs = PKG_CONFIG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/**/*.yml"]), +) + +wpilib_event_extension( + srcs = ["src/main/python/wpilib/event/event.cpp"], +) + +wpilib_extension( + srcs = glob(["src/main/python/wpilib/src/**/*.cpp"]), + extra_hdrs = glob([ + "src/main/python/wpilib/src/rpy/*.h", + "src/main/python/wpilib/src/rpy/*.inc", + ]), + header_to_dat_deps = glob(["src/main/python/wpilib/src/**"]), + includes = [ + "src/main/python/wpilib", + "src/main/python/wpilib/src", + ], +) + +wpilib_counter_extension( + srcs = ["src/main/python/wpilib/counter/counter.cpp"], + header_to_dat_deps = glob([ + "src/main/python/wpilib/src/rpy/*.h", + "src/main/python/wpilib/src/rpy/*.inc", + ]), +) + +wpilib_drive_extension( + srcs = ["src/main/python/wpilib/drive/drive.cpp"], + header_to_dat_deps = glob([ + "src/main/python/wpilib/src/rpy/*.h", + "src/main/python/wpilib/src/rpy/*.inc", + ]), +) + +wpilib_simulation_extension( + srcs = ["src/main/python/wpilib/simulation/simulation.cpp"], + header_to_dat_deps = glob([ + "src/main/python/wpilib/src/rpy/*.h", + "src/main/python/wpilib/src/rpy/*.inc", + ]), +) + +define_pybind_library( + name = "robotpy-wpilib", + pkgcfgs = PKG_CONFIG_DEPS, +) + +robotpy_py_test( + "python_tests", + srcs = glob(["src/test/python/**/*.py"]), + deps = [ + ":robotpy-wpilib", + requirement("pytest"), + ], +) diff --git a/wpilibc/robotpy_native_build_info.bzl b/wpilibc/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..f593188d18 --- /dev/null +++ b/wpilibc/robotpy_native_build_info.bzl @@ -0,0 +1,42 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True), + out = "native/wpilib/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "wpilibc/src/generated/main/native/include": "", + "wpilibc/src/main/native/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/wpilib/_init_robotpy_native_wpilib.py", + pc_file = "native/wpilib/robotpy-native-wpilib.pc", + pc_deps = [ + "//ntcore:native/ntcore/robotpy-native-ntcore.pc", + "//hal:native/wpihal/robotpy-native-wpihal.pc", + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpinet:native/wpinet/robotpy-native-wpinet.pc", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + ], + deps = [ + "//ntcore:robotpy-native-ntcore", + "//hal:robotpy-native-wpihal", + "//wpimath:robotpy-native-wpimath", + "//wpinet:robotpy-native-wpinet", + "//wpiutil:robotpy-native-wpiutil", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/wpilibc", + install_path = "native/wpilib/", + ) diff --git a/wpilibc/robotpy_pybind_build_info.bzl b/wpilibc/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..f8d3ccb673 --- /dev/null +++ b/wpilibc/robotpy_pybind_build_info.bzl @@ -0,0 +1,1974 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def wpilib_event_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPILIB_EVENT_HEADER_GEN = [ + struct( + class_name = "BooleanEvent", + yml_file = "semiwrap/event/BooleanEvent.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/event/BooleanEvent.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::BooleanEvent", "wpi__BooleanEvent.hpp"), + ], + ), + struct( + class_name = "EventLoop", + yml_file = "semiwrap/event/EventLoop.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/event/EventLoop.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::EventLoop", "wpi__EventLoop.hpp"), + ], + ), + struct( + class_name = "NetworkBooleanEvent", + yml_file = "semiwrap/event/NetworkBooleanEvent.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/event/NetworkBooleanEvent.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::NetworkBooleanEvent", "wpi__NetworkBooleanEvent.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpilib_event.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpilib_event.casters.pkl", + dep_file = "wpilib_event.casters.d", + ) + + gen_libinit( + name = "wpilib_event.gen_lib_init", + output_file = "src/main/python/wpilib/event/_init__event.py", + modules = ["native.wpilib._init_robotpy_native_wpilib", "wpimath.filter._init__filter"], + ) + + gen_pkgconf( + name = "wpilib_event.gen_pkgconf", + libinit_py = "wpilib.event._init__event", + module_pkg_name = "wpilib.event._event", + output_file = "wpilib_event.pc", + pkg_name = "wpilib_event", + install_path = "src/main/python/wpilib/event", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpilib/__init__.py", + ) + + gen_modinit_hpp( + name = "wpilib_event.gen_modinit_hpp", + input_dats = [x.class_name for x in WPILIB_EVENT_HEADER_GEN], + libname = "_event", + output_file = "semiwrap_init.wpilib.event._event.hpp", + ) + + run_header_gen( + name = "wpilib_event", + casters_pickle = "wpilib_event.casters.pkl", + header_gen_config = WPILIB_EVENT_HEADER_GEN, + trampoline_subpath = "src/main/python/wpilib/event", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpilib_event", + install_path = "src/main/python/wpilib/event/", + extension_name = "_event", + generated_srcs = [":wpilib_event.generated_srcs"], + semiwrap_header = [":wpilib_event.gen_modinit_hpp"], + deps = [ + ":wpilib_event.tmpl_hdrs", + ":wpilib_event.trampoline_hdrs", + "//wpilibc:wpilibc", + "//wpimath:wpimath", + "//wpimath:wpimath_filter_pybind_library", + ], + dynamic_deps = [ + "//wpilibc:shared/wpilibc", + "//wpimath:shared/wpimath", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpilib_event.generated_files", + srcs = [ + "wpilib_event.gen_modinit_hpp.gen", + "wpilib_event.header_gen_files", + "wpilib_event.gen_pkgconf", + "wpilib_event.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpilib_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPILIB_HEADER_GEN = [ + struct( + class_name = "Filesystem", + yml_file = "semiwrap/Filesystem.yml", + header_root = "wpilibc/src/main/python/wpilib/src", + header_file = "wpilibc/src/main/python/wpilib/src/rpy/Filesystem.h", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "MotorControllerGroup", + yml_file = "semiwrap/MotorControllerGroup.yml", + header_root = "wpilibc/src/main/python/wpilib/src", + header_file = "wpilibc/src/main/python/wpilib/src/rpy/MotorControllerGroup.h", + tmpl_class_names = [], + trampolines = [ + ("wpi::PyMotorControllerGroup", "wpi__PyMotorControllerGroup.hpp"), + ], + ), + struct( + class_name = "Notifier", + yml_file = "semiwrap/Notifier.yml", + header_root = "wpilibc/src/main/python/wpilib/src", + header_file = "wpilibc/src/main/python/wpilib/src/rpy/Notifier.h", + tmpl_class_names = [], + trampolines = [ + ("wpi::PyNotifier", "wpi__PyNotifier.hpp"), + ], + ), + struct( + class_name = "ExpansionHub", + yml_file = "semiwrap/ExpansionHub.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/ExpansionHub.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::ExpansionHub", "wpi__ExpansionHub.hpp"), + ], + ), + struct( + class_name = "ExpansionHubMotor", + yml_file = "semiwrap/ExpansionHubMotor.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/ExpansionHubMotor.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::ExpansionHubMotor", "wpi__ExpansionHubMotor.hpp"), + ], + ), + struct( + class_name = "ExpansionHubPidConstants", + yml_file = "semiwrap/ExpansionHubPidConstants.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/ExpansionHubPidConstants.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::ExpansionHubPidConstants", "wpi__ExpansionHubPidConstants.hpp"), + ], + ), + struct( + class_name = "ExpansionHubServo", + yml_file = "semiwrap/ExpansionHubServo.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/ExpansionHubServo.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::ExpansionHubServo", "wpi__ExpansionHubServo.hpp"), + ], + ), + struct( + class_name = "DSControlWord", + yml_file = "semiwrap/DSControlWord.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/DSControlWord.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DSControlWord", "wpi__DSControlWord.hpp"), + ], + ), + struct( + class_name = "DriverStation", + yml_file = "semiwrap/DriverStation.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/DriverStation.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DriverStation", "wpi__DriverStation.hpp"), + ], + ), + struct( + class_name = "Gamepad", + yml_file = "semiwrap/Gamepad.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/Gamepad.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Gamepad", "wpi__Gamepad.hpp"), + ("wpi::Gamepad::Button", "wpi__Gamepad__Button.hpp"), + ("wpi::Gamepad::Axis", "wpi__Gamepad__Axis.hpp"), + ], + ), + struct( + class_name = "GenericHID", + yml_file = "semiwrap/GenericHID.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/GenericHID.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::GenericHID", "wpi__GenericHID.hpp"), + ], + ), + struct( + class_name = "Joystick", + yml_file = "semiwrap/Joystick.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/Joystick.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Joystick", "wpi__Joystick.hpp"), + ], + ), + struct( + class_name = "PS4Controller", + yml_file = "semiwrap/PS4Controller.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/PS4Controller.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PS4Controller", "wpi__PS4Controller.hpp"), + ("wpi::PS4Controller::Button", "wpi__PS4Controller__Button.hpp"), + ("wpi::PS4Controller::Axis", "wpi__PS4Controller__Axis.hpp"), + ], + ), + struct( + class_name = "PS5Controller", + yml_file = "semiwrap/PS5Controller.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/PS5Controller.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PS5Controller", "wpi__PS5Controller.hpp"), + ("wpi::PS5Controller::Button", "wpi__PS5Controller__Button.hpp"), + ("wpi::PS5Controller::Axis", "wpi__PS5Controller__Axis.hpp"), + ], + ), + struct( + class_name = "StadiaController", + yml_file = "semiwrap/StadiaController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/StadiaController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::StadiaController", "wpi__StadiaController.hpp"), + ("wpi::StadiaController::Button", "wpi__StadiaController__Button.hpp"), + ("wpi::StadiaController::Axis", "wpi__StadiaController__Axis.hpp"), + ], + ), + struct( + class_name = "XboxController", + yml_file = "semiwrap/XboxController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/driverstation/XboxController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::XboxController", "wpi__XboxController.hpp"), + ("wpi::XboxController::Button", "wpi__XboxController__Button.hpp"), + ("wpi::XboxController::Axis", "wpi__XboxController__Axis.hpp"), + ], + ), + struct( + class_name = "IterativeRobotBase", + yml_file = "semiwrap/IterativeRobotBase.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/framework/IterativeRobotBase.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::IterativeRobotBase", "wpi__IterativeRobotBase.hpp"), + ], + ), + struct( + class_name = "RobotBase", + yml_file = "semiwrap/RobotBase.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/framework/RobotBase.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::RobotBase", "wpi__RobotBase.hpp"), + ], + ), + struct( + class_name = "RobotState", + yml_file = "semiwrap/RobotState.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/framework/RobotState.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::RobotState", "wpi__RobotState.hpp"), + ], + ), + struct( + class_name = "TimedRobot", + yml_file = "semiwrap/TimedRobot.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/framework/TimedRobot.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::TimedRobot", "wpi__TimedRobot.hpp"), + ], + ), + struct( + class_name = "TimesliceRobot", + yml_file = "semiwrap/TimesliceRobot.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/framework/TimesliceRobot.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::TimesliceRobot", "wpi__TimesliceRobot.hpp"), + ], + ), + struct( + class_name = "ADXL345_I2C", + yml_file = "semiwrap/ADXL345_I2C.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/accelerometer/ADXL345_I2C.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::ADXL345_I2C", "wpi__ADXL345_I2C.hpp"), + ("wpi::ADXL345_I2C::AllAxes", "wpi__ADXL345_I2C__AllAxes.hpp"), + ], + ), + struct( + class_name = "AnalogAccelerometer", + yml_file = "semiwrap/AnalogAccelerometer.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/accelerometer/AnalogAccelerometer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::AnalogAccelerometer", "wpi__AnalogAccelerometer.hpp"), + ], + ), + struct( + class_name = "CAN", + yml_file = "semiwrap/CAN.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/bus/CAN.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::CAN", "wpi__CAN.hpp"), + ], + ), + struct( + class_name = "I2C", + yml_file = "semiwrap/I2C.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/bus/I2C.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::I2C", "wpi__I2C.hpp"), + ], + ), + struct( + class_name = "SerialPort", + yml_file = "semiwrap/SerialPort.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/bus/SerialPort.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SerialPort", "wpi__SerialPort.hpp"), + ], + ), + struct( + class_name = "AnalogInput", + yml_file = "semiwrap/AnalogInput.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/discrete/AnalogInput.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::AnalogInput", "wpi__AnalogInput.hpp"), + ], + ), + struct( + class_name = "CounterBase", + yml_file = "semiwrap/CounterBase.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/discrete/CounterBase.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::CounterBase", "wpi__CounterBase.hpp"), + ], + ), + struct( + class_name = "DigitalInput", + yml_file = "semiwrap/DigitalInput.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/discrete/DigitalInput.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DigitalInput", "wpi__DigitalInput.hpp"), + ], + ), + struct( + class_name = "DigitalOutput", + yml_file = "semiwrap/DigitalOutput.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/discrete/DigitalOutput.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DigitalOutput", "wpi__DigitalOutput.hpp"), + ], + ), + struct( + class_name = "PWM", + yml_file = "semiwrap/PWM.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/discrete/PWM.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWM", "wpi__PWM.hpp"), + ], + ), + struct( + class_name = "OnboardIMU", + yml_file = "semiwrap/OnboardIMU.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/imu/OnboardIMU.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::OnboardIMU", "wpi__OnboardIMU.hpp"), + ], + ), + struct( + class_name = "AddressableLED", + yml_file = "semiwrap/AddressableLED.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/led/AddressableLED.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::AddressableLED", "wpi__AddressableLED.hpp"), + ("wpi::AddressableLED::LEDData", "wpi__AddressableLED__LEDData.hpp"), + ], + ), + struct( + class_name = "LEDPattern", + yml_file = "semiwrap/LEDPattern.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/led/LEDPattern.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::LEDPattern", "wpi__LEDPattern.hpp"), + ("wpi::LEDPattern::LEDReader", "wpi__LEDPattern__LEDReader.hpp"), + ], + ), + struct( + class_name = "Koors40", + yml_file = "semiwrap/Koors40.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/Koors40.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Koors40", "wpi__Koors40.hpp"), + ], + ), + struct( + class_name = "MotorController", + yml_file = "semiwrap/MotorController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/MotorController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::MotorController", "wpi__MotorController.hpp"), + ], + ), + struct( + class_name = "MotorSafety", + yml_file = "semiwrap/MotorSafety.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/MotorSafety.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::MotorSafety", "wpi__MotorSafety.hpp"), + ], + ), + struct( + class_name = "PWMMotorController", + yml_file = "semiwrap/PWMMotorController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/PWMMotorController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWMMotorController", "wpi__PWMMotorController.hpp"), + ], + ), + struct( + class_name = "PWMSparkFlex", + yml_file = "semiwrap/PWMSparkFlex.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/PWMSparkFlex.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWMSparkFlex", "wpi__PWMSparkFlex.hpp"), + ], + ), + struct( + class_name = "PWMSparkMax", + yml_file = "semiwrap/PWMSparkMax.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/PWMSparkMax.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWMSparkMax", "wpi__PWMSparkMax.hpp"), + ], + ), + struct( + class_name = "PWMTalonFX", + yml_file = "semiwrap/PWMTalonFX.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/PWMTalonFX.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWMTalonFX", "wpi__PWMTalonFX.hpp"), + ], + ), + struct( + class_name = "PWMTalonSRX", + yml_file = "semiwrap/PWMTalonSRX.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/PWMTalonSRX.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWMTalonSRX", "wpi__PWMTalonSRX.hpp"), + ], + ), + struct( + class_name = "PWMVenom", + yml_file = "semiwrap/PWMVenom.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/PWMVenom.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWMVenom", "wpi__PWMVenom.hpp"), + ], + ), + struct( + class_name = "PWMVictorSPX", + yml_file = "semiwrap/PWMVictorSPX.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/PWMVictorSPX.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PWMVictorSPX", "wpi__PWMVictorSPX.hpp"), + ], + ), + struct( + class_name = "Spark", + yml_file = "semiwrap/Spark.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/Spark.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Spark", "wpi__Spark.hpp"), + ], + ), + struct( + class_name = "SparkMini", + yml_file = "semiwrap/SparkMini.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/SparkMini.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SparkMini", "wpi__SparkMini.hpp"), + ], + ), + struct( + class_name = "Talon", + yml_file = "semiwrap/Talon.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/Talon.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Talon", "wpi__Talon.hpp"), + ], + ), + struct( + class_name = "VictorSP", + yml_file = "semiwrap/VictorSP.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/motor/VictorSP.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::VictorSP", "wpi__VictorSP.hpp"), + ], + ), + struct( + class_name = "Compressor", + yml_file = "semiwrap/Compressor.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/Compressor.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Compressor", "wpi__Compressor.hpp"), + ], + ), + struct( + class_name = "CompressorConfigType", + yml_file = "semiwrap/CompressorConfigType.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/CompressorConfigType.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "DoubleSolenoid", + yml_file = "semiwrap/DoubleSolenoid.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/DoubleSolenoid.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DoubleSolenoid", "wpi__DoubleSolenoid.hpp"), + ], + ), + struct( + class_name = "PneumaticHub", + yml_file = "semiwrap/PneumaticHub.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/PneumaticHub.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PneumaticHub", "wpi__PneumaticHub.hpp"), + ("wpi::PneumaticHub::Version", "wpi__PneumaticHub__Version.hpp"), + ("wpi::PneumaticHub::Faults", "wpi__PneumaticHub__Faults.hpp"), + ("wpi::PneumaticHub::StickyFaults", "wpi__PneumaticHub__StickyFaults.hpp"), + ], + ), + struct( + class_name = "PneumaticsBase", + yml_file = "semiwrap/PneumaticsBase.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/PneumaticsBase.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PneumaticsBase", "wpi__PneumaticsBase.hpp"), + ], + ), + struct( + class_name = "PneumaticsControlModule", + yml_file = "semiwrap/PneumaticsControlModule.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/PneumaticsControlModule.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PneumaticsControlModule", "wpi__PneumaticsControlModule.hpp"), + ], + ), + struct( + class_name = "PneumaticsModuleType", + yml_file = "semiwrap/PneumaticsModuleType.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/PneumaticsModuleType.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Solenoid", + yml_file = "semiwrap/Solenoid.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/pneumatic/Solenoid.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Solenoid", "wpi__Solenoid.hpp"), + ], + ), + struct( + class_name = "PowerDistribution", + yml_file = "semiwrap/PowerDistribution.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/power/PowerDistribution.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::PowerDistribution", "wpi__PowerDistribution.hpp"), + ("wpi::PowerDistribution::Version", "wpi__PowerDistribution__Version.hpp"), + ("wpi::PowerDistribution::Faults", "wpi__PowerDistribution__Faults.hpp"), + ("wpi::PowerDistribution::StickyFaults", "wpi__PowerDistribution__StickyFaults.hpp"), + ], + ), + struct( + class_name = "SharpIR", + yml_file = "semiwrap/SharpIR.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/range/SharpIR.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SharpIR", "wpi__SharpIR.hpp"), + ], + ), + struct( + class_name = "AnalogEncoder", + yml_file = "semiwrap/AnalogEncoder.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/rotation/AnalogEncoder.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::AnalogEncoder", "wpi__AnalogEncoder.hpp"), + ], + ), + struct( + class_name = "AnalogPotentiometer", + yml_file = "semiwrap/AnalogPotentiometer.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/rotation/AnalogPotentiometer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::AnalogPotentiometer", "wpi__AnalogPotentiometer.hpp"), + ], + ), + struct( + class_name = "DutyCycle", + yml_file = "semiwrap/DutyCycle.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/rotation/DutyCycle.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DutyCycle", "wpi__DutyCycle.hpp"), + ], + ), + struct( + class_name = "DutyCycleEncoder", + yml_file = "semiwrap/DutyCycleEncoder.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/rotation/DutyCycleEncoder.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DutyCycleEncoder", "wpi__DutyCycleEncoder.hpp"), + ], + ), + struct( + class_name = "Encoder", + yml_file = "semiwrap/Encoder.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/hardware/rotation/Encoder.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Encoder", "wpi__Encoder.hpp"), + ], + ), + struct( + class_name = "DriverStationModeThread", + yml_file = "semiwrap/DriverStationModeThread.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/internal/DriverStationModeThread.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::internal::DriverStationModeThread", "wpi__internal__DriverStationModeThread.hpp"), + ], + ), + struct( + class_name = "Field2d", + yml_file = "semiwrap/Field2d.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/Field2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Field2d", "wpi__Field2d.hpp"), + ], + ), + struct( + class_name = "FieldObject2d", + yml_file = "semiwrap/FieldObject2d.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/FieldObject2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::FieldObject2d", "wpi__FieldObject2d.hpp"), + ], + ), + struct( + class_name = "Mechanism2d", + yml_file = "semiwrap/Mechanism2d.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/Mechanism2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Mechanism2d", "wpi__Mechanism2d.hpp"), + ], + ), + struct( + class_name = "MechanismLigament2d", + yml_file = "semiwrap/MechanismLigament2d.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/MechanismLigament2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::MechanismLigament2d", "wpi__MechanismLigament2d.hpp"), + ], + ), + struct( + class_name = "MechanismObject2d", + yml_file = "semiwrap/MechanismObject2d.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/MechanismObject2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::MechanismObject2d", "wpi__MechanismObject2d.hpp"), + ], + ), + struct( + class_name = "MechanismRoot2d", + yml_file = "semiwrap/MechanismRoot2d.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/MechanismRoot2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::MechanismRoot2d", "wpi__MechanismRoot2d.hpp"), + ], + ), + struct( + class_name = "SendableBuilderImpl", + yml_file = "semiwrap/SendableBuilderImpl.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/SendableBuilderImpl.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SendableBuilderImpl", "wpi__SendableBuilderImpl.hpp"), + ], + ), + struct( + class_name = "SendableChooser", + yml_file = "semiwrap/SendableChooser.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/SendableChooser.hpp", + tmpl_class_names = [ + ("SendableChooser_tmpl1", "SendableChooser"), + ], + trampolines = [ + ("wpi::SendableChooser", "wpi__SendableChooser.hpp"), + ], + ), + struct( + class_name = "SendableChooserBase", + yml_file = "semiwrap/SendableChooserBase.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/SendableChooserBase.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SendableChooserBase", "wpi__SendableChooserBase.hpp"), + ], + ), + struct( + class_name = "SmartDashboard", + yml_file = "semiwrap/SmartDashboard.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/smartdashboard/SmartDashboard.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SmartDashboard", "wpi__SmartDashboard.hpp"), + ], + ), + struct( + class_name = "SysIdRoutineLog", + yml_file = "semiwrap/SysIdRoutineLog.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/sysid/SysIdRoutineLog.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sysid::SysIdRoutineLog", "wpi__sysid__SysIdRoutineLog.hpp"), + ("wpi::sysid::SysIdRoutineLog::MotorLog", "wpi__sysid__SysIdRoutineLog__MotorLog.hpp"), + ], + ), + struct( + class_name = "DataLogManager", + yml_file = "semiwrap/DataLogManager.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/DataLogManager.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DataLogManager", "wpi__DataLogManager.hpp"), + ], + ), + struct( + class_name = "Errors", + yml_file = "semiwrap/Errors.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/Errors.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "RobotController", + yml_file = "semiwrap/RobotController.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/RobotController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::CANStatus", "wpi__CANStatus.hpp"), + ("wpi::RobotController", "wpi__RobotController.hpp"), + ], + ), + struct( + class_name = "RuntimeType", + yml_file = "semiwrap/RuntimeType.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/RuntimeType.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "SystemServer", + yml_file = "semiwrap/SystemServer.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/SystemServer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SystemServer", "wpi__SystemServer.hpp"), + ], + ), + struct( + class_name = "Threads", + yml_file = "semiwrap/Threads.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/Threads.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Timer", + yml_file = "semiwrap/Timer.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/Timer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Timer", "wpi__Timer.hpp"), + ], + ), + struct( + class_name = "Tracer", + yml_file = "semiwrap/Tracer.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/Tracer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Tracer", "wpi__Tracer.hpp"), + ], + ), + struct( + class_name = "Watchdog", + yml_file = "semiwrap/Watchdog.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/system/Watchdog.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Watchdog", "wpi__Watchdog.hpp"), + ], + ), + struct( + class_name = "Alert", + yml_file = "semiwrap/Alert.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/util/Alert.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Alert", "wpi__Alert.hpp"), + ], + ), + struct( + class_name = "Color", + yml_file = "semiwrap/Color.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/util/Color.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Color", "wpi__Color.hpp"), + ], + ), + struct( + class_name = "Color8Bit", + yml_file = "semiwrap/Color8Bit.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/util/Color8Bit.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Color8Bit", "wpi__Color8Bit.hpp"), + ], + ), + struct( + class_name = "Preferences", + yml_file = "semiwrap/Preferences.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/util/Preferences.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Preferences", "wpi__Preferences.hpp"), + ], + ), + struct( + class_name = "SensorUtil", + yml_file = "semiwrap/SensorUtil.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/util/SensorUtil.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SensorUtil", "wpi__SensorUtil.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpilib.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpilib.casters.pkl", + dep_file = "wpilib.casters.d", + ) + + gen_libinit( + name = "wpilib.gen_lib_init", + output_file = "src/main/python/wpilib/_init__wpilib.py", + modules = ["native.wpilib._init_robotpy_native_wpilib", "hal._init__wpiHal", "wpiutil._init__wpiutil", "ntcore._init__ntcore", "wpimath._init__wpimath", "wpimath.geometry._init__geometry", "wpimath._controls._init__controls", "wpilib.event._init__event"], + ) + + gen_pkgconf( + name = "wpilib.gen_pkgconf", + libinit_py = "wpilib._init__wpilib", + module_pkg_name = "wpilib._wpilib", + output_file = "wpilib.pc", + pkg_name = "wpilib", + install_path = "src/main/python/wpilib", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpilib/__init__.py", + ) + + gen_modinit_hpp( + name = "wpilib.gen_modinit_hpp", + input_dats = [x.class_name for x in WPILIB_HEADER_GEN], + libname = "_wpilib", + output_file = "semiwrap_init.wpilib._wpilib.hpp", + ) + + run_header_gen( + name = "wpilib", + casters_pickle = "wpilib.casters.pkl", + header_gen_config = WPILIB_HEADER_GEN, + trampoline_subpath = "src/main/python/wpilib", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + generation_defines = ["DYNAMIC_CAMERA_SERVER 1"], + ) + + create_pybind_library( + name = "wpilib", + install_path = "src/main/python/wpilib/", + extension_name = "_wpilib", + generated_srcs = [":wpilib.generated_srcs"], + semiwrap_header = [":wpilib.gen_modinit_hpp"], + deps = [ + ":wpilib.tmpl_hdrs", + ":wpilib.trampoline_hdrs", + "//hal:wpiHal", + "//hal:wpihal_pybind_library", + "//ntcore:ntcore", + "//ntcore:ntcore_pybind_library", + "//wpilibc:wpilib_event_pybind_library", + "//wpilibc:wpilibc", + "//wpimath:wpimath", + "//wpimath:wpimath_controls_pybind_library", + "//wpimath:wpimath_filter_pybind_library", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//hal:shared/wpiHal", + "//ntcore:shared/ntcore", + "//wpilibc:shared/wpilibc", + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + local_defines = ["DYNAMIC_CAMERA_SERVER=1"], + ) + + native.filegroup( + name = "wpilib.generated_files", + srcs = [ + "wpilib.gen_modinit_hpp.gen", + "wpilib.header_gen_files", + "wpilib.gen_pkgconf", + "wpilib.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpilib_counter_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPILIB_COUNTER_HEADER_GEN = [ + struct( + class_name = "EdgeConfiguration", + yml_file = "semiwrap/counter/EdgeConfiguration.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/counter/EdgeConfiguration.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "Tachometer", + yml_file = "semiwrap/counter/Tachometer.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/counter/Tachometer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::Tachometer", "wpi__Tachometer.hpp"), + ], + ), + struct( + class_name = "UpDownCounter", + yml_file = "semiwrap/counter/UpDownCounter.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/counter/UpDownCounter.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::UpDownCounter", "wpi__UpDownCounter.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpilib_counter.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpilib_counter.casters.pkl", + dep_file = "wpilib_counter.casters.d", + ) + + gen_libinit( + name = "wpilib_counter.gen_lib_init", + output_file = "src/main/python/wpilib/counter/_init__counter.py", + modules = ["native.wpilib._init_robotpy_native_wpilib", "wpilib._init__wpilib"], + ) + + gen_pkgconf( + name = "wpilib_counter.gen_pkgconf", + libinit_py = "wpilib.counter._init__counter", + module_pkg_name = "wpilib.counter._counter", + output_file = "wpilib_counter.pc", + pkg_name = "wpilib_counter", + install_path = "src/main/python/wpilib/counter", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpilib/__init__.py", + ) + + gen_modinit_hpp( + name = "wpilib_counter.gen_modinit_hpp", + input_dats = [x.class_name for x in WPILIB_COUNTER_HEADER_GEN], + libname = "_counter", + output_file = "semiwrap_init.wpilib.counter._counter.hpp", + ) + + run_header_gen( + name = "wpilib_counter", + casters_pickle = "wpilib_counter.casters.pkl", + header_gen_config = WPILIB_COUNTER_HEADER_GEN, + trampoline_subpath = "src/main/python/wpilib/counter", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpilib_counter", + install_path = "src/main/python/wpilib/counter/", + extension_name = "_counter", + generated_srcs = [":wpilib_counter.generated_srcs"], + semiwrap_header = [":wpilib_counter.gen_modinit_hpp"], + deps = [ + ":wpilib_counter.tmpl_hdrs", + ":wpilib_counter.trampoline_hdrs", + "//hal:wpiHal", + "//hal:wpihal_pybind_library", + "//ntcore:ntcore", + "//ntcore:ntcore_pybind_library", + "//wpilibc:wpilib_event_pybind_library", + "//wpilibc:wpilib_pybind_library", + "//wpilibc:wpilibc", + "//wpimath:wpimath", + "//wpimath:wpimath_controls_pybind_library", + "//wpimath:wpimath_filter_pybind_library", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//hal:shared/wpiHal", + "//ntcore:shared/ntcore", + "//wpilibc:shared/wpilibc", + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpilib_counter.generated_files", + srcs = [ + "wpilib_counter.gen_modinit_hpp.gen", + "wpilib_counter.header_gen_files", + "wpilib_counter.gen_pkgconf", + "wpilib_counter.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpilib_drive_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPILIB_DRIVE_HEADER_GEN = [ + struct( + class_name = "DifferentialDrive", + yml_file = "semiwrap/drive/DifferentialDrive.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/drive/DifferentialDrive.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::DifferentialDrive", "wpi__DifferentialDrive.hpp"), + ("wpi::DifferentialDrive::WheelSpeeds", "wpi__DifferentialDrive__WheelSpeeds.hpp"), + ], + ), + struct( + class_name = "MecanumDrive", + yml_file = "semiwrap/drive/MecanumDrive.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/drive/MecanumDrive.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::MecanumDrive", "wpi__MecanumDrive.hpp"), + ("wpi::MecanumDrive::WheelSpeeds", "wpi__MecanumDrive__WheelSpeeds.hpp"), + ], + ), + struct( + class_name = "RobotDriveBase", + yml_file = "semiwrap/drive/RobotDriveBase.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/drive/RobotDriveBase.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::RobotDriveBase", "wpi__RobotDriveBase.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpilib_drive.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpilib_drive.casters.pkl", + dep_file = "wpilib_drive.casters.d", + ) + + gen_libinit( + name = "wpilib_drive.gen_lib_init", + output_file = "src/main/python/wpilib/drive/_init__drive.py", + modules = ["native.wpilib._init_robotpy_native_wpilib", "wpilib._init__wpilib"], + ) + + gen_pkgconf( + name = "wpilib_drive.gen_pkgconf", + libinit_py = "wpilib.drive._init__drive", + module_pkg_name = "wpilib.drive._drive", + output_file = "wpilib_drive.pc", + pkg_name = "wpilib_drive", + install_path = "src/main/python/wpilib/drive", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpilib/__init__.py", + ) + + gen_modinit_hpp( + name = "wpilib_drive.gen_modinit_hpp", + input_dats = [x.class_name for x in WPILIB_DRIVE_HEADER_GEN], + libname = "_drive", + output_file = "semiwrap_init.wpilib.drive._drive.hpp", + ) + + run_header_gen( + name = "wpilib_drive", + casters_pickle = "wpilib_drive.casters.pkl", + header_gen_config = WPILIB_DRIVE_HEADER_GEN, + trampoline_subpath = "src/main/python/wpilib/drive", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpilib_drive", + install_path = "src/main/python/wpilib/drive/", + extension_name = "_drive", + generated_srcs = [":wpilib_drive.generated_srcs"], + semiwrap_header = [":wpilib_drive.gen_modinit_hpp"], + deps = [ + ":wpilib_drive.tmpl_hdrs", + ":wpilib_drive.trampoline_hdrs", + "//hal:wpiHal", + "//hal:wpihal_pybind_library", + "//ntcore:ntcore", + "//ntcore:ntcore_pybind_library", + "//wpilibc:wpilib_event_pybind_library", + "//wpilibc:wpilib_pybind_library", + "//wpilibc:wpilibc", + "//wpimath:wpimath", + "//wpimath:wpimath_controls_pybind_library", + "//wpimath:wpimath_filter_pybind_library", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//hal:shared/wpiHal", + "//ntcore:shared/ntcore", + "//wpilibc:shared/wpilibc", + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpilib_drive.generated_files", + srcs = [ + "wpilib_drive.gen_modinit_hpp.gen", + "wpilib_drive.header_gen_files", + "wpilib_drive.gen_pkgconf", + "wpilib_drive.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpilib_simulation_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPILIB_SIMULATION_HEADER_GEN = [ + struct( + class_name = "ADXL345Sim", + yml_file = "semiwrap/simulation/ADXL345Sim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/ADXL345Sim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::ADXL345Sim", "wpi__sim__ADXL345Sim.hpp"), + ], + ), + struct( + class_name = "AddressableLEDSim", + yml_file = "semiwrap/simulation/AddressableLEDSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/AddressableLEDSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::AddressableLEDSim", "wpi__sim__AddressableLEDSim.hpp"), + ], + ), + struct( + class_name = "AnalogEncoderSim", + yml_file = "semiwrap/simulation/AnalogEncoderSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/AnalogEncoderSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::AnalogEncoderSim", "wpi__sim__AnalogEncoderSim.hpp"), + ], + ), + struct( + class_name = "AnalogInputSim", + yml_file = "semiwrap/simulation/AnalogInputSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/AnalogInputSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::AnalogInputSim", "wpi__sim__AnalogInputSim.hpp"), + ], + ), + struct( + class_name = "BatterySim", + yml_file = "semiwrap/simulation/BatterySim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/BatterySim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::BatterySim", "wpi__sim__BatterySim.hpp"), + ], + ), + struct( + class_name = "CTREPCMSim", + yml_file = "semiwrap/simulation/CTREPCMSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/CTREPCMSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::CTREPCMSim", "wpi__sim__CTREPCMSim.hpp"), + ], + ), + struct( + class_name = "CallbackStore", + yml_file = "semiwrap/simulation/CallbackStore.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/CallbackStore.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::CallbackStore", "wpi__sim__CallbackStore.hpp"), + ], + ), + struct( + class_name = "DCMotorSim", + yml_file = "semiwrap/simulation/DCMotorSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DCMotorSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DCMotorSim", "wpi__sim__DCMotorSim.hpp"), + ], + ), + struct( + class_name = "DIOSim", + yml_file = "semiwrap/simulation/DIOSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DIOSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DIOSim", "wpi__sim__DIOSim.hpp"), + ], + ), + struct( + class_name = "DifferentialDrivetrainSim", + yml_file = "semiwrap/simulation/DifferentialDrivetrainSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DifferentialDrivetrainSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DifferentialDrivetrainSim", "wpi__sim__DifferentialDrivetrainSim.hpp"), + ("wpi::sim::DifferentialDrivetrainSim::State", "wpi__sim__DifferentialDrivetrainSim__State.hpp"), + ("wpi::sim::DifferentialDrivetrainSim::KitbotGearing", "wpi__sim__DifferentialDrivetrainSim__KitbotGearing.hpp"), + ("wpi::sim::DifferentialDrivetrainSim::KitbotMotor", "wpi__sim__DifferentialDrivetrainSim__KitbotMotor.hpp"), + ("wpi::sim::DifferentialDrivetrainSim::KitbotWheelSize", "wpi__sim__DifferentialDrivetrainSim__KitbotWheelSize.hpp"), + ], + ), + struct( + class_name = "DigitalPWMSim", + yml_file = "semiwrap/simulation/DigitalPWMSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DigitalPWMSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DigitalPWMSim", "wpi__sim__DigitalPWMSim.hpp"), + ], + ), + struct( + class_name = "DoubleSolenoidSim", + yml_file = "semiwrap/simulation/DoubleSolenoidSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DoubleSolenoidSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DoubleSolenoidSim", "wpi__sim__DoubleSolenoidSim.hpp"), + ], + ), + struct( + class_name = "DriverStationSim", + yml_file = "semiwrap/simulation/DriverStationSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DriverStationSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DriverStationSim", "wpi__sim__DriverStationSim.hpp"), + ], + ), + struct( + class_name = "DutyCycleEncoderSim", + yml_file = "semiwrap/simulation/DutyCycleEncoderSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DutyCycleEncoderSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DutyCycleEncoderSim", "wpi__sim__DutyCycleEncoderSim.hpp"), + ], + ), + struct( + class_name = "DutyCycleSim", + yml_file = "semiwrap/simulation/DutyCycleSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/DutyCycleSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::DutyCycleSim", "wpi__sim__DutyCycleSim.hpp"), + ], + ), + struct( + class_name = "ElevatorSim", + yml_file = "semiwrap/simulation/ElevatorSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/ElevatorSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::ElevatorSim", "wpi__sim__ElevatorSim.hpp"), + ], + ), + struct( + class_name = "EncoderSim", + yml_file = "semiwrap/simulation/EncoderSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/EncoderSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::EncoderSim", "wpi__sim__EncoderSim.hpp"), + ], + ), + struct( + class_name = "FlywheelSim", + yml_file = "semiwrap/simulation/FlywheelSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/FlywheelSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::FlywheelSim", "wpi__sim__FlywheelSim.hpp"), + ], + ), + struct( + class_name = "GamepadSim", + yml_file = "semiwrap/simulation/GamepadSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/GamepadSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::GamepadSim", "wpi__sim__GamepadSim.hpp"), + ], + ), + struct( + class_name = "GenericHIDSim", + yml_file = "semiwrap/simulation/GenericHIDSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/GenericHIDSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::GenericHIDSim", "wpi__sim__GenericHIDSim.hpp"), + ], + ), + struct( + class_name = "JoystickSim", + yml_file = "semiwrap/simulation/JoystickSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/JoystickSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::JoystickSim", "wpi__sim__JoystickSim.hpp"), + ], + ), + struct( + class_name = "LinearSystemSim", + yml_file = "semiwrap/simulation/LinearSystemSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/LinearSystemSim.hpp", + tmpl_class_names = [ + ("LinearSystemSim_tmpl1", "LinearSystemSim_1_1_1"), + ("LinearSystemSim_tmpl2", "LinearSystemSim_1_1_2"), + ("LinearSystemSim_tmpl3", "LinearSystemSim_2_1_1"), + ("LinearSystemSim_tmpl4", "LinearSystemSim_2_1_2"), + ("LinearSystemSim_tmpl5", "LinearSystemSim_2_2_1"), + ("LinearSystemSim_tmpl6", "LinearSystemSim_2_2_2"), + ], + trampolines = [ + ("wpi::sim::LinearSystemSim", "wpi__sim__LinearSystemSim.hpp"), + ], + ), + struct( + class_name = "PS4ControllerSim", + yml_file = "semiwrap/simulation/PS4ControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/PS4ControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::PS4ControllerSim", "wpi__sim__PS4ControllerSim.hpp"), + ], + ), + struct( + class_name = "PS5ControllerSim", + yml_file = "semiwrap/simulation/PS5ControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/PS5ControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::PS5ControllerSim", "wpi__sim__PS5ControllerSim.hpp"), + ], + ), + struct( + class_name = "PWMSim", + yml_file = "semiwrap/simulation/PWMSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/PWMSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::PWMSim", "wpi__sim__PWMSim.hpp"), + ], + ), + struct( + class_name = "PneumaticsBaseSim", + yml_file = "semiwrap/simulation/PneumaticsBaseSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/PneumaticsBaseSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::PneumaticsBaseSim", "wpi__sim__PneumaticsBaseSim.hpp"), + ], + ), + struct( + class_name = "PowerDistributionSim", + yml_file = "semiwrap/simulation/PowerDistributionSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/PowerDistributionSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::PowerDistributionSim", "wpi__sim__PowerDistributionSim.hpp"), + ], + ), + struct( + class_name = "PWMMotorControllerSim", + yml_file = "semiwrap/simulation/PWMMotorControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/PWMMotorControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::PWMMotorControllerSim", "wpi__sim__PWMMotorControllerSim.hpp"), + ], + ), + struct( + class_name = "REVPHSim", + yml_file = "semiwrap/simulation/REVPHSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/REVPHSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::REVPHSim", "wpi__sim__REVPHSim.hpp"), + ], + ), + struct( + class_name = "RoboRioSim", + yml_file = "semiwrap/simulation/RoboRioSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/RoboRioSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::RoboRioSim", "wpi__sim__RoboRioSim.hpp"), + ], + ), + struct( + class_name = "SendableChooserSim", + yml_file = "semiwrap/simulation/SendableChooserSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SendableChooserSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::SendableChooserSim", "wpi__sim__SendableChooserSim.hpp"), + ], + ), + struct( + class_name = "SharpIRSim", + yml_file = "semiwrap/simulation/SharpIRSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SharpIRSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::SharpIRSim", "wpi__SharpIRSim.hpp"), + ], + ), + struct( + class_name = "SimDeviceSim", + yml_file = "semiwrap/simulation/SimDeviceSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SimDeviceSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::SimDeviceSim", "wpi__sim__SimDeviceSim.hpp"), + ], + ), + struct( + class_name = "SimHooks", + yml_file = "semiwrap/simulation/SimHooks.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SimHooks.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "SingleJointedArmSim", + yml_file = "semiwrap/simulation/SingleJointedArmSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SingleJointedArmSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::SingleJointedArmSim", "wpi__sim__SingleJointedArmSim.hpp"), + ], + ), + struct( + class_name = "SolenoidSim", + yml_file = "semiwrap/simulation/SolenoidSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/SolenoidSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::SolenoidSim", "wpi__sim__SolenoidSim.hpp"), + ], + ), + struct( + class_name = "StadiaControllerSim", + yml_file = "semiwrap/simulation/StadiaControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/StadiaControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::StadiaControllerSim", "wpi__sim__StadiaControllerSim.hpp"), + ], + ), + struct( + class_name = "XboxControllerSim", + yml_file = "semiwrap/simulation/XboxControllerSim.yml", + header_root = "$(execpath :robotpy-native-wpilib.copy_headers)", + header_file = "$(execpath :robotpy-native-wpilib.copy_headers)/wpi/simulation/XboxControllerSim.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::sim::XboxControllerSim", "wpi__sim__XboxControllerSim.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpilib_simulation.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpilib_simulation.casters.pkl", + dep_file = "wpilib_simulation.casters.d", + ) + + gen_libinit( + name = "wpilib_simulation.gen_lib_init", + output_file = "src/main/python/wpilib/simulation/_init__simulation.py", + modules = ["native.wpilib._init_robotpy_native_wpilib", "wpilib._init__wpilib", "wpimath._controls._init__controls", "wpimath.geometry._init__geometry", "wpimath.kinematics._init__kinematics"], + ) + + gen_pkgconf( + name = "wpilib_simulation.gen_pkgconf", + libinit_py = "wpilib.simulation._init__simulation", + module_pkg_name = "wpilib.simulation._simulation", + output_file = "wpilib_simulation.pc", + pkg_name = "wpilib_simulation", + install_path = "src/main/python/wpilib/simulation", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpilib/__init__.py", + ) + + gen_modinit_hpp( + name = "wpilib_simulation.gen_modinit_hpp", + input_dats = [x.class_name for x in WPILIB_SIMULATION_HEADER_GEN], + libname = "_simulation", + output_file = "semiwrap_init.wpilib.simulation._simulation.hpp", + ) + + run_header_gen( + name = "wpilib_simulation", + casters_pickle = "wpilib_simulation.casters.pkl", + header_gen_config = WPILIB_SIMULATION_HEADER_GEN, + trampoline_subpath = "src/main/python/wpilib/simulation", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpilib_simulation", + install_path = "src/main/python/wpilib/simulation/", + extension_name = "_simulation", + generated_srcs = [":wpilib_simulation.generated_srcs"], + semiwrap_header = [":wpilib_simulation.gen_modinit_hpp"], + deps = [ + ":wpilib_simulation.tmpl_hdrs", + ":wpilib_simulation.trampoline_hdrs", + "//hal:wpiHal", + "//hal:wpihal_pybind_library", + "//ntcore:ntcore", + "//ntcore:ntcore_pybind_library", + "//wpilibc:wpilib_event_pybind_library", + "//wpilibc:wpilib_pybind_library", + "//wpilibc:wpilibc", + "//wpimath:wpimath", + "//wpimath:wpimath_controls_pybind_library", + "//wpimath:wpimath_filter_pybind_library", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_kinematics_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//hal:shared/wpiHal", + "//ntcore:shared/ntcore", + "//wpilibc:shared/wpilibc", + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpilib_simulation.generated_files", + srcs = [ + "wpilib_simulation.gen_modinit_hpp.gen", + "wpilib_simulation.header_gen_files", + "wpilib_simulation.gen_pkgconf", + "wpilib_simulation.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "wpilib_event.generated_files", + "wpilib.generated_files", + "wpilib_counter.generated_files", + "wpilib_drive.generated_files", + "wpilib_simulation.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/wpilib/event/wpilib_event.pc", + "src/main/python/wpilib/wpilib.pc", + "src/main/python/wpilib/counter/wpilib_counter.pc", + "src/main/python/wpilib/drive/wpilib_drive.pc", + "src/main/python/wpilib/simulation/wpilib_simulation.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/wpilib/**"], exclude = ["src/main/python/wpilib/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/wpilib/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/wpilib/**/*.py"]) + [ + "src/main/python/wpilib/event/_init__event.py", + "src/main/python/wpilib/_init__wpilib.py", + "src/main/python/wpilib/counter/_init__counter.py", + "src/main/python/wpilib/drive/_init__drive.py", + "src/main/python/wpilib/simulation/_init__simulation.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/wpilib/event/_event", + ":src/main/python/wpilib/_wpilib", + ":src/main/python/wpilib/counter/_counter", + ":src/main/python/wpilib/drive/_drive", + ":src/main/python/wpilib/simulation/_simulation", + ":wpilib_event.trampoline_hdr_files", + ":wpilib.trampoline_hdr_files", + ":wpilib_counter.trampoline_hdr_files", + ":wpilib_drive.trampoline_hdr_files", + ":wpilib_simulation.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//hal:robotpy-hal", + "//ntcore:pyntcore", + "//wpilibc:robotpy-native-wpilib", + "//wpimath:robotpy-wpimath", + "//wpiutil:robotpy-wpiutil", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + package_root_file = "src/main/python/wpilib/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//wpilibc:robotpy-native-wpilib.copy_headers", + ], + package_root_file = "src/main/python/wpilib/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + ) diff --git a/wpilibc/src/main/python/pyproject.toml b/wpilibc/src/main/python/pyproject.toml index 93e8afac1b..99afb6cb87 100644 --- a/wpilibc/src/main/python/pyproject.toml +++ b/wpilibc/src/main/python/pyproject.toml @@ -60,9 +60,6 @@ update_init = [ scan_headers_ignore = [ "wpi/system/WPILibVersion.hpp", - # needs a python wrapper - "frc/AsynchronousInterrupt.h", - "wpi/system/Filesystem.hpp", "wpi/system/Notifier.hpp", # wrapped separately "wpi/system/Resource.hpp", @@ -91,78 +88,62 @@ includes = ["wpilib/src"] DYNAMIC_CAMERA_SERVER = 1 [tool.semiwrap.extension_modules."wpilib._wpilib".headers] -# frc -ADXL345_I2C = "wpi/hardware/accelerometer/ADXL345_I2C.hpp" -AddressableLED = "wpi/hardware/led/AddressableLED.hpp" -Alert = "wpi/util/Alert.hpp" -AnalogAccelerometer = "wpi/hardware/accelerometer/AnalogAccelerometer.hpp" -AnalogEncoder = "wpi/hardware/rotation/AnalogEncoder.hpp" -AnalogInput = "wpi/hardware/discrete/AnalogInput.hpp" -AnalogPotentiometer = "wpi/hardware/rotation/AnalogPotentiometer.hpp" -CAN = "wpi/hardware/bus/CAN.hpp" -Compressor = "wpi/hardware/pneumatic/Compressor.hpp" -CompressorConfigType = "wpi/hardware/pneumatic/CompressorConfigType.hpp" -DataLogManager = "wpi/system/DataLogManager.hpp" -DSControlWord = "wpi/driverstation/DSControlWord.hpp" -DigitalInput = "wpi/hardware/discrete/DigitalInput.hpp" -DigitalOutput = "wpi/hardware/discrete/DigitalOutput.hpp" -DoubleSolenoid = "wpi/hardware/pneumatic/DoubleSolenoid.hpp" -DriverStation = "wpi/driverstation/DriverStation.hpp" -DutyCycle = "wpi/hardware/rotation/DutyCycle.hpp" -DutyCycleEncoder = "wpi/hardware/rotation/DutyCycleEncoder.hpp" -Encoder = "wpi/hardware/rotation/Encoder.hpp" -Errors = "wpi/system/Errors.hpp" +# rpy +Filesystem = "rpy/Filesystem.h" +MotorControllerGroup = "rpy/MotorControllerGroup.h" +Notifier = "rpy/Notifier.h" + +# wpi ExpansionHub = "wpi/ExpansionHub.hpp" ExpansionHubMotor = "wpi/ExpansionHubMotor.hpp" ExpansionHubPidConstants = "wpi/ExpansionHubPidConstants.hpp" ExpansionHubServo = "wpi/ExpansionHubServo.hpp" -Filesystem = "rpy/Filesystem.h" + +# wpi/driverstation +DSControlWord = "wpi/driverstation/DSControlWord.hpp" +DriverStation = "wpi/driverstation/DriverStation.hpp" Gamepad = "wpi/driverstation/Gamepad.hpp" -I2C = "wpi/hardware/bus/I2C.hpp" -IterativeRobotBase = "wpi/framework/IterativeRobotBase.hpp" +GenericHID = "wpi/driverstation/GenericHID.hpp" Joystick = "wpi/driverstation/Joystick.hpp" -LEDPattern = "wpi/hardware/led/LEDPattern.hpp" -MotorSafety = "wpi/hardware/motor/MotorSafety.hpp" -Notifier = "rpy/Notifier.h" -OnboardIMU = "wpi/hardware/imu/OnboardIMU.hpp" PS4Controller = "wpi/driverstation/PS4Controller.hpp" PS5Controller = "wpi/driverstation/PS5Controller.hpp" -PWM = "wpi/hardware/discrete/PWM.hpp" -PneumaticHub = "wpi/hardware/pneumatic/PneumaticHub.hpp" -PneumaticsBase = "wpi/hardware/pneumatic/PneumaticsBase.hpp" -PneumaticsControlModule = "wpi/hardware/pneumatic/PneumaticsControlModule.hpp" -PneumaticsModuleType = "wpi/hardware/pneumatic/PneumaticsModuleType.hpp" -PowerDistribution = "wpi/hardware/power/PowerDistribution.hpp" -Preferences = "wpi/util/Preferences.hpp" -RobotBase = "wpi/framework/RobotBase.hpp" -RobotController = "wpi/system/RobotController.hpp" -RobotState = "wpi/framework/RobotState.hpp" -RuntimeType = "wpi/system/RuntimeType.hpp" -SensorUtil = "wpi/util/SensorUtil.hpp" -SerialPort = "wpi/hardware/bus/SerialPort.hpp" -SharpIR = "wpi/hardware/range/SharpIR.hpp" -Solenoid = "wpi/hardware/pneumatic/Solenoid.hpp" StadiaController = "wpi/driverstation/StadiaController.hpp" -SystemServer = "wpi/system/SystemServer.hpp" -Threads = "wpi/system/Threads.hpp" -TimedRobot = "wpi/framework/TimedRobot.hpp" -Timer = "wpi/system/Timer.hpp" -TimesliceRobot = "wpi/framework/TimesliceRobot.hpp" -Tracer = "wpi/system/Tracer.hpp" -Watchdog = "wpi/system/Watchdog.hpp" XboxController = "wpi/driverstation/XboxController.hpp" -# frc (interfaces) +# wpi/framework +IterativeRobotBase = "wpi/framework/IterativeRobotBase.hpp" +RobotBase = "wpi/framework/RobotBase.hpp" +RobotState = "wpi/framework/RobotState.hpp" +TimedRobot = "wpi/framework/TimedRobot.hpp" +TimesliceRobot = "wpi/framework/TimesliceRobot.hpp" + +# wpi/hardware/accelerometer +ADXL345_I2C = "wpi/hardware/accelerometer/ADXL345_I2C.hpp" +AnalogAccelerometer = "wpi/hardware/accelerometer/AnalogAccelerometer.hpp" + +# wpi/hardware/bus +CAN = "wpi/hardware/bus/CAN.hpp" +I2C = "wpi/hardware/bus/I2C.hpp" +SerialPort = "wpi/hardware/bus/SerialPort.hpp" + +# wpi/hardware/discrete +AnalogInput = "wpi/hardware/discrete/AnalogInput.hpp" CounterBase = "wpi/hardware/discrete/CounterBase.hpp" -GenericHID = "wpi/driverstation/GenericHID.hpp" -MotorController = "wpi/hardware/motor/MotorController.hpp" +DigitalInput = "wpi/hardware/discrete/DigitalInput.hpp" +DigitalOutput = "wpi/hardware/discrete/DigitalOutput.hpp" +PWM = "wpi/hardware/discrete/PWM.hpp" -# frc/internal -DriverStationModeThread = "wpi/internal/DriverStationModeThread.hpp" +# wpi/hardware/imu +OnboardIMU = "wpi/hardware/imu/OnboardIMU.hpp" -# frc/motorcontrol +# wpi/hardware/led +AddressableLED = "wpi/hardware/led/AddressableLED.hpp" +LEDPattern = "wpi/hardware/led/LEDPattern.hpp" + +# wpi/hardware/motor Koors40 = "wpi/hardware/motor/Koors40.hpp" -MotorControllerGroup = "rpy/MotorControllerGroup.h" +MotorController = "wpi/hardware/motor/MotorController.hpp" +MotorSafety = "wpi/hardware/motor/MotorSafety.hpp" PWMMotorController = "wpi/hardware/motor/PWMMotorController.hpp" PWMSparkFlex = "wpi/hardware/motor/PWMSparkFlex.hpp" PWMSparkMax = "wpi/hardware/motor/PWMSparkMax.hpp" @@ -175,7 +156,33 @@ SparkMini = "wpi/hardware/motor/SparkMini.hpp" Talon = "wpi/hardware/motor/Talon.hpp" VictorSP = "wpi/hardware/motor/VictorSP.hpp" -# frc/smartdashboard +# wpi/hardware/pneumatic +Compressor = "wpi/hardware/pneumatic/Compressor.hpp" +CompressorConfigType = "wpi/hardware/pneumatic/CompressorConfigType.hpp" +DoubleSolenoid = "wpi/hardware/pneumatic/DoubleSolenoid.hpp" +PneumaticHub = "wpi/hardware/pneumatic/PneumaticHub.hpp" +PneumaticsBase = "wpi/hardware/pneumatic/PneumaticsBase.hpp" +PneumaticsControlModule = "wpi/hardware/pneumatic/PneumaticsControlModule.hpp" +PneumaticsModuleType = "wpi/hardware/pneumatic/PneumaticsModuleType.hpp" +Solenoid = "wpi/hardware/pneumatic/Solenoid.hpp" + +# wpi/hardware/power +PowerDistribution = "wpi/hardware/power/PowerDistribution.hpp" + +# wpi/hardware/range +SharpIR = "wpi/hardware/range/SharpIR.hpp" + +# wpi/hardware/rotation +AnalogEncoder = "wpi/hardware/rotation/AnalogEncoder.hpp" +AnalogPotentiometer = "wpi/hardware/rotation/AnalogPotentiometer.hpp" +DutyCycle = "wpi/hardware/rotation/DutyCycle.hpp" +DutyCycleEncoder = "wpi/hardware/rotation/DutyCycleEncoder.hpp" +Encoder = "wpi/hardware/rotation/Encoder.hpp" + +# wpi/internal +DriverStationModeThread = "wpi/internal/DriverStationModeThread.hpp" + +# wpi/smartdashboard Field2d = "wpi/smartdashboard/Field2d.hpp" FieldObject2d = "wpi/smartdashboard/FieldObject2d.hpp" Mechanism2d = "wpi/smartdashboard/Mechanism2d.hpp" @@ -187,12 +194,26 @@ SendableChooser = "wpi/smartdashboard/SendableChooser.hpp" SendableChooserBase = "wpi/smartdashboard/SendableChooserBase.hpp" SmartDashboard = "wpi/smartdashboard/SmartDashboard.hpp" -# frc/sysid +# wpi/sysid SysIdRoutineLog = "wpi/sysid/SysIdRoutineLog.hpp" -# frc/util +# wpi/system +DataLogManager = "wpi/system/DataLogManager.hpp" +Errors = "wpi/system/Errors.hpp" +RobotController = "wpi/system/RobotController.hpp" +RuntimeType = "wpi/system/RuntimeType.hpp" +SystemServer = "wpi/system/SystemServer.hpp" +Threads = "wpi/system/Threads.hpp" +Timer = "wpi/system/Timer.hpp" +Tracer = "wpi/system/Tracer.hpp" +Watchdog = "wpi/system/Watchdog.hpp" + +# wpi/util +Alert = "wpi/util/Alert.hpp" Color = "wpi/util/Color.hpp" Color8Bit = "wpi/util/Color8Bit.hpp" +Preferences = "wpi/util/Preferences.hpp" +SensorUtil = "wpi/util/SensorUtil.hpp" [tool.semiwrap.extension_modules."wpilib.counter._counter"] @@ -202,7 +223,7 @@ depends = ["wpilib"] yaml_path = "semiwrap/counter" [tool.semiwrap.extension_modules."wpilib.counter._counter".headers] -# frc/counter +# wpi/counter EdgeConfiguration = "wpi/counter/EdgeConfiguration.hpp" Tachometer = "wpi/counter/Tachometer.hpp" UpDownCounter = "wpi/counter/UpDownCounter.hpp" @@ -215,7 +236,7 @@ depends = ["wpilib"] yaml_path = "semiwrap/drive" [tool.semiwrap.extension_modules."wpilib.drive._drive".headers] -# frc/drive +# wpi/drive DifferentialDrive = "wpi/drive/DifferentialDrive.hpp" MecanumDrive = "wpi/drive/MecanumDrive.hpp" RobotDriveBase = "wpi/drive/RobotDriveBase.hpp" @@ -229,7 +250,7 @@ depends = ["wpimath_filter"] yaml_path = "semiwrap/event" [tool.semiwrap.extension_modules."wpilib.event._event".headers] -# frc/event +# wpi/event BooleanEvent = "wpi/event/BooleanEvent.hpp" EventLoop = "wpi/event/EventLoop.hpp" NetworkBooleanEvent = "wpi/event/NetworkBooleanEvent.hpp" @@ -242,7 +263,7 @@ depends = ["wpilib", "wpimath_controls", "wpimath_geometry", "wpimath_kinematics yaml_path = "semiwrap/simulation" [tool.semiwrap.extension_modules."wpilib.simulation._simulation".headers] -# frc/simulation +# wpi/simulation ADXL345Sim = "wpi/simulation/ADXL345Sim.hpp" AddressableLEDSim = "wpi/simulation/AddressableLEDSim.hpp" AnalogEncoderSim = "wpi/simulation/AnalogEncoderSim.hpp" diff --git a/wpimath/BUILD.bazel b/wpimath/BUILD.bazel index 61f0b905e6..b03ae4f920 100644 --- a/wpimath/BUILD.bazel +++ b/wpimath/BUILD.bazel @@ -8,7 +8,12 @@ load("//shared/bazel/rules:cc_rules.bzl", "generate_def_windows", "third_party_c load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules:packaging.bzl", "package_default_jni_project", "pkg_files_headers") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") load("//wpimath:generate.bzl", "generate_wpimath") +load("//wpimath:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//wpimath:robotpy_pybind_build_info.bzl", "define_pybind_library", "publish_library_casters", "wpimath_controls_extension", "wpimath_extension", "wpimath_filter_extension", "wpimath_geometry_extension", "wpimath_interpolation_extension", "wpimath_kinematics_extension", "wpimath_spline_extension") +load("//wpimath:robotpy_pybind_test_info.bzl", "wpimath_test_extension", define_test_pybind_library = "define_pybind_library") filegroup( name = "doxygen-files", @@ -319,3 +324,137 @@ package_default_jni_project( maven_artifact_name = "wpimath-cpp", maven_group_id = "org.wpilib.wpimath", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-wpimath-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", + third_party_dirs = [ + "gcem", + "sleipnir", + ], +) + +define_native_wrapper( + name = "robotpy-native-wpimath", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +PYBIND_PKGCFG_DEPS = [ + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", +] + +generate_robotpy_pybind_build_info( + name = "robotpy-wpimath-generator", + additional_srcs = [":robotpy-native-wpimath.copy_headers"], + package_root_file = "src/main/python/wpimath/__init__.py", + pkgcfgs = PYBIND_PKGCFG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/**/*.yml"]), +) + +publish_library_casters() + +wpimath_extension( + srcs = ["src/main/python/wpimath/src/wpimath.cpp"], + extra_hdrs = glob(["src/main/python/wpimath/_impl/src/**/*.h"]), +) + +wpimath_filter_extension( + srcs = ["src/main/python/wpimath/filter/filter.cpp"], + extra_hdrs = glob(["src/main/python/wpimath/_impl/src/**/*.h"]), +) + +wpimath_geometry_extension( + srcs = ["src/main/python/wpimath/geometry/geometry.cpp"], + extra_hdrs = glob(["src/main/python/wpimath/geometry/include/rpy/*"]), + header_to_dat_deps = glob(["src/main/native/include/**/*"]) + glob([ + "src/main/python/wpimath/geometry/include/**/*.h", + "src/main/python/wpimath/_impl/src/**/*.h", + ]), + includes = ["src/main/python/wpimath/geometry/include"], +) + +wpimath_interpolation_extension( + srcs = ["src/main/python/wpimath/interpolation/interpolation.cpp"], + header_to_dat_deps = glob([ + "src/main/python/wpimath/geometry/include/**/*.h", + "src/main/python/wpimath/_impl/src/**/*.h", + ]), +) + +wpimath_kinematics_extension( + srcs = ["src/main/python/wpimath/kinematics/kinematics.cpp"], + header_to_dat_deps = glob([ + "src/main/python/wpimath/geometry/include/**/*.h", + "src/main/python/wpimath/_impl/src/**/*.h", + ]), +) + +wpimath_spline_extension( + srcs = ["src/main/python/wpimath/spline/spline.cpp"], + header_to_dat_deps = glob([ + "src/main/python/wpimath/geometry/include/**/*.h", + "src/main/python/wpimath/_impl/src/**/*.h", + ]), +) + +wpimath_controls_extension( + srcs = ["src/main/python/wpimath/_controls/controls.cpp"], + header_to_dat_deps = glob([ + "src/main/python/wpimath/geometry/include/**/*.h", + "src/main/python/wpimath/_impl/src/**/*.h", + ]), +) + +define_pybind_library( + name = "robotpy-wpimath", + pkgcfgs = PYBIND_PKGCFG_DEPS, +) + +generate_robotpy_pybind_build_info( + name = "robotpy-wpimath_test-generator", + additional_srcs = ["src/test/python/cpp/wpimath_test/include/module.h"], + generated_file_name = "robotpy_pybind_test_info.bzl", + package_root_file = "src/test/python/cpp/wpimath_test/__init__.py", + pkgcfgs = [ + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpimath:robotpy-wpimath.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", + ], + pyproject_toml = "src/test/python/cpp/pyproject.toml", + stripped_include_prefix = "src/test/python/cpp", + yaml_files = glob(["src/test/python/cpp/semiwrap/**/*.yml"]), + yml_prefix = "src/test/python/cpp/", +) + +wpimath_test_extension( + srcs = glob(["src/test/python/cpp/wpimath_test/src/*.cpp"]), + extra_hdrs = ["src/test/python/cpp/wpimath_test/include/module.h"], + header_to_dat_deps = ["src/test/python/cpp/wpimath_test/include/module.h"], + includes = ["src/test/python/cpp/wpimath_test/include"], +) + +define_test_pybind_library( + name = "robotpy-wpimath-test", + pkgcfgs = [ + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpimath:robotpy-wpimath.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", + ], +) + +robotpy_py_test( + "python_tests", + srcs = glob( + ["src/test/python/**/*.py"], + exclude = ["src/test/python/cpp/**"], + ), + deps = [ + ":robotpy-wpimath", + ":robotpy-wpimath-test", + requirement("pytest"), + ], +) diff --git a/wpimath/robotpy_native_build_info.bzl b/wpimath/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..103ac9ee62 --- /dev/null +++ b/wpimath/robotpy_native_build_info.bzl @@ -0,0 +1,39 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True) + native.glob([ + "src/main/native/thirdparty/gcem/include/**", + "src/main/native/thirdparty/sleipnir/include/**", + ]), + out = "native/wpimath/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "wpimath/src/generated/main/native/include": "", + "wpimath/src/main/native/include": "", + "wpimath/src/main/native/thirdparty/gcem/include": "", + "wpimath/src/main/native/thirdparty/sleipnir/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/wpimath/_init_robotpy_native_wpimath.py", + pc_file = "native/wpimath/robotpy-native-wpimath.pc", + pc_deps = [ + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + ], + deps = [ + "//wpiutil:robotpy-native-wpiutil", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/wpimath", + install_path = "native/wpimath/", + ) diff --git a/wpimath/robotpy_pybind_build_info.bzl b/wpimath/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..e6e21ae000 --- /dev/null +++ b/wpimath/robotpy_pybind_build_info.bzl @@ -0,0 +1,1785 @@ +# THIS FILE IS AUTO GENERATED + +load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "publish_casters", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def wpimath_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_HEADER_GEN = [ + struct( + class_name = "ComputerVisionUtil", + yml_file = "semiwrap/ComputerVisionUtil.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/util/ComputerVisionUtil.hpp", + tmpl_class_names = [], + trampolines = [], + ), + struct( + class_name = "MathUtil", + yml_file = "semiwrap/MathUtil.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/util/MathUtil.hpp", + tmpl_class_names = [], + trampolines = [], + ), + ] + + resolve_casters( + name = "wpimath.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json", ":src/main/python/wpimath/wpimath-casters.pybind11.json"], + casters_pkl_file = "wpimath.casters.pkl", + dep_file = "wpimath.casters.d", + ) + + gen_libinit( + name = "wpimath.gen_lib_init", + output_file = "src/main/python/wpimath/_init__wpimath.py", + modules = ["native.wpimath._init_robotpy_native_wpimath", "wpiutil._init__wpiutil"], + ) + + gen_pkgconf( + name = "wpimath.gen_pkgconf", + libinit_py = "wpimath._init__wpimath", + module_pkg_name = "wpimath._wpimath", + output_file = "wpimath.pc", + pkg_name = "wpimath", + install_path = "src/main/python/wpimath", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_HEADER_GEN], + libname = "_wpimath", + output_file = "semiwrap_init.wpimath._wpimath.hpp", + ) + + run_header_gen( + name = "wpimath", + casters_pickle = "wpimath.casters.pkl", + header_gen_config = WPIMATH_HEADER_GEN, + trampoline_subpath = "src/main/python/wpimath", + deps = header_to_dat_deps, + local_native_libraries = [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpimath", + install_path = "src/main/python/wpimath/", + extension_name = "_wpimath", + generated_srcs = [":wpimath.generated_srcs"], + semiwrap_header = [":wpimath.gen_modinit_hpp"], + deps = [ + ":wpimath.tmpl_hdrs", + ":wpimath.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath-casters", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath.generated_files", + srcs = [ + "wpimath.gen_modinit_hpp.gen", + "wpimath.header_gen_files", + "wpimath.gen_pkgconf", + "wpimath.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpimath_filter_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_FILTER_HEADER_GEN = [ + struct( + class_name = "Debouncer", + yml_file = "semiwrap/filter/Debouncer.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/filter/Debouncer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Debouncer", "wpi__math__Debouncer.hpp"), + ], + ), + struct( + class_name = "LinearFilter", + yml_file = "semiwrap/filter/LinearFilter.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/filter/LinearFilter.hpp", + tmpl_class_names = [ + ("LinearFilter_tmpl1", "LinearFilter"), + ], + trampolines = [ + ("wpi::math::LinearFilter", "wpi__math__LinearFilter.hpp"), + ], + ), + struct( + class_name = "MedianFilter", + yml_file = "semiwrap/filter/MedianFilter.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/filter/MedianFilter.hpp", + tmpl_class_names = [ + ("MedianFilter_tmpl1", "MedianFilter"), + ], + trampolines = [ + ("wpi::math::MedianFilter", "wpi__math__MedianFilter.hpp"), + ], + ), + struct( + class_name = "SlewRateLimiter", + yml_file = "semiwrap/filter/SlewRateLimiter.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/filter/SlewRateLimiter.hpp", + tmpl_class_names = [ + ("SlewRateLimiter_tmpl1", "SlewRateLimiter"), + ], + trampolines = [ + ("wpi::math::SlewRateLimiter", "wpi__math__SlewRateLimiter.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpimath_filter.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json", ":src/main/python/wpimath/wpimath-casters.pybind11.json"], + casters_pkl_file = "wpimath_filter.casters.pkl", + dep_file = "wpimath_filter.casters.d", + ) + + gen_libinit( + name = "wpimath_filter.gen_lib_init", + output_file = "src/main/python/wpimath/filter/_init__filter.py", + modules = ["native.wpimath._init_robotpy_native_wpimath", "wpimath._init__wpimath"], + ) + + gen_pkgconf( + name = "wpimath_filter.gen_pkgconf", + libinit_py = "wpimath.filter._init__filter", + module_pkg_name = "wpimath.filter._filter", + output_file = "wpimath_filter.pc", + pkg_name = "wpimath_filter", + install_path = "src/main/python/wpimath/filter", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath_filter.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_FILTER_HEADER_GEN], + libname = "_filter", + output_file = "semiwrap_init.wpimath.filter._filter.hpp", + ) + + run_header_gen( + name = "wpimath_filter", + casters_pickle = "wpimath_filter.casters.pkl", + header_gen_config = WPIMATH_FILTER_HEADER_GEN, + trampoline_subpath = "src/main/python/wpimath/filter", + deps = header_to_dat_deps, + local_native_libraries = [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpimath_filter", + install_path = "src/main/python/wpimath/filter/", + extension_name = "_filter", + generated_srcs = [":wpimath_filter.generated_srcs"], + semiwrap_header = [":wpimath_filter.gen_modinit_hpp"], + deps = [ + ":wpimath_filter.tmpl_hdrs", + ":wpimath_filter.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath-casters", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath_filter.generated_files", + srcs = [ + "wpimath_filter.gen_modinit_hpp.gen", + "wpimath_filter.header_gen_files", + "wpimath_filter.gen_pkgconf", + "wpimath_filter.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpimath_geometry_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_GEOMETRY_HEADER_GEN = [ + struct( + class_name = "CoordinateAxis", + yml_file = "semiwrap/geometry/CoordinateAxis.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/CoordinateAxis.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::CoordinateAxis", "wpi__math__CoordinateAxis.hpp"), + ], + ), + struct( + class_name = "CoordinateSystem", + yml_file = "semiwrap/geometry/CoordinateSystem.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/CoordinateSystem.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::CoordinateSystem", "wpi__math__CoordinateSystem.hpp"), + ], + ), + struct( + class_name = "Ellipse2d", + yml_file = "semiwrap/geometry/Ellipse2d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Ellipse2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Ellipse2d", "wpi__math__Ellipse2d.hpp"), + ], + ), + struct( + class_name = "Pose2d", + yml_file = "semiwrap/geometry/Pose2d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Pose2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Pose2d", "wpi__math__Pose2d.hpp"), + ], + ), + struct( + class_name = "Pose3d", + yml_file = "semiwrap/geometry/Pose3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Pose3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Pose3d", "wpi__math__Pose3d.hpp"), + ], + ), + struct( + class_name = "Quaternion", + yml_file = "semiwrap/geometry/Quaternion.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Quaternion.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Quaternion", "wpi__math__Quaternion.hpp"), + ], + ), + struct( + class_name = "Rectangle2d", + yml_file = "semiwrap/geometry/Rectangle2d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Rectangle2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Rectangle2d", "wpi__math__Rectangle2d.hpp"), + ], + ), + struct( + class_name = "Rotation2d", + yml_file = "semiwrap/geometry/Rotation2d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Rotation2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Rotation2d", "wpi__math__Rotation2d.hpp"), + ], + ), + struct( + class_name = "Rotation3d", + yml_file = "semiwrap/geometry/Rotation3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Rotation3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Rotation3d", "wpi__math__Rotation3d.hpp"), + ], + ), + struct( + class_name = "Transform2d", + yml_file = "semiwrap/geometry/Transform2d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Transform2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Transform2d", "wpi__math__Transform2d.hpp"), + ], + ), + struct( + class_name = "Transform3d", + yml_file = "semiwrap/geometry/Transform3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Transform3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Transform3d", "wpi__math__Transform3d.hpp"), + ], + ), + struct( + class_name = "Translation2d", + yml_file = "semiwrap/geometry/Translation2d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Translation2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Translation2d", "wpi__math__Translation2d.hpp"), + ], + ), + struct( + class_name = "Translation3d", + yml_file = "semiwrap/geometry/Translation3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Translation3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Translation3d", "wpi__math__Translation3d.hpp"), + ], + ), + struct( + class_name = "Twist2d", + yml_file = "semiwrap/geometry/Twist2d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Twist2d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Twist2d", "wpi__math__Twist2d.hpp"), + ], + ), + struct( + class_name = "Twist3d", + yml_file = "semiwrap/geometry/Twist3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/geometry/Twist3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Twist3d", "wpi__math__Twist3d.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpimath_geometry.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json", ":src/main/python/wpimath/wpimath-casters.pybind11.json"], + casters_pkl_file = "wpimath_geometry.casters.pkl", + dep_file = "wpimath_geometry.casters.d", + ) + + gen_libinit( + name = "wpimath_geometry.gen_lib_init", + output_file = "src/main/python/wpimath/geometry/_init__geometry.py", + modules = ["native.wpimath._init_robotpy_native_wpimath", "wpimath._init__wpimath"], + ) + + gen_pkgconf( + name = "wpimath_geometry.gen_pkgconf", + libinit_py = "wpimath.geometry._init__geometry", + module_pkg_name = "wpimath.geometry._geometry", + output_file = "wpimath_geometry.pc", + pkg_name = "wpimath_geometry", + install_path = "src/main/python/wpimath/geometry", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath_geometry.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_GEOMETRY_HEADER_GEN], + libname = "_geometry", + output_file = "semiwrap_init.wpimath.geometry._geometry.hpp", + ) + + run_header_gen( + name = "wpimath_geometry", + casters_pickle = "wpimath_geometry.casters.pkl", + header_gen_config = WPIMATH_GEOMETRY_HEADER_GEN, + trampoline_subpath = "src/main/python/wpimath/geometry", + deps = header_to_dat_deps, + local_native_libraries = [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpimath_geometry", + install_path = "src/main/python/wpimath/geometry/", + extension_name = "_geometry", + generated_srcs = [":wpimath_geometry.generated_srcs"], + semiwrap_header = [":wpimath_geometry.gen_modinit_hpp"], + deps = [ + ":wpimath_geometry.tmpl_hdrs", + ":wpimath_geometry.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath-casters", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath_geometry.generated_files", + srcs = [ + "wpimath_geometry.gen_modinit_hpp.gen", + "wpimath_geometry.header_gen_files", + "wpimath_geometry.gen_pkgconf", + "wpimath_geometry.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpimath_interpolation_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_INTERPOLATION_HEADER_GEN = [ + struct( + class_name = "TimeInterpolatableBuffer", + yml_file = "semiwrap/interpolation/TimeInterpolatableBuffer.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/interpolation/TimeInterpolatableBuffer.hpp", + tmpl_class_names = [ + ("TimeInterpolatableBuffer_tmpl1", "TimeInterpolatablePose2dBuffer"), + ("TimeInterpolatableBuffer_tmpl2", "TimeInterpolatablePose3dBuffer"), + ("TimeInterpolatableBuffer_tmpl3", "TimeInterpolatableRotation2dBuffer"), + ("TimeInterpolatableBuffer_tmpl4", "TimeInterpolatableRotation3dBuffer"), + ("TimeInterpolatableBuffer_tmpl5", "TimeInterpolatableTranslation2dBuffer"), + ("TimeInterpolatableBuffer_tmpl6", "TimeInterpolatableTranslation3dBuffer"), + ("TimeInterpolatableBuffer_tmpl7", "TimeInterpolatableFloatBuffer"), + ], + trampolines = [ + ("wpi::math::TimeInterpolatableBuffer", "wpi__math__TimeInterpolatableBuffer.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpimath_interpolation.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json", ":src/main/python/wpimath/wpimath-casters.pybind11.json"], + casters_pkl_file = "wpimath_interpolation.casters.pkl", + dep_file = "wpimath_interpolation.casters.d", + ) + + gen_libinit( + name = "wpimath_interpolation.gen_lib_init", + output_file = "src/main/python/wpimath/interpolation/_init__interpolation.py", + modules = ["native.wpimath._init_robotpy_native_wpimath", "wpimath.geometry._init__geometry"], + ) + + gen_pkgconf( + name = "wpimath_interpolation.gen_pkgconf", + libinit_py = "wpimath.interpolation._init__interpolation", + module_pkg_name = "wpimath.interpolation._interpolation", + output_file = "wpimath_interpolation.pc", + pkg_name = "wpimath_interpolation", + install_path = "src/main/python/wpimath/interpolation", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath_interpolation.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_INTERPOLATION_HEADER_GEN], + libname = "_interpolation", + output_file = "semiwrap_init.wpimath.interpolation._interpolation.hpp", + ) + + run_header_gen( + name = "wpimath_interpolation", + casters_pickle = "wpimath_interpolation.casters.pkl", + header_gen_config = WPIMATH_INTERPOLATION_HEADER_GEN, + trampoline_subpath = "src/main/python/wpimath/interpolation", + deps = header_to_dat_deps, + local_native_libraries = [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpimath_interpolation", + install_path = "src/main/python/wpimath/interpolation/", + extension_name = "_interpolation", + generated_srcs = [":wpimath_interpolation.generated_srcs"], + semiwrap_header = [":wpimath_interpolation.gen_modinit_hpp"], + deps = [ + ":wpimath_interpolation.tmpl_hdrs", + ":wpimath_interpolation.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath-casters", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath_interpolation.generated_files", + srcs = [ + "wpimath_interpolation.gen_modinit_hpp.gen", + "wpimath_interpolation.header_gen_files", + "wpimath_interpolation.gen_pkgconf", + "wpimath_interpolation.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpimath_kinematics_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_KINEMATICS_HEADER_GEN = [ + struct( + class_name = "ChassisSpeeds", + yml_file = "semiwrap/kinematics/ChassisSpeeds.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/ChassisSpeeds.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::ChassisSpeeds", "wpi__math__ChassisSpeeds.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveKinematics", + yml_file = "semiwrap/kinematics/DifferentialDriveKinematics.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/DifferentialDriveKinematics.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveKinematics", "wpi__math__DifferentialDriveKinematics.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveOdometry3d", + yml_file = "semiwrap/kinematics/DifferentialDriveOdometry3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/DifferentialDriveOdometry3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveOdometry3d", "wpi__math__DifferentialDriveOdometry3d.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveOdometry", + yml_file = "semiwrap/kinematics/DifferentialDriveOdometry.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/DifferentialDriveOdometry.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveOdometry", "wpi__math__DifferentialDriveOdometry.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveWheelPositions", + yml_file = "semiwrap/kinematics/DifferentialDriveWheelPositions.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/DifferentialDriveWheelPositions.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveWheelPositions", "wpi__math__DifferentialDriveWheelPositions.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveWheelSpeeds", + yml_file = "semiwrap/kinematics/DifferentialDriveWheelSpeeds.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/DifferentialDriveWheelSpeeds.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveWheelSpeeds", "wpi__math__DifferentialDriveWheelSpeeds.hpp"), + ], + ), + struct( + class_name = "Kinematics", + yml_file = "semiwrap/kinematics/Kinematics.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/Kinematics.hpp", + tmpl_class_names = [ + ("Kinematics_tmpl1", "DifferentialDriveKinematicsBase"), + ("Kinematics_tmpl2", "MecanumDriveKinematicsBase"), + ("Kinematics_tmpl3", "SwerveDrive2KinematicsBase"), + ("Kinematics_tmpl4", "SwerveDrive3KinematicsBase"), + ("Kinematics_tmpl5", "SwerveDrive4KinematicsBase"), + ("Kinematics_tmpl6", "SwerveDrive6KinematicsBase"), + ], + trampolines = [ + ("wpi::math::Kinematics", "wpi__math__Kinematics.hpp"), + ], + ), + struct( + class_name = "MecanumDriveKinematics", + yml_file = "semiwrap/kinematics/MecanumDriveKinematics.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/MecanumDriveKinematics.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDriveKinematics", "wpi__math__MecanumDriveKinematics.hpp"), + ], + ), + struct( + class_name = "MecanumDriveOdometry", + yml_file = "semiwrap/kinematics/MecanumDriveOdometry.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/MecanumDriveOdometry.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDriveOdometry", "wpi__math__MecanumDriveOdometry.hpp"), + ], + ), + struct( + class_name = "MecanumDriveOdometry3d", + yml_file = "semiwrap/kinematics/MecanumDriveOdometry3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/MecanumDriveOdometry3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDriveOdometry3d", "wpi__math__MecanumDriveOdometry3d.hpp"), + ], + ), + struct( + class_name = "MecanumDriveWheelPositions", + yml_file = "semiwrap/kinematics/MecanumDriveWheelPositions.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/MecanumDriveWheelPositions.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDriveWheelPositions", "wpi__math__MecanumDriveWheelPositions.hpp"), + ], + ), + struct( + class_name = "MecanumDriveWheelSpeeds", + yml_file = "semiwrap/kinematics/MecanumDriveWheelSpeeds.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/MecanumDriveWheelSpeeds.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDriveWheelSpeeds", "wpi__math__MecanumDriveWheelSpeeds.hpp"), + ], + ), + struct( + class_name = "Odometry", + yml_file = "semiwrap/kinematics/Odometry.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/Odometry.hpp", + tmpl_class_names = [ + ("Odometry_tmpl1", "DifferentialDriveOdometryBase"), + ("Odometry_tmpl2", "MecanumDriveOdometryBase"), + ("Odometry_tmpl3", "SwerveDrive2OdometryBase"), + ("Odometry_tmpl4", "SwerveDrive3OdometryBase"), + ("Odometry_tmpl5", "SwerveDrive4OdometryBase"), + ("Odometry_tmpl6", "SwerveDrive6OdometryBase"), + ], + trampolines = [ + ("wpi::math::Odometry", "wpi__math__Odometry.hpp"), + ], + ), + struct( + class_name = "Odometry3d", + yml_file = "semiwrap/kinematics/Odometry3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/Odometry3d.hpp", + tmpl_class_names = [ + ("Odometry3d_tmpl1", "DifferentialDriveOdometry3dBase"), + ("Odometry3d_tmpl2", "MecanumDriveOdometry3dBase"), + ("Odometry3d_tmpl3", "SwerveDrive2Odometry3dBase"), + ("Odometry3d_tmpl4", "SwerveDrive3Odometry3dBase"), + ("Odometry3d_tmpl5", "SwerveDrive4Odometry3dBase"), + ("Odometry3d_tmpl6", "SwerveDrive6Odometry3dBase"), + ], + trampolines = [ + ("wpi::math::Odometry3d", "wpi__math__Odometry3d.hpp"), + ], + ), + struct( + class_name = "SwerveDriveKinematics", + yml_file = "semiwrap/kinematics/SwerveDriveKinematics.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/SwerveDriveKinematics.hpp", + tmpl_class_names = [ + ("SwerveDriveKinematics_tmpl1", "SwerveDrive2Kinematics"), + ("SwerveDriveKinematics_tmpl2", "SwerveDrive3Kinematics"), + ("SwerveDriveKinematics_tmpl3", "SwerveDrive4Kinematics"), + ("SwerveDriveKinematics_tmpl4", "SwerveDrive6Kinematics"), + ], + trampolines = [ + ("wpi::math::SwerveDriveKinematics", "wpi__math__SwerveDriveKinematics.hpp"), + ], + ), + struct( + class_name = "SwerveDriveOdometry", + yml_file = "semiwrap/kinematics/SwerveDriveOdometry.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/SwerveDriveOdometry.hpp", + tmpl_class_names = [ + ("SwerveDriveOdometry_tmpl1", "SwerveDrive2Odometry"), + ("SwerveDriveOdometry_tmpl2", "SwerveDrive3Odometry"), + ("SwerveDriveOdometry_tmpl3", "SwerveDrive4Odometry"), + ("SwerveDriveOdometry_tmpl4", "SwerveDrive6Odometry"), + ], + trampolines = [ + ("wpi::math::SwerveDriveOdometry", "wpi__math__SwerveDriveOdometry.hpp"), + ], + ), + struct( + class_name = "SwerveDriveOdometry3d", + yml_file = "semiwrap/kinematics/SwerveDriveOdometry3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/SwerveDriveOdometry3d.hpp", + tmpl_class_names = [ + ("SwerveDriveOdometry3d_tmpl1", "SwerveDrive2Odometry3d"), + ("SwerveDriveOdometry3d_tmpl2", "SwerveDrive3Odometry3d"), + ("SwerveDriveOdometry3d_tmpl3", "SwerveDrive4Odometry3d"), + ("SwerveDriveOdometry3d_tmpl4", "SwerveDrive6Odometry3d"), + ], + trampolines = [ + ("wpi::math::SwerveDriveOdometry3d", "wpi__math__SwerveDriveOdometry3d.hpp"), + ], + ), + struct( + class_name = "SwerveModulePosition", + yml_file = "semiwrap/kinematics/SwerveModulePosition.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/SwerveModulePosition.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::SwerveModulePosition", "wpi__math__SwerveModulePosition.hpp"), + ], + ), + struct( + class_name = "SwerveModuleState", + yml_file = "semiwrap/kinematics/SwerveModuleState.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/kinematics/SwerveModuleState.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::SwerveModuleState", "wpi__math__SwerveModuleState.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpimath_kinematics.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json", ":src/main/python/wpimath/wpimath-casters.pybind11.json"], + casters_pkl_file = "wpimath_kinematics.casters.pkl", + dep_file = "wpimath_kinematics.casters.d", + ) + + gen_libinit( + name = "wpimath_kinematics.gen_lib_init", + output_file = "src/main/python/wpimath/kinematics/_init__kinematics.py", + modules = ["native.wpimath._init_robotpy_native_wpimath", "wpimath.geometry._init__geometry"], + ) + + gen_pkgconf( + name = "wpimath_kinematics.gen_pkgconf", + libinit_py = "wpimath.kinematics._init__kinematics", + module_pkg_name = "wpimath.kinematics._kinematics", + output_file = "wpimath_kinematics.pc", + pkg_name = "wpimath_kinematics", + install_path = "src/main/python/wpimath/kinematics", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath_kinematics.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_KINEMATICS_HEADER_GEN], + libname = "_kinematics", + output_file = "semiwrap_init.wpimath.kinematics._kinematics.hpp", + ) + + run_header_gen( + name = "wpimath_kinematics", + casters_pickle = "wpimath_kinematics.casters.pkl", + header_gen_config = WPIMATH_KINEMATICS_HEADER_GEN, + trampoline_subpath = "src/main/python/wpimath/kinematics", + deps = header_to_dat_deps, + local_native_libraries = [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpimath_kinematics", + install_path = "src/main/python/wpimath/kinematics/", + extension_name = "_kinematics", + generated_srcs = [":wpimath_kinematics.generated_srcs"], + semiwrap_header = [":wpimath_kinematics.gen_modinit_hpp"], + deps = [ + ":wpimath_kinematics.tmpl_hdrs", + ":wpimath_kinematics.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath-casters", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath_kinematics.generated_files", + srcs = [ + "wpimath_kinematics.gen_modinit_hpp.gen", + "wpimath_kinematics.header_gen_files", + "wpimath_kinematics.gen_pkgconf", + "wpimath_kinematics.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpimath_spline_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_SPLINE_HEADER_GEN = [ + struct( + class_name = "CubicHermiteSpline", + yml_file = "semiwrap/spline/CubicHermiteSpline.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/spline/CubicHermiteSpline.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::CubicHermiteSpline", "wpi__math__CubicHermiteSpline.hpp"), + ], + ), + struct( + class_name = "QuinticHermiteSpline", + yml_file = "semiwrap/spline/QuinticHermiteSpline.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/spline/QuinticHermiteSpline.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::QuinticHermiteSpline", "wpi__math__QuinticHermiteSpline.hpp"), + ], + ), + struct( + class_name = "Spline", + yml_file = "semiwrap/spline/Spline.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/spline/Spline.hpp", + tmpl_class_names = [ + ("Spline_tmpl1", "Spline3"), + ("Spline_tmpl2", "Spline5"), + ], + trampolines = [ + ("wpi::math::Spline", "wpi__math__Spline.hpp"), + ("wpi::math::Spline::ControlVector", "wpi__math__Spline__ControlVector.hpp"), + ], + ), + struct( + class_name = "SplineHelper", + yml_file = "semiwrap/spline/SplineHelper.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/spline/SplineHelper.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::SplineHelper", "wpi__math__SplineHelper.hpp"), + ], + ), + struct( + class_name = "SplineParameterizer", + yml_file = "semiwrap/spline/SplineParameterizer.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/spline/SplineParameterizer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::SplineParameterizer", "wpi__math__SplineParameterizer.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpimath_spline.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json", ":src/main/python/wpimath/wpimath-casters.pybind11.json"], + casters_pkl_file = "wpimath_spline.casters.pkl", + dep_file = "wpimath_spline.casters.d", + ) + + gen_libinit( + name = "wpimath_spline.gen_lib_init", + output_file = "src/main/python/wpimath/spline/_init__spline.py", + modules = ["native.wpimath._init_robotpy_native_wpimath", "wpimath.geometry._init__geometry"], + ) + + gen_pkgconf( + name = "wpimath_spline.gen_pkgconf", + libinit_py = "wpimath.spline._init__spline", + module_pkg_name = "wpimath.spline._spline", + output_file = "wpimath_spline.pc", + pkg_name = "wpimath_spline", + install_path = "src/main/python/wpimath/spline", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath_spline.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_SPLINE_HEADER_GEN], + libname = "_spline", + output_file = "semiwrap_init.wpimath.spline._spline.hpp", + ) + + run_header_gen( + name = "wpimath_spline", + casters_pickle = "wpimath_spline.casters.pkl", + header_gen_config = WPIMATH_SPLINE_HEADER_GEN, + trampoline_subpath = "src/main/python/wpimath/spline", + deps = header_to_dat_deps, + local_native_libraries = [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpimath_spline", + install_path = "src/main/python/wpimath/spline/", + extension_name = "_spline", + generated_srcs = [":wpimath_spline.generated_srcs"], + semiwrap_header = [":wpimath_spline.gen_modinit_hpp"], + deps = [ + ":wpimath_spline.tmpl_hdrs", + ":wpimath_spline.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath-casters", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath_spline.generated_files", + srcs = [ + "wpimath_spline.gen_modinit_hpp.gen", + "wpimath_spline.header_gen_files", + "wpimath_spline.gen_pkgconf", + "wpimath_spline.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def wpimath_controls_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_CONTROLS_HEADER_GEN = [ + struct( + class_name = "ArmFeedforward", + yml_file = "semiwrap/controls/ArmFeedforward.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/ArmFeedforward.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::ArmFeedforward", "wpi__math__ArmFeedforward.hpp"), + ], + ), + struct( + class_name = "BangBangController", + yml_file = "semiwrap/controls/BangBangController.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/BangBangController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::BangBangController", "wpi__math__BangBangController.hpp"), + ], + ), + struct( + class_name = "ControlAffinePlantInversionFeedforward", + yml_file = "semiwrap/controls/ControlAffinePlantInversionFeedforward.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/ControlAffinePlantInversionFeedforward.hpp", + tmpl_class_names = [ + ("ControlAffinePlantInversionFeedforward_tmpl1", "ControlAffinePlantInversionFeedforward_1_1"), + ("ControlAffinePlantInversionFeedforward_tmpl2", "ControlAffinePlantInversionFeedforward_2_1"), + ("ControlAffinePlantInversionFeedforward_tmpl3", "ControlAffinePlantInversionFeedforward_2_2"), + ], + trampolines = [ + ("wpi::math::ControlAffinePlantInversionFeedforward", "wpi__math__ControlAffinePlantInversionFeedforward.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveAccelerationLimiter", + yml_file = "semiwrap/controls/DifferentialDriveAccelerationLimiter.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/DifferentialDriveAccelerationLimiter.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveAccelerationLimiter", "wpi__math__DifferentialDriveAccelerationLimiter.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveFeedforward", + yml_file = "semiwrap/controls/DifferentialDriveFeedforward.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/DifferentialDriveFeedforward.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveFeedforward", "wpi__math__DifferentialDriveFeedforward.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveWheelVoltages", + yml_file = "semiwrap/controls/DifferentialDriveWheelVoltages.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/DifferentialDriveWheelVoltages.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveWheelVoltages", "wpi__math__DifferentialDriveWheelVoltages.hpp"), + ], + ), + struct( + class_name = "ElevatorFeedforward", + yml_file = "semiwrap/controls/ElevatorFeedforward.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/ElevatorFeedforward.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::ElevatorFeedforward", "wpi__math__ElevatorFeedforward.hpp"), + ], + ), + struct( + class_name = "ImplicitModelFollower", + yml_file = "semiwrap/controls/ImplicitModelFollower.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/ImplicitModelFollower.hpp", + tmpl_class_names = [ + ("ImplicitModelFollower_tmpl1", "ImplicitModelFollower_1_1"), + ("ImplicitModelFollower_tmpl2", "ImplicitModelFollower_2_1"), + ("ImplicitModelFollower_tmpl3", "ImplicitModelFollower_2_2"), + ], + trampolines = [ + ("wpi::math::ImplicitModelFollower", "wpi__math__ImplicitModelFollower.hpp"), + ], + ), + struct( + class_name = "LTVDifferentialDriveController", + yml_file = "semiwrap/controls/LTVDifferentialDriveController.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/LTVDifferentialDriveController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::LTVDifferentialDriveController", "wpi__math__LTVDifferentialDriveController.hpp"), + ], + ), + struct( + class_name = "LTVUnicycleController", + yml_file = "semiwrap/controls/LTVUnicycleController.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/LTVUnicycleController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::LTVUnicycleController", "wpi__math__LTVUnicycleController.hpp"), + ], + ), + struct( + class_name = "LinearPlantInversionFeedforward", + yml_file = "semiwrap/controls/LinearPlantInversionFeedforward.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/LinearPlantInversionFeedforward.hpp", + tmpl_class_names = [ + ("LinearPlantInversionFeedforward_tmpl1", "LinearPlantInversionFeedforward_1_1"), + ("LinearPlantInversionFeedforward_tmpl2", "LinearPlantInversionFeedforward_2_1"), + ("LinearPlantInversionFeedforward_tmpl3", "LinearPlantInversionFeedforward_2_2"), + ("LinearPlantInversionFeedforward_tmpl4", "LinearPlantInversionFeedforward_3_2"), + ], + trampolines = [ + ("wpi::math::LinearPlantInversionFeedforward", "wpi__math__LinearPlantInversionFeedforward.hpp"), + ], + ), + struct( + class_name = "LinearQuadraticRegulator", + yml_file = "semiwrap/controls/LinearQuadraticRegulator.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/LinearQuadraticRegulator.hpp", + tmpl_class_names = [ + ("LinearQuadraticRegulator_tmpl1", "LinearQuadraticRegulator_1_1"), + ("LinearQuadraticRegulator_tmpl2", "LinearQuadraticRegulator_2_1"), + ("LinearQuadraticRegulator_tmpl3", "LinearQuadraticRegulator_2_2"), + ("LinearQuadraticRegulator_tmpl4", "LinearQuadraticRegulator_3_2"), + ], + trampolines = [ + ("wpi::math::LinearQuadraticRegulator", "wpi__math__LinearQuadraticRegulator.hpp"), + ], + ), + struct( + class_name = "PIDController", + yml_file = "semiwrap/controls/PIDController.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/PIDController.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::PIDController", "wpi__math__PIDController.hpp"), + ], + ), + struct( + class_name = "ProfiledPIDController", + yml_file = "semiwrap/controls/ProfiledPIDController.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/ProfiledPIDController.hpp", + tmpl_class_names = [ + ("ProfiledPIDController_tmpl1", "ProfiledPIDController"), + ("ProfiledPIDController_tmpl2", "ProfiledPIDControllerRadians"), + ], + trampolines = [ + ("wpi::math::ProfiledPIDController", "wpi__math__ProfiledPIDController.hpp"), + ], + ), + struct( + class_name = "SimpleMotorFeedforward", + yml_file = "semiwrap/controls/SimpleMotorFeedforward.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/controller/SimpleMotorFeedforward.hpp", + tmpl_class_names = [ + ("SimpleMotorFeedforward_tmpl1", "SimpleMotorFeedforwardMeters"), + ("SimpleMotorFeedforward_tmpl2", "SimpleMotorFeedforwardRadians"), + ], + trampolines = [ + ("wpi::math::SimpleMotorFeedforward", "wpi__math__SimpleMotorFeedforward.hpp"), + ], + ), + struct( + class_name = "DifferentialDrivePoseEstimator", + yml_file = "semiwrap/controls/DifferentialDrivePoseEstimator.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/DifferentialDrivePoseEstimator.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDrivePoseEstimator", "wpi__math__DifferentialDrivePoseEstimator.hpp"), + ], + ), + struct( + class_name = "DifferentialDrivePoseEstimator3d", + yml_file = "semiwrap/controls/DifferentialDrivePoseEstimator3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/DifferentialDrivePoseEstimator3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDrivePoseEstimator3d", "wpi__math__DifferentialDrivePoseEstimator3d.hpp"), + ], + ), + struct( + class_name = "ExtendedKalmanFilter", + yml_file = "semiwrap/controls/ExtendedKalmanFilter.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/ExtendedKalmanFilter.hpp", + tmpl_class_names = [ + ("ExtendedKalmanFilter_tmpl1", "ExtendedKalmanFilter_1_1_1"), + ("ExtendedKalmanFilter_tmpl2", "ExtendedKalmanFilter_2_1_1"), + ("ExtendedKalmanFilter_tmpl3", "ExtendedKalmanFilter_2_1_2"), + ("ExtendedKalmanFilter_tmpl4", "ExtendedKalmanFilter_2_2_2"), + ], + trampolines = [ + ("wpi::math::ExtendedKalmanFilter", "wpi__math__ExtendedKalmanFilter.hpp"), + ], + ), + struct( + class_name = "KalmanFilter", + yml_file = "semiwrap/controls/KalmanFilter.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/KalmanFilter.hpp", + tmpl_class_names = [ + ("KalmanFilter_tmpl1", "KalmanFilter_1_1_1"), + ("KalmanFilter_tmpl2", "KalmanFilter_2_1_1"), + ("KalmanFilter_tmpl3", "KalmanFilter_2_1_2"), + ("KalmanFilter_tmpl4", "KalmanFilter_2_2_2"), + ("KalmanFilter_tmpl5", "KalmanFilter_3_2_3"), + ], + trampolines = [ + ("wpi::math::KalmanFilter", "wpi__math__KalmanFilter.hpp"), + ], + ), + struct( + class_name = "MecanumDrivePoseEstimator", + yml_file = "semiwrap/controls/MecanumDrivePoseEstimator.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/MecanumDrivePoseEstimator.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDrivePoseEstimator", "wpi__math__MecanumDrivePoseEstimator.hpp"), + ], + ), + struct( + class_name = "MecanumDrivePoseEstimator3d", + yml_file = "semiwrap/controls/MecanumDrivePoseEstimator3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/MecanumDrivePoseEstimator3d.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDrivePoseEstimator3d", "wpi__math__MecanumDrivePoseEstimator3d.hpp"), + ], + ), + struct( + class_name = "PoseEstimator", + yml_file = "semiwrap/controls/PoseEstimator.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/PoseEstimator.hpp", + tmpl_class_names = [ + ("PoseEstimator_tmpl1", "DifferentialDrivePoseEstimatorBase"), + ("PoseEstimator_tmpl2", "MecanumDrivePoseEstimatorBase"), + ("PoseEstimator_tmpl3", "SwerveDrive2PoseEstimatorBase"), + ("PoseEstimator_tmpl4", "SwerveDrive3PoseEstimatorBase"), + ("PoseEstimator_tmpl5", "SwerveDrive4PoseEstimatorBase"), + ("PoseEstimator_tmpl6", "SwerveDrive6PoseEstimatorBase"), + ], + trampolines = [ + ("wpi::math::PoseEstimator", "wpi__math__PoseEstimator.hpp"), + ], + ), + struct( + class_name = "PoseEstimator3d", + yml_file = "semiwrap/controls/PoseEstimator3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/PoseEstimator3d.hpp", + tmpl_class_names = [ + ("PoseEstimator3d_tmpl1", "DifferentialDrivePoseEstimator3dBase"), + ("PoseEstimator3d_tmpl2", "MecanumDrivePoseEstimator3dBase"), + ("PoseEstimator3d_tmpl3", "SwerveDrive2PoseEstimator3dBase"), + ("PoseEstimator3d_tmpl4", "SwerveDrive3PoseEstimator3dBase"), + ("PoseEstimator3d_tmpl5", "SwerveDrive4PoseEstimator3dBase"), + ("PoseEstimator3d_tmpl6", "SwerveDrive6PoseEstimator3dBase"), + ], + trampolines = [ + ("wpi::math::PoseEstimator3d", "wpi__math__PoseEstimator3d.hpp"), + ], + ), + struct( + class_name = "SwerveDrivePoseEstimator", + yml_file = "semiwrap/controls/SwerveDrivePoseEstimator.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/SwerveDrivePoseEstimator.hpp", + tmpl_class_names = [ + ("SwerveDrivePoseEstimator_tmpl1", "SwerveDrive2PoseEstimator"), + ("SwerveDrivePoseEstimator_tmpl2", "SwerveDrive3PoseEstimator"), + ("SwerveDrivePoseEstimator_tmpl3", "SwerveDrive4PoseEstimator"), + ("SwerveDrivePoseEstimator_tmpl4", "SwerveDrive6PoseEstimator"), + ], + trampolines = [ + ("wpi::math::SwerveDrivePoseEstimator", "wpi__math__SwerveDrivePoseEstimator.hpp"), + ], + ), + struct( + class_name = "SwerveDrivePoseEstimator3d", + yml_file = "semiwrap/controls/SwerveDrivePoseEstimator3d.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/estimator/SwerveDrivePoseEstimator3d.hpp", + tmpl_class_names = [ + ("SwerveDrivePoseEstimator3d_tmpl1", "SwerveDrive2PoseEstimator3d"), + ("SwerveDrivePoseEstimator3d_tmpl2", "SwerveDrive3PoseEstimator3d"), + ("SwerveDrivePoseEstimator3d_tmpl3", "SwerveDrive4PoseEstimator3d"), + ("SwerveDrivePoseEstimator3d_tmpl4", "SwerveDrive6PoseEstimator3d"), + ], + trampolines = [ + ("wpi::math::SwerveDrivePoseEstimator3d", "wpi__math__SwerveDrivePoseEstimator3d.hpp"), + ], + ), + struct( + class_name = "SimulatedAnnealing", + yml_file = "semiwrap/controls/SimulatedAnnealing.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/optimization/SimulatedAnnealing.hpp", + tmpl_class_names = [ + ("SimulatedAnnealing_tmpl1", "SimulatedAnnealing"), + ], + trampolines = [ + ("wpi::math::SimulatedAnnealing", "wpi__math__SimulatedAnnealing.hpp"), + ], + ), + struct( + class_name = "TravelingSalesman", + yml_file = "semiwrap/controls/TravelingSalesman.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/path/TravelingSalesman.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::TravelingSalesman", "wpi__math__TravelingSalesman.hpp"), + ], + ), + struct( + class_name = "LinearSystem", + yml_file = "semiwrap/controls/LinearSystem.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/system/LinearSystem.hpp", + tmpl_class_names = [ + ("LinearSystem_tmpl1", "LinearSystem_1_1_1"), + ("LinearSystem_tmpl2", "LinearSystem_1_1_2"), + ("LinearSystem_tmpl3", "LinearSystem_1_1_3"), + ("LinearSystem_tmpl4", "LinearSystem_2_1_1"), + ("LinearSystem_tmpl5", "LinearSystem_2_1_2"), + ("LinearSystem_tmpl6", "LinearSystem_2_1_3"), + ("LinearSystem_tmpl7", "LinearSystem_2_2_1"), + ("LinearSystem_tmpl8", "LinearSystem_2_2_2"), + ("LinearSystem_tmpl9", "LinearSystem_2_2_3"), + ("LinearSystem_tmpl10", "LinearSystem_3_2_1"), + ("LinearSystem_tmpl11", "LinearSystem_3_2_2"), + ("LinearSystem_tmpl12", "LinearSystem_3_2_3"), + ], + trampolines = [ + ("wpi::math::LinearSystem", "wpi__math__LinearSystem.hpp"), + ], + ), + struct( + class_name = "LinearSystemLoop", + yml_file = "semiwrap/controls/LinearSystemLoop.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/system/LinearSystemLoop.hpp", + tmpl_class_names = [ + ("LinearSystemLoop_tmpl1", "LinearSystemLoop_1_1_1"), + ("LinearSystemLoop_tmpl2", "LinearSystemLoop_2_1_1"), + ("LinearSystemLoop_tmpl3", "LinearSystemLoop_2_1_2"), + ("LinearSystemLoop_tmpl4", "LinearSystemLoop_2_2_2"), + ("LinearSystemLoop_tmpl5", "LinearSystemLoop_3_2_3"), + ], + trampolines = [ + ("wpi::math::LinearSystemLoop", "wpi__math__LinearSystemLoop.hpp"), + ], + ), + struct( + class_name = "DCMotor", + yml_file = "semiwrap/controls/DCMotor.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/system/plant/DCMotor.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DCMotor", "wpi__math__DCMotor.hpp"), + ], + ), + struct( + class_name = "LinearSystemId", + yml_file = "semiwrap/controls/LinearSystemId.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/system/plant/LinearSystemId.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::LinearSystemId", "wpi__math__LinearSystemId.hpp"), + ], + ), + struct( + class_name = "ExponentialProfile", + yml_file = "semiwrap/controls/ExponentialProfile.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/ExponentialProfile.hpp", + tmpl_class_names = [ + ("ExponentialProfile_tmpl1", "ExponentialProfileMeterVolts"), + ], + trampolines = [ + ("wpi::math::ExponentialProfile", "wpi__math__ExponentialProfile.hpp"), + ("wpi::math::ExponentialProfile::Constraints", "wpi__math__ExponentialProfile__Constraints.hpp"), + ("wpi::math::ExponentialProfile::State", "wpi__math__ExponentialProfile__State.hpp"), + ("wpi::math::ExponentialProfile::ProfileTiming", "wpi__math__ExponentialProfile__ProfileTiming.hpp"), + ], + ), + struct( + class_name = "Trajectory", + yml_file = "semiwrap/controls/Trajectory.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/Trajectory.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::Trajectory", "wpi__math__Trajectory.hpp"), + ("wpi::math::Trajectory::State", "wpi__math__Trajectory__State.hpp"), + ], + ), + struct( + class_name = "TrajectoryConfig", + yml_file = "semiwrap/controls/TrajectoryConfig.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/TrajectoryConfig.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::TrajectoryConfig", "wpi__math__TrajectoryConfig.hpp"), + ], + ), + struct( + class_name = "TrajectoryGenerator", + yml_file = "semiwrap/controls/TrajectoryGenerator.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/TrajectoryGenerator.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::TrajectoryGenerator", "wpi__math__TrajectoryGenerator.hpp"), + ], + ), + struct( + class_name = "TrajectoryParameterizer", + yml_file = "semiwrap/controls/TrajectoryParameterizer.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/TrajectoryParameterizer.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::TrajectoryParameterizer", "wpi__math__TrajectoryParameterizer.hpp"), + ], + ), + struct( + class_name = "TrapezoidProfile", + yml_file = "semiwrap/controls/TrapezoidProfile.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/TrapezoidProfile.hpp", + tmpl_class_names = [ + ("TrapezoidProfile_tmpl1", "TrapezoidProfile"), + ("TrapezoidProfile_tmpl2", "TrapezoidProfileRadians"), + ], + trampolines = [ + ("wpi::math::TrapezoidProfile", "wpi__math__TrapezoidProfile.hpp"), + ("wpi::math::TrapezoidProfile::Constraints", "wpi__math__TrapezoidProfile__Constraints.hpp"), + ("wpi::math::TrapezoidProfile::State", "wpi__math__TrapezoidProfile__State.hpp"), + ], + ), + struct( + class_name = "CentripetalAccelerationConstraint", + yml_file = "semiwrap/controls/CentripetalAccelerationConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/CentripetalAccelerationConstraint.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::CentripetalAccelerationConstraint", "wpi__math__CentripetalAccelerationConstraint.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveKinematicsConstraint", + yml_file = "semiwrap/controls/DifferentialDriveKinematicsConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/DifferentialDriveKinematicsConstraint.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveKinematicsConstraint", "wpi__math__DifferentialDriveKinematicsConstraint.hpp"), + ], + ), + struct( + class_name = "DifferentialDriveVoltageConstraint", + yml_file = "semiwrap/controls/DifferentialDriveVoltageConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/DifferentialDriveVoltageConstraint.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::DifferentialDriveVoltageConstraint", "wpi__math__DifferentialDriveVoltageConstraint.hpp"), + ], + ), + struct( + class_name = "EllipticalRegionConstraint", + yml_file = "semiwrap/controls/EllipticalRegionConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/EllipticalRegionConstraint.hpp", + tmpl_class_names = [ + ("EllipticalRegionConstraint_tmpl1", "EllipticalRegionConstraint"), + ], + trampolines = [ + ("wpi::math::EllipticalRegionConstraint", "wpi__math__EllipticalRegionConstraint.hpp"), + ], + ), + struct( + class_name = "MaxVelocityConstraint", + yml_file = "semiwrap/controls/MaxVelocityConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/MaxVelocityConstraint.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MaxVelocityConstraint", "wpi__math__MaxVelocityConstraint.hpp"), + ], + ), + struct( + class_name = "MecanumDriveKinematicsConstraint", + yml_file = "semiwrap/controls/MecanumDriveKinematicsConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/MecanumDriveKinematicsConstraint.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::MecanumDriveKinematicsConstraint", "wpi__math__MecanumDriveKinematicsConstraint.hpp"), + ], + ), + struct( + class_name = "RectangularRegionConstraint", + yml_file = "semiwrap/controls/RectangularRegionConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/RectangularRegionConstraint.hpp", + tmpl_class_names = [ + ("RectangularRegionConstraint_tmpl1", "RectangularRegionConstraint"), + ], + trampolines = [ + ("wpi::math::RectangularRegionConstraint", "wpi__math__RectangularRegionConstraint.hpp"), + ], + ), + struct( + class_name = "SwerveDriveKinematicsConstraint", + yml_file = "semiwrap/controls/SwerveDriveKinematicsConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/SwerveDriveKinematicsConstraint.hpp", + tmpl_class_names = [ + ("SwerveDriveKinematicsConstraint_tmpl1", "SwerveDrive2KinematicsConstraint"), + ("SwerveDriveKinematicsConstraint_tmpl2", "SwerveDrive3KinematicsConstraint"), + ("SwerveDriveKinematicsConstraint_tmpl3", "SwerveDrive4KinematicsConstraint"), + ("SwerveDriveKinematicsConstraint_tmpl4", "SwerveDrive6KinematicsConstraint"), + ], + trampolines = [ + ("wpi::math::SwerveDriveKinematicsConstraint", "wpi__math__SwerveDriveKinematicsConstraint.hpp"), + ], + ), + struct( + class_name = "TrajectoryConstraint", + yml_file = "semiwrap/controls/TrajectoryConstraint.yml", + header_root = "$(execpath :robotpy-native-wpimath.copy_headers)", + header_file = "$(execpath :robotpy-native-wpimath.copy_headers)/wpi/math/trajectory/constraint/TrajectoryConstraint.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::math::TrajectoryConstraint", "wpi__math__TrajectoryConstraint.hpp"), + ("wpi::math::TrajectoryConstraint::MinMax", "wpi__math__TrajectoryConstraint__MinMax.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpimath_controls.resolve_casters", + caster_deps = ["//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json", ":src/main/python/wpimath/wpimath-casters.pybind11.json"], + casters_pkl_file = "wpimath_controls.casters.pkl", + dep_file = "wpimath_controls.casters.d", + ) + + gen_libinit( + name = "wpimath_controls.gen_lib_init", + output_file = "src/main/python/wpimath/_controls/_init__controls.py", + modules = ["native.wpimath._init_robotpy_native_wpimath", "wpimath._init__wpimath", "wpimath.geometry._init__geometry", "wpimath.kinematics._init__kinematics", "wpimath.spline._init__spline"], + ) + + gen_pkgconf( + name = "wpimath_controls.gen_pkgconf", + libinit_py = "wpimath._controls._init__controls", + module_pkg_name = "wpimath._controls._controls", + output_file = "wpimath_controls.pc", + pkg_name = "wpimath_controls", + install_path = "src/main/python/wpimath/_controls", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath_controls.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_CONTROLS_HEADER_GEN], + libname = "_controls", + output_file = "semiwrap_init.wpimath._controls._controls.hpp", + ) + + run_header_gen( + name = "wpimath_controls", + casters_pickle = "wpimath_controls.casters.pkl", + header_gen_config = WPIMATH_CONTROLS_HEADER_GEN, + trampoline_subpath = "src/main/python/wpimath/_controls", + deps = header_to_dat_deps, + local_native_libraries = [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + ) + + create_pybind_library( + name = "wpimath_controls", + install_path = "src/main/python/wpimath/_controls/", + extension_name = "_controls", + generated_srcs = [":wpimath_controls.generated_srcs"], + semiwrap_header = [":wpimath_controls.gen_modinit_hpp"], + deps = [ + ":wpimath_controls.tmpl_hdrs", + ":wpimath_controls.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath-casters", + "//wpimath:wpimath_geometry_pybind_library", + "//wpimath:wpimath_kinematics_pybind_library", + "//wpimath:wpimath_pybind_library", + "//wpimath:wpimath_spline_pybind_library", + "//wpiutil:wpiutil", + "//wpiutil:wpiutil_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + "//wpiutil:shared/wpiutil", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath_controls.generated_files", + srcs = [ + "wpimath_controls.gen_modinit_hpp.gen", + "wpimath_controls.header_gen_files", + "wpimath_controls.gen_pkgconf", + "wpimath_controls.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def publish_library_casters(): + publish_casters( + name = "publish_casters", + caster_name = "wpimath-casters", + output_json = "src/main/python/wpimath/wpimath-casters.pybind11.json", + output_pc = "src/main/python/wpimath/wpimath-casters.pc", + project_config = "src/main/python/pyproject.toml", + package_root = "src/main/python/wpimath/__init__.py", + typecasters_srcs = native.glob(["src/main/python/wpimath/_impl/src/**", "src/main/python/wpimath/_impl/src/type_casters/**"]), + ) + + cc_library( + name = "wpimath-casters", + hdrs = native.glob(["src/main/python/wpimath/_impl/src/*.h", "src/main/python/wpimath/_impl/src/type_casters/*.h"]), + includes = ["src/main/python/wpimath/_impl/src", "src/main/python/wpimath/_impl/src/type_casters"], + visibility = ["//visibility:public"], + tags = ["robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "wpimath.generated_files", + "wpimath_filter.generated_files", + "wpimath_geometry.generated_files", + "wpimath_interpolation.generated_files", + "wpimath_kinematics.generated_files", + "wpimath_spline.generated_files", + "wpimath_controls.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/wpimath/wpimath.pc", + "src/main/python/wpimath/filter/wpimath_filter.pc", + "src/main/python/wpimath/geometry/wpimath_geometry.pc", + "src/main/python/wpimath/interpolation/wpimath_interpolation.pc", + "src/main/python/wpimath/kinematics/wpimath_kinematics.pc", + "src/main/python/wpimath/spline/wpimath_spline.pc", + "src/main/python/wpimath/_controls/wpimath_controls.pc", + "src/main/python/wpimath/wpimath-casters.pc", + "src/main/python/wpimath/wpimath-casters.pybind11.json", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/wpimath/**"], exclude = ["src/main/python/wpimath/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/wpimath/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/wpimath/**/*.py"]) + [ + "src/main/python/wpimath/_init__wpimath.py", + "src/main/python/wpimath/filter/_init__filter.py", + "src/main/python/wpimath/geometry/_init__geometry.py", + "src/main/python/wpimath/interpolation/_init__interpolation.py", + "src/main/python/wpimath/kinematics/_init__kinematics.py", + "src/main/python/wpimath/spline/_init__spline.py", + "src/main/python/wpimath/_controls/_init__controls.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/wpimath/_wpimath", + ":src/main/python/wpimath/filter/_filter", + ":src/main/python/wpimath/geometry/_geometry", + ":src/main/python/wpimath/interpolation/_interpolation", + ":src/main/python/wpimath/kinematics/_kinematics", + ":src/main/python/wpimath/spline/_spline", + ":src/main/python/wpimath/_controls/_controls", + ":wpimath.trampoline_hdr_files", + ":wpimath_filter.trampoline_hdr_files", + ":wpimath_geometry.trampoline_hdr_files", + ":wpimath_interpolation.trampoline_hdr_files", + ":wpimath_kinematics.trampoline_hdr_files", + ":wpimath_spline.trampoline_hdr_files", + ":wpimath_controls.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//wpimath:robotpy-native-wpimath", + "//wpiutil:robotpy-wpiutil", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + ], + package_root_file = "src/main/python/wpimath/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//wpimath:robotpy-native-wpimath.copy_headers", + ], + package_root_file = "src/main/python/wpimath/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + ) diff --git a/wpimath/robotpy_pybind_test_info.bzl b/wpimath/robotpy_pybind_test_info.bzl new file mode 100644 index 0000000000..0b324c84a7 --- /dev/null +++ b/wpimath/robotpy_pybind_test_info.bzl @@ -0,0 +1,157 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def wpimath_test_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + WPIMATH_TEST_HEADER_GEN = [ + struct( + class_name = "module", + yml_file = "semiwrap/module.yml", + header_root = "wpimath/src/test/python/cpp/wpimath_test/include", + header_file = "wpimath/src/test/python/cpp/wpimath_test/include/module.h", + tmpl_class_names = [], + trampolines = [ + ("SomeClass", "__SomeClass.hpp"), + ], + ), + ] + + resolve_casters( + name = "wpimath_test.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "wpimath_test.casters.pkl", + dep_file = "wpimath_test.casters.d", + ) + + gen_libinit( + name = "wpimath_test.gen_lib_init", + output_file = "src/test/python/cpp/wpimath_test/_init__wpimath_test.py", + modules = ["wpimath._init__wpimath"], + ) + + gen_pkgconf( + name = "wpimath_test.gen_pkgconf", + libinit_py = "wpimath_test._init__wpimath_test", + module_pkg_name = "wpimath_test._wpimath_test", + output_file = "wpimath_test.pc", + pkg_name = "wpimath_test", + install_path = "src/test/python/cpp/wpimath_test", + project_file = "src/test/python/cpp/pyproject.toml", + package_root = "src/test/python/cpp/wpimath_test/__init__.py", + ) + + gen_modinit_hpp( + name = "wpimath_test.gen_modinit_hpp", + input_dats = [x.class_name for x in WPIMATH_TEST_HEADER_GEN], + libname = "_wpimath_test", + output_file = "semiwrap_init.wpimath_test._wpimath_test.hpp", + ) + + run_header_gen( + name = "wpimath_test", + casters_pickle = "wpimath_test.casters.pkl", + header_gen_config = WPIMATH_TEST_HEADER_GEN, + trampoline_subpath = "src/test/python/cpp/wpimath_test", + deps = header_to_dat_deps, + local_native_libraries = [ + ], + yml_prefix = "src/test/python/cpp/", + ) + + create_pybind_library( + name = "wpimath_test", + install_path = "src/test/python/cpp/wpimath_test/", + extension_name = "_wpimath_test", + generated_srcs = [":wpimath_test.generated_srcs"], + semiwrap_header = [":wpimath_test.gen_modinit_hpp"], + deps = [ + ":wpimath_test.tmpl_hdrs", + ":wpimath_test.trampoline_hdrs", + "//wpimath:wpimath", + "//wpimath:wpimath_pybind_library", + ], + dynamic_deps = [ + "//wpimath:shared/wpimath", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "wpimath_test.generated_files", + srcs = [ + "wpimath_test.gen_modinit_hpp.gen", + "wpimath_test.header_gen_files", + "wpimath_test.gen_pkgconf", + "wpimath_test.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "wpimath_test.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/test/python/cpp/wpimath_test/wpimath_test.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/test/python/cpp/wpimath_test/**"], exclude = ["src/test/python/cpp/wpimath_test/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/test/python/cpp/wpimath_test/**/*.py"]) + [ + "src/test/python/cpp/wpimath_test/_init__wpimath_test.py", + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/test/python/cpp/wpimath_test/_wpimath_test", + ":wpimath_test.trampoline_hdr_files", + ], + imports = ["src/test/python/cpp"], + deps = [ + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/test/python/cpp/semiwrap", + extra_hdrs = native.glob(["src/test/python/cpp/**/*.h"], allow_empty = True) + [ + ], + package_root_file = "src/test/python/cpp/wpimath_test/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/test/python/cpp/pyproject.toml", + yaml_files = native.glob(["src/test/python/cpp/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/test/python/cpp/**/*.h"], allow_empty = True) + [ + ], + package_root_file = "src/test/python/cpp/wpimath_test/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/test/python/cpp/pyproject.toml", + ) diff --git a/wpimath/src/main/python/pyproject.toml b/wpimath/src/main/python/pyproject.toml index e58f426316..3a36a798a0 100644 --- a/wpimath/src/main/python/pyproject.toml +++ b/wpimath/src/main/python/pyproject.toml @@ -83,10 +83,10 @@ scan_headers_ignore = [ "wpi/math/proto/*", "wpi/math/*/proto/*", - + "wpi/math/struct/*", "wpi/math/*/struct/*", - + "[eE]igen/*", "gcem.hpp", @@ -95,9 +95,7 @@ scan_headers_ignore = [ "gch/*", "sleipnir/*", "type_casters/*", - "unsupported/*", "wpi/units/*", - "wpimath/protobuf/*", "wpi/math/util/MathShared.hpp", @@ -1491,7 +1489,7 @@ includes = ["wpimath/geometry/include"] yaml_path = "semiwrap/geometry" [tool.semiwrap.extension_modules."wpimath.geometry._geometry".headers] -# frc/geometry +# wpi/math/geometry CoordinateAxis = "wpi/math/geometry/CoordinateAxis.hpp" CoordinateSystem = "wpi/math/geometry/CoordinateSystem.hpp" Ellipse2d = "wpi/math/geometry/Ellipse2d.hpp" @@ -1515,7 +1513,7 @@ depends = ["wpimath_geometry"] yaml_path = "semiwrap/interpolation" [tool.semiwrap.extension_modules."wpimath.interpolation._interpolation".headers] -# frc/interpolation +# wpi/math/interpolation TimeInterpolatableBuffer = "wpi/math/interpolation/TimeInterpolatableBuffer.hpp" @@ -1526,7 +1524,7 @@ depends = ["wpimath_geometry"] yaml_path = "semiwrap/kinematics" [tool.semiwrap.extension_modules."wpimath.kinematics._kinematics".headers] -# frc/kinematics +# wpi/math/kinematics ChassisSpeeds = "wpi/math/kinematics/ChassisSpeeds.hpp" DifferentialDriveKinematics = "wpi/math/kinematics/DifferentialDriveKinematics.hpp" DifferentialDriveOdometry3d = "wpi/math/kinematics/DifferentialDriveOdometry3d.hpp" @@ -1555,7 +1553,7 @@ depends = ["wpimath_geometry"] yaml_path = "semiwrap/spline" [tool.semiwrap.extension_modules."wpimath.spline._spline".headers] -# frc/spline +# wpi/math/spline CubicHermiteSpline = "wpi/math/spline/CubicHermiteSpline.hpp" QuinticHermiteSpline = "wpi/math/spline/QuinticHermiteSpline.hpp" Spline = "wpi/math/spline/Spline.hpp" @@ -1570,7 +1568,7 @@ depends = ["wpimath", "wpimath_geometry", "wpimath_kinematics", "wpimath_spline" yaml_path = "semiwrap/controls" [tool.semiwrap.extension_modules."wpimath._controls._controls".headers] -# frc/controller +# wpi/math/controller ArmFeedforward = "wpi/math/controller/ArmFeedforward.hpp" BangBangController = "wpi/math/controller/BangBangController.hpp" ControlAffinePlantInversionFeedforward = "wpi/math/controller/ControlAffinePlantInversionFeedforward.hpp" @@ -1587,7 +1585,7 @@ PIDController = "wpi/math/controller/PIDController.hpp" ProfiledPIDController = "wpi/math/controller/ProfiledPIDController.hpp" SimpleMotorFeedforward = "wpi/math/controller/SimpleMotorFeedforward.hpp" -# frc/estimator +# wpi/math/estimator # AngleStatistics = "wpi/math/estimator/AngleStatistics.hpp" DifferentialDrivePoseEstimator = "wpi/math/estimator/DifferentialDrivePoseEstimator.hpp" DifferentialDrivePoseEstimator3d = "wpi/math/estimator/DifferentialDrivePoseEstimator3d.hpp" @@ -1604,24 +1602,24 @@ SwerveDrivePoseEstimator3d = "wpi/math/estimator/SwerveDrivePoseEstimator3d.hpp" # UnscentedKalmanFilter = "wpi/math/estimator/UnscentedKalmanFilter.hpp" # UnscentedTransform = "wpi/math/estimator/UnscentedTransform.hpp" -# frc/optimization +# wpi/math/optimization SimulatedAnnealing = "wpi/math/optimization/SimulatedAnnealing.hpp" -# frc/path +# wpi/math/path TravelingSalesman = "wpi/math/path/TravelingSalesman.hpp" -# frc/system +# wpi/math/system # Discretization = "wpi/math/system/Discretization.hpp" LinearSystem = "wpi/math/system/LinearSystem.hpp" LinearSystemLoop = "wpi/math/system/LinearSystemLoop.hpp" # NumericalIntegration = "wpi/math/system/NumericalIntegration.hpp" # NumericalJacobian = "wpi/math/system/NumericalJacobian.hpp" -# frc/system/plant +# wpi/math/system/plant DCMotor = "wpi/math/system/plant/DCMotor.hpp" LinearSystemId = "wpi/math/system/plant/LinearSystemId.hpp" -# frc/trajectory +# wpi/math/trajectory ExponentialProfile = "wpi/math/trajectory/ExponentialProfile.hpp" Trajectory = "wpi/math/trajectory/Trajectory.hpp" TrajectoryConfig = "wpi/math/trajectory/TrajectoryConfig.hpp" @@ -1629,7 +1627,7 @@ TrajectoryGenerator = "wpi/math/trajectory/TrajectoryGenerator.hpp" TrajectoryParameterizer = "wpi/math/trajectory/TrajectoryParameterizer.hpp" TrapezoidProfile = "wpi/math/trajectory/TrapezoidProfile.hpp" -# frc/trajectory/constraint +# wpi/math/trajectory/constraint CentripetalAccelerationConstraint = "wpi/math/trajectory/constraint/CentripetalAccelerationConstraint.hpp" DifferentialDriveKinematicsConstraint = "wpi/math/trajectory/constraint/DifferentialDriveKinematicsConstraint.hpp" DifferentialDriveVoltageConstraint = "wpi/math/trajectory/constraint/DifferentialDriveVoltageConstraint.hpp" diff --git a/wpimath/src/test/python/cpp/wpimath_test/__init__.py b/wpimath/src/test/python/cpp/wpimath_test/__init__.py index 5dff80ff06..e904b8633e 100644 --- a/wpimath/src/test/python/cpp/wpimath_test/__init__.py +++ b/wpimath/src/test/python/cpp/wpimath_test/__init__.py @@ -1,6 +1,6 @@ from . import _init__wpimath_test -# autogenerated by 'robotpy-build create-imports wpimath_test' +# autogenerated by 'semiwrap create-imports wpimath_test wpimath_test._wpimath_test' from ._wpimath_test import SomeClass __all__ = ["SomeClass"] diff --git a/wpinet/robotpy_pybind_build_info.bzl b/wpinet/robotpy_pybind_build_info.bzl index 7a6b190cf2..bf353b4a77 100644 --- a/wpinet/robotpy_pybind_build_info.bzl +++ b/wpinet/robotpy_pybind_build_info.bzl @@ -1,5 +1,6 @@ # THIS FILE IS AUTO GENERATED +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") @@ -132,10 +133,17 @@ def define_pybind_library(name, pkgcfgs = []): tags = ["manual", "robotpy"], ) + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/wpinet/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + robotpy_library( name = name, srcs = native.glob(["src/main/python/wpinet/**/*.py"]) + [ "src/main/python/wpinet/_init__wpinet.py", + "{}.generate_version".format(name), ], data = [ "{}.generated_pkgcfg_files".format(name), @@ -156,6 +164,7 @@ def define_pybind_library(name, pkgcfgs = []): yaml_output_directory = "src/main/python/semiwrap", extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", ], package_root_file = "src/main/python/wpinet/__init__.py", pkgcfgs = pkgcfgs, diff --git a/wpiutil/robotpy_pybind_build_info.bzl b/wpiutil/robotpy_pybind_build_info.bzl index f33899fe6b..7c366273bb 100644 --- a/wpiutil/robotpy_pybind_build_info.bzl +++ b/wpiutil/robotpy_pybind_build_info.bzl @@ -1,6 +1,7 @@ # THIS FILE IS AUTO GENERATED load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "publish_casters", "resolve_casters", "run_header_gen") load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") @@ -193,10 +194,17 @@ def define_pybind_library(name, pkgcfgs = []): tags = ["manual", "robotpy"], ) + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/wpiutil/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + robotpy_library( name = name, srcs = native.glob(["src/main/python/wpiutil/**/*.py"]) + [ "src/main/python/wpiutil/_init__wpiutil.py", + "{}.generate_version".format(name), ], data = [ "{}.generated_pkgcfg_files".format(name), diff --git a/xrpVendordep/BUILD.bazel b/xrpVendordep/BUILD.bazel index 9c13c1df64..b7aef9a5ee 100644 --- a/xrpVendordep/BUILD.bazel +++ b/xrpVendordep/BUILD.bazel @@ -1,8 +1,13 @@ +load("@allwpilib_pip_deps//:requirements.bzl", "requirement") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test") load("@rules_java//java:defs.bzl", "java_binary") load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library") load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_library") load("//shared/bazel/rules:packaging.bzl", "package_minimal_cc_project") +load("//shared/bazel/rules/robotpy:build_info_gen.bzl", "generate_robotpy_native_wrapper_build_info", "generate_robotpy_pybind_build_info") +load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test") +load("//xrpVendordep:robotpy_native_build_info.bzl", "define_native_wrapper") +load("//xrpVendordep:robotpy_pybind_build_info.bzl", "define_pybind_library", "xrp_extension") filegroup( name = "doxygen-files", @@ -99,3 +104,57 @@ package_minimal_cc_project( maven_artifact_name = "xrpVendordep-cpp", maven_group_id = "org.wpilib.xrpVendordep", ) + +generate_robotpy_native_wrapper_build_info( + name = "robotpy-native-xrp-generator", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +define_native_wrapper( + name = "robotpy-native-xrp", + pyproject_toml = "src/main/python/native-pyproject.toml", +) + +PKG_CONFIG_DEPS = [ + "//datalog:native/datalog/robotpy-native-datalog.pc", + "//datalog:robotpy-wpilog.generated_pkgcfg_files", + "//hal:native/wpihal/robotpy-native-wpihal.pc", + "//hal:robotpy-hal.generated_pkgcfg_files", + "//ntcore:native/ntcore/robotpy-native-ntcore.pc", + "//ntcore:pyntcore.generated_pkgcfg_files", + "//wpilibc:native/wpilib/robotpy-native-wpilib.pc", + "//wpilibc:robotpy-wpilib.generated_pkgcfg_files", + "//wpimath:native/wpimath/robotpy-native-wpimath.pc", + "//wpimath:robotpy-wpimath.generated_pkgcfg_files", + "//wpinet:native/wpinet/robotpy-native-wpinet.pc", + "//wpinet:robotpy-wpinet.generated_pkgcfg_files", + "//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc", + "//wpiutil:robotpy-wpiutil.generated_pkgcfg_files", + "//xrpVendordep:native/xrp/robotpy-native-xrp.pc", +] + +generate_robotpy_pybind_build_info( + name = "robotpy-xrp-generator", + additional_srcs = [":robotpy-native-xrp.copy_headers"], + package_root_file = "src/main/python/xrp/__init__.py", + pkgcfgs = PKG_CONFIG_DEPS, + yaml_files = glob(["src/main/python/semiwrap/**/*.yml"]), +) + +xrp_extension( + srcs = ["src/main/python/xrp/src/main.cpp"], +) + +define_pybind_library( + name = "robotpy-xrp", + pkgcfgs = PKG_CONFIG_DEPS, +) + +robotpy_py_test( + "python_tests", + srcs = glob(["src/test/python/*.py"]), + deps = [ + ":robotpy-xrp", + requirement("pytest"), + ], +) diff --git a/xrpVendordep/robotpy_native_build_info.bzl b/xrpVendordep/robotpy_native_build_info.bzl new file mode 100644 index 0000000000..b20c6550a5 --- /dev/null +++ b/xrpVendordep/robotpy_native_build_info.bzl @@ -0,0 +1,34 @@ +# THIS FILE IS AUTO GENERATED + +load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library") + +def define_native_wrapper(name, pyproject_toml = None): + copy_to_directory( + name = "{}.copy_headers".format(name), + srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True), + out = "native/xrp/include", + root_paths = ["src/main/native/include/"], + replace_prefixes = { + "xrpVendordep/src/generated/main/native/include": "", + "xrpVendordep/src/main/native/include": "", + }, + verbose = False, + visibility = ["//visibility:public"], + ) + + native_wrappery_library( + name = name, + pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml", + libinit_file = "native/xrp/_init_robotpy_native_xrp.py", + pc_file = "native/xrp/robotpy-native-xrp.pc", + pc_deps = [ + "//wpilibc:native/wpilib/robotpy-native-wpilib.pc", + ], + deps = [ + "//wpilibc:robotpy-native-wpilib", + ], + headers = "{}.copy_headers".format(name), + native_shared_library = "shared/xrpVendordep", + install_path = "native/xrp/", + ) diff --git a/xrpVendordep/robotpy_pybind_build_info.bzl b/xrpVendordep/robotpy_pybind_build_info.bzl new file mode 100644 index 0000000000..4326daa9d6 --- /dev/null +++ b/xrpVendordep/robotpy_pybind_build_info.bzl @@ -0,0 +1,238 @@ +# THIS FILE IS AUTO GENERATED + +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library") +load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen") +load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files") + +def xrp_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = [], extra_pyi_deps = []): + XRP_HEADER_GEN = [ + struct( + class_name = "XRPGyro", + yml_file = "semiwrap/XRPGyro.yml", + header_root = "$(execpath :robotpy-native-xrp.copy_headers)", + header_file = "$(execpath :robotpy-native-xrp.copy_headers)/wpi/xrp/XRPGyro.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::xrp::XRPGyro", "wpi__xrp__XRPGyro.hpp"), + ], + ), + struct( + class_name = "XRPMotor", + yml_file = "semiwrap/XRPMotor.yml", + header_root = "$(execpath :robotpy-native-xrp.copy_headers)", + header_file = "$(execpath :robotpy-native-xrp.copy_headers)/wpi/xrp/XRPMotor.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::xrp::XRPMotor", "wpi__xrp__XRPMotor.hpp"), + ], + ), + struct( + class_name = "XRPOnBoardIO", + yml_file = "semiwrap/XRPOnBoardIO.yml", + header_root = "$(execpath :robotpy-native-xrp.copy_headers)", + header_file = "$(execpath :robotpy-native-xrp.copy_headers)/wpi/xrp/XRPOnBoardIO.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::xrp::XRPOnBoardIO", "wpi__xrp__XRPOnBoardIO.hpp"), + ], + ), + struct( + class_name = "XRPRangefinder", + yml_file = "semiwrap/XRPRangefinder.yml", + header_root = "$(execpath :robotpy-native-xrp.copy_headers)", + header_file = "$(execpath :robotpy-native-xrp.copy_headers)/wpi/xrp/XRPRangefinder.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::xrp::XRPRangefinder", "wpi__xrp__XRPRangefinder.hpp"), + ], + ), + struct( + class_name = "XRPReflectanceSensor", + yml_file = "semiwrap/XRPReflectanceSensor.yml", + header_root = "$(execpath :robotpy-native-xrp.copy_headers)", + header_file = "$(execpath :robotpy-native-xrp.copy_headers)/wpi/xrp/XRPReflectanceSensor.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::xrp::XRPReflectanceSensor", "wpi__xrp__XRPReflectanceSensor.hpp"), + ], + ), + struct( + class_name = "XRPServo", + yml_file = "semiwrap/XRPServo.yml", + header_root = "$(execpath :robotpy-native-xrp.copy_headers)", + header_file = "$(execpath :robotpy-native-xrp.copy_headers)/wpi/xrp/XRPServo.hpp", + tmpl_class_names = [], + trampolines = [ + ("wpi::xrp::XRPServo", "wpi__xrp__XRPServo.hpp"), + ], + ), + ] + + resolve_casters( + name = "xrp.resolve_casters", + caster_deps = ["//wpimath:src/main/python/wpimath/wpimath-casters.pybind11.json", "//wpiutil:src/main/python/wpiutil/wpiutil-casters.pybind11.json"], + casters_pkl_file = "xrp.casters.pkl", + dep_file = "xrp.casters.d", + ) + + gen_libinit( + name = "xrp.gen_lib_init", + output_file = "src/main/python/xrp/_init__xrp.py", + modules = ["native.xrp._init_robotpy_native_xrp", "wpilib._init__wpilib", "wpimath.geometry._init__geometry"], + ) + + gen_pkgconf( + name = "xrp.gen_pkgconf", + libinit_py = "xrp._init__xrp", + module_pkg_name = "xrp._xrp", + output_file = "xrp.pc", + pkg_name = "xrp", + install_path = "src/main/python/xrp", + project_file = "src/main/python/pyproject.toml", + package_root = "src/main/python/xrp/__init__.py", + ) + + gen_modinit_hpp( + name = "xrp.gen_modinit_hpp", + input_dats = [x.class_name for x in XRP_HEADER_GEN], + libname = "_xrp", + output_file = "semiwrap_init.xrp._xrp.hpp", + ) + + run_header_gen( + name = "xrp", + casters_pickle = "xrp.casters.pkl", + header_gen_config = XRP_HEADER_GEN, + trampoline_subpath = "src/main/python/xrp", + deps = header_to_dat_deps, + local_native_libraries = [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + "//xrpVendordep:robotpy-native-xrp.copy_headers", + ], + ) + + create_pybind_library( + name = "xrp", + install_path = "src/main/python/xrp/", + extension_name = "_xrp", + generated_srcs = [":xrp.generated_srcs"], + semiwrap_header = [":xrp.gen_modinit_hpp"], + deps = [ + ":xrp.tmpl_hdrs", + ":xrp.trampoline_hdrs", + "//wpilibc:wpilib_pybind_library", + "//wpilibc:wpilibc", + "//wpimath:wpimath", + "//wpimath:wpimath_geometry_pybind_library", + "//xrpVendordep:xrpVendordep", + ], + dynamic_deps = [ + "//wpilibc:shared/wpilibc", + "//wpimath:shared/wpimath", + "//xrpVendordep:shared/xrpVendordep", + ], + extra_hdrs = extra_hdrs, + extra_srcs = srcs, + includes = includes, + ) + + native.filegroup( + name = "xrp.generated_files", + srcs = [ + "xrp.gen_modinit_hpp.gen", + "xrp.header_gen_files", + "xrp.gen_pkgconf", + "xrp.gen_lib_init", + ], + tags = ["manual", "robotpy"], + ) + +def define_pybind_library(name, pkgcfgs = []): + # Helper used to generate all files with one target. + native.filegroup( + name = "{}.generated_files".format(name), + srcs = [ + "xrp.generated_files", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Files that will be included in the wheel as data deps + native.filegroup( + name = "{}.generated_pkgcfg_files".format(name), + srcs = [ + "src/main/python/xrp/xrp.pc", + ], + tags = ["manual", "robotpy"], + visibility = ["//visibility:public"], + ) + + # Contains all of the non-python files that need to be included in the wheel + native.filegroup( + name = "{}.extra_files".format(name), + srcs = native.glob(["src/main/python/xrp/**"], exclude = ["src/main/python/xrp/**/*.py"], allow_empty = True), + tags = ["manual", "robotpy"], + ) + + generate_version_file( + name = "{}.generate_version".format(name), + output_file = "src/main/python/xrp/version.py", + template = "//shared/bazel/rules/robotpy:version_template.in", + ) + + robotpy_library( + name = name, + srcs = native.glob(["src/main/python/xrp/**/*.py"]) + [ + "src/main/python/xrp/_init__xrp.py", + "{}.generate_version".format(name), + ], + data = [ + "{}.generated_pkgcfg_files".format(name), + "{}.extra_files".format(name), + ":src/main/python/xrp/_xrp", + ":xrp.trampoline_hdr_files", + ], + imports = ["src/main/python"], + deps = [ + "//wpilibc:robotpy-wpilib", + "//xrpVendordep:robotpy-native-xrp", + ], + visibility = ["//visibility:public"], + ) + + update_yaml_files( + name = "{}-update-yaml".format(name), + yaml_output_directory = "src/main/python/semiwrap", + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//datalog:robotpy-native-datalog.copy_headers", + "//hal:robotpy-native-wpihal.copy_headers", + "//ntcore:robotpy-native-ntcore.copy_headers", + "//wpilibc:robotpy-native-wpilib.copy_headers", + "//wpimath:robotpy-native-wpimath.copy_headers", + "//wpinet:robotpy-native-wpinet.copy_headers", + "//wpiutil:robotpy-native-wpiutil.copy_headers", + "//xrpVendordep:robotpy-native-xrp.copy_headers", + ], + package_root_file = "src/main/python/xrp/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + yaml_files = native.glob(["src/main/python/semiwrap/**"]), + ) + + scan_headers( + name = "{}-scan-headers".format(name), + extra_hdrs = native.glob(["src/main/python/**/*.h"], allow_empty = True) + [ + "//xrpVendordep:robotpy-native-xrp.copy_headers", + ], + package_root_file = "src/main/python/xrp/__init__.py", + pkgcfgs = pkgcfgs, + pyproject_toml = "src/main/python/pyproject.toml", + )