mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
[python] Improve robotpy generation (#8867)
The initial build file generation for robotpy projects was relatively naive and purpose built to get `allwpilib` compiling, without supporting all the available features. This modifies the generation scripts to be able to support multiple embedded libraries, which will be necessary for #8858, since `mrclib.so` will need to be bundled along with the hal libraries. In addition some cleanup was done to get the wheels looking more like what is in pypi.
This commit is contained in:
39
wpimath/robotpy_native_build_info.bzl
generated
39
wpimath/robotpy_native_build_info.bzl
generated
@@ -1,9 +1,11 @@
|
||||
# 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")
|
||||
load("//shared/bazel/rules/robotpy:robotpy_rules.bzl", "copy_native_file", "generate_native_files", "robotpy_library")
|
||||
|
||||
def define_native_wrapper(name, pyproject_toml = None):
|
||||
pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml"
|
||||
|
||||
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([
|
||||
@@ -22,23 +24,40 @@ def define_native_wrapper(name, pyproject_toml = None):
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
native_wrappery_library(
|
||||
libinit_files = ["native/wpimath/_init_robotpy_native_wpimath.py"]
|
||||
|
||||
generate_native_files(
|
||||
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",
|
||||
pyproject_toml = pyproject_toml,
|
||||
pc_deps = [
|
||||
"//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc",
|
||||
],
|
||||
libinit_files = libinit_files,
|
||||
pc_files = ["native/wpimath/robotpy-native-wpimath.pc"],
|
||||
)
|
||||
|
||||
copy_native_file(
|
||||
name = "wpimath",
|
||||
library = "shared/wpimath",
|
||||
base_path = "native/wpimath/",
|
||||
)
|
||||
|
||||
robotpy_library(
|
||||
name = name,
|
||||
distribution = "robotpy-native-wpimath",
|
||||
srcs = libinit_files,
|
||||
data = [
|
||||
name + ".pc_wrapper",
|
||||
":wpimath.copy_lib",
|
||||
"{}.copy_headers".format(name),
|
||||
],
|
||||
deps = [
|
||||
"//wpiutil:robotpy-native-wpiutil",
|
||||
],
|
||||
headers = "{}.copy_headers".format(name),
|
||||
native_shared_library = "shared/wpimath",
|
||||
install_path = "native/wpimath/",
|
||||
strip_path_prefixes = ["wpimath"],
|
||||
requires = ["robotpy-native-wpiutil==0.0.0"],
|
||||
summary = "WPILib Math Library",
|
||||
requires = ["robotpy-native-wpiutil==0.0.0"],
|
||||
python_requires = ">=3.11",
|
||||
strip_path_prefixes = ["wpimath"],
|
||||
entry_points = {
|
||||
"pkg_config": [
|
||||
"wpimath = native.wpimath",
|
||||
|
||||
4
wpimath/robotpy_pybind_build_info.bzl
generated
4
wpimath/robotpy_pybind_build_info.bzl
generated
@@ -2,7 +2,7 @@
|
||||
|
||||
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:robotpy_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")
|
||||
|
||||
@@ -1281,6 +1281,7 @@ def define_pybind_library(name, pkgcfgs = []):
|
||||
|
||||
robotpy_library(
|
||||
name = name,
|
||||
distribution = "robotpy-wpimath",
|
||||
srcs = native.glob(["src/main/python/wpimath/**/*.py"]) + [
|
||||
"src/main/python/wpimath/_init__wpimath.py",
|
||||
"{}.generate_version".format(name),
|
||||
@@ -1301,6 +1302,7 @@ def define_pybind_library(name, pkgcfgs = []):
|
||||
project_urls = {"Source code": "https://github.com/robotpy/mostrobotpy"},
|
||||
author_email = "RobotPy Development Team <robotpy@googlegroups.com>",
|
||||
requires = ["robotpy-native-wpimath==0.0.0", "robotpy-wpiutil==0.0.0"],
|
||||
python_requires = ">=3.11",
|
||||
entry_points = {
|
||||
"pkg_config": ["wpimath-casters = wpimath", "wpimath = wpimath"],
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# THIS FILE IS AUTO GENERATED
|
||||
|
||||
load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library")
|
||||
load("//shared/bazel/rules/robotpy:robotpy_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")
|
||||
|
||||
@@ -121,6 +121,7 @@ def define_pybind_library(name, pkgcfgs = []):
|
||||
|
||||
robotpy_library(
|
||||
name = name,
|
||||
distribution = "wpimath_test",
|
||||
srcs = native.glob(["src/test/python/cpp/wpimath_test/**/*.py"]) + [
|
||||
"src/test/python/cpp/wpimath_test/_init__wpimath_test.py",
|
||||
],
|
||||
@@ -138,6 +139,7 @@ def define_pybind_library(name, pkgcfgs = []):
|
||||
project_urls = None,
|
||||
author_email = "RobotPy Development Team <robotpy@googlegroups.com>",
|
||||
requires = None,
|
||||
python_requires = ">=3.11",
|
||||
entry_points = {
|
||||
"pkg_config": ["wpimath_test = wpimath_test"],
|
||||
},
|
||||
|
||||
@@ -11,6 +11,7 @@ requires = [
|
||||
name = "robotpy-native-wpimath"
|
||||
version = "0.0.0"
|
||||
description = "WPILib Math Library"
|
||||
requires-python = ">=3.11"
|
||||
license = "BSD-3-Clause"
|
||||
|
||||
dependencies = [
|
||||
|
||||
@@ -14,6 +14,7 @@ requires = [
|
||||
name = "robotpy-wpimath"
|
||||
version = "0.0.0"
|
||||
description = "Binary wrapper for WPILib Math library"
|
||||
requires-python = ">=3.11"
|
||||
authors = [
|
||||
{name = "RobotPy Development Team", email = "robotpy@googlegroups.com"},
|
||||
]
|
||||
|
||||
@@ -8,6 +8,7 @@ requires = [
|
||||
name = "wpimath_test"
|
||||
version = "0.1"
|
||||
description = "Test project for verifying robotpy-build behavior"
|
||||
requires-python = ">=3.11"
|
||||
authors = [
|
||||
{name = "RobotPy Development Team", email = "robotpy@googlegroups.com"},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user