mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
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.
221 lines
8.4 KiB
Python
Generated
221 lines
8.4 KiB
Python
Generated
# THIS FILE IS AUTO GENERATED
|
|
|
|
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
|
|
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")
|
|
|
|
def romi_extension(srcs = [], header_to_dat_deps = [], extra_hdrs = [], includes = []):
|
|
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._init__wpimath"],
|
|
)
|
|
|
|
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_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,
|
|
distribution = "robotpy-romi",
|
|
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",
|
|
"//simulation/halsim_ws_core:robotpy-halsim-ws",
|
|
"//wpilibc:robotpy-wpilib",
|
|
],
|
|
strip_path_prefixes = ["romiVendordep/src/main/python", "romiVendordep"],
|
|
summary = "Binary wrapper for WPILib Romi Vendor library",
|
|
project_urls = {"Source code": "https://github.com/robotpy/mostrobotpy"},
|
|
author_email = "RobotPy Development Team <robotpy@googlegroups.com>",
|
|
requires = ["robotpy-native-romi==0.0.0", "wpilib==0.0.0", "robotpy-halsim-ws==0.0.0"],
|
|
python_requires = ">=3.11",
|
|
entry_points = {
|
|
"pkg_config": ["romi = romi"],
|
|
"robotpy_cli.2027": ["run-romi = romi.cli:RunRomi"],
|
|
},
|
|
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",
|
|
)
|