2025-05-14 01:01:47 -04:00
|
|
|
load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
|
|
|
|
|
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
|
2024-12-19 01:00:40 -05:00
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
2025-07-24 09:11:09 -04:00
|
|
|
load("@rules_pkg//:mappings.bzl", "pkg_files")
|
2025-05-14 01:01:47 -04:00
|
|
|
load("@rules_python//python:defs.bzl", "py_binary")
|
2025-07-02 01:53:34 -04:00
|
|
|
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library")
|
2025-11-10 09:10:49 -08:00
|
|
|
load("//shared/bazel/rules:packaging.bzl", "package_default_cc_project")
|
2024-12-19 01:00:40 -05:00
|
|
|
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
|
2025-11-09 13:32:58 -05:00
|
|
|
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")
|
2025-05-14 01:01:47 -04:00
|
|
|
load("//wpilibc:generate.bzl", "generate_wpilibc")
|
2025-11-09 13:32:58 -05:00
|
|
|
load("//wpilibc:robotpy_native_build_info.bzl", "define_native_wrapper")
|
2025-12-31 12:06:01 -05:00
|
|
|
load("//wpilibc:robotpy_pybind_build_info.bzl", "define_pybind_library", "wpilib_extension", "wpilib_simulation_extension")
|
2025-05-14 01:01:47 -04:00
|
|
|
|
2025-08-04 22:49:47 -07:00
|
|
|
filegroup(
|
|
|
|
|
name = "doxygen-files",
|
|
|
|
|
srcs = glob([
|
|
|
|
|
"src/generated/main/native/include/**/*",
|
|
|
|
|
"src/main/native/include/**/*",
|
|
|
|
|
]),
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
)
|
|
|
|
|
|
2025-05-14 01:01:47 -04:00
|
|
|
py_binary(
|
|
|
|
|
name = "generate_hids",
|
|
|
|
|
srcs = ["generate_hids.py"],
|
2025-06-13 23:53:09 -04:00
|
|
|
target_compatible_with = select({
|
|
|
|
|
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
|
|
|
|
|
"//conditions:default": [],
|
|
|
|
|
}),
|
2025-05-14 01:01:47 -04:00
|
|
|
deps = [requirement("jinja2")],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
py_binary(
|
|
|
|
|
name = "generate_pwm_motor_controllers",
|
|
|
|
|
srcs = ["generate_pwm_motor_controllers.py"],
|
2025-06-13 23:53:09 -04:00
|
|
|
target_compatible_with = select({
|
|
|
|
|
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
|
|
|
|
|
"//conditions:default": [],
|
|
|
|
|
}),
|
2025-05-14 01:01:47 -04:00
|
|
|
deps = [requirement("jinja2")],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
py_binary(
|
|
|
|
|
name = "generate_wpilibc_py",
|
|
|
|
|
srcs = ["generate_wpilibc.py"],
|
|
|
|
|
main = "generate_wpilibc.py",
|
|
|
|
|
target_compatible_with = select({
|
|
|
|
|
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
|
|
|
|
|
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
|
|
|
|
|
"//conditions:default": [],
|
|
|
|
|
}),
|
|
|
|
|
deps = [
|
|
|
|
|
":generate_hids",
|
|
|
|
|
":generate_pwm_motor_controllers",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
filegroup(
|
|
|
|
|
name = "templates",
|
|
|
|
|
srcs = glob(["src/generate/main/native/**"]) + [
|
|
|
|
|
"//wpilibj:hid_schema",
|
|
|
|
|
"//wpilibj:pwm_schema",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
generate_wpilibc(
|
|
|
|
|
name = "generate_wpilibc",
|
|
|
|
|
)
|
2024-12-19 01:00:40 -05:00
|
|
|
|
|
|
|
|
generate_version_file(
|
|
|
|
|
name = "generate-version",
|
|
|
|
|
output_file = "WPILibVersion.cpp",
|
|
|
|
|
template = "src/generate/WPILibVersion.cpp.in",
|
|
|
|
|
)
|
|
|
|
|
|
2025-05-14 01:01:47 -04:00
|
|
|
write_source_files(
|
|
|
|
|
name = "write_wpilibc",
|
2026-04-25 14:06:02 -04:00
|
|
|
diff_args = ["-u"],
|
2025-05-14 01:01:47 -04:00
|
|
|
files = {
|
|
|
|
|
"src/generated": ":generate_wpilibc",
|
|
|
|
|
},
|
|
|
|
|
suggested_update_target = "//:write_all",
|
|
|
|
|
tags = ["pregeneration"],
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
)
|
|
|
|
|
|
2025-06-13 23:53:09 -04:00
|
|
|
third_party_cc_lib_helper(
|
|
|
|
|
name = "generated_cc",
|
|
|
|
|
include_root = "src/generated/main/native/include",
|
|
|
|
|
src_root = "src/generated/main/native/cpp",
|
2024-12-19 01:00:40 -05:00
|
|
|
)
|
|
|
|
|
|
2025-07-24 09:11:09 -04:00
|
|
|
pkg_files(
|
|
|
|
|
name = "generated_version_files_pkg",
|
|
|
|
|
srcs = [
|
|
|
|
|
":generate-version",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
2025-06-13 23:53:09 -04:00
|
|
|
wpilib_cc_library(
|
2025-06-27 19:36:12 -04:00
|
|
|
name = "wpilibc",
|
2024-12-19 01:00:40 -05:00
|
|
|
srcs = [
|
|
|
|
|
":generate-version",
|
|
|
|
|
] + glob([
|
|
|
|
|
"src/main/native/cppcs/**",
|
|
|
|
|
"src/main/native/cpp/**",
|
2025-06-13 23:53:09 -04:00
|
|
|
]),
|
2024-12-19 01:00:40 -05:00
|
|
|
hdrs = glob(["src/main/native/include/**"]),
|
2025-06-27 19:36:12 -04:00
|
|
|
copts = [
|
|
|
|
|
# TODO(austin): this needs to be different for shared vs dynamic.
|
|
|
|
|
"-DDYNAMIC_CAMERA_SERVER",
|
2025-07-31 21:04:22 -07:00
|
|
|
] + select({
|
|
|
|
|
"//shared/bazel/rules:compilation_mode_dbg": ["-DDYNAMIC_CAMERA_SERVER_DEBUG"],
|
|
|
|
|
"//conditions:default": [],
|
|
|
|
|
}),
|
2025-07-24 09:11:09 -04:00
|
|
|
extra_src_pkg_files = [
|
|
|
|
|
":generated_version_files_pkg",
|
|
|
|
|
],
|
2025-06-27 19:36:12 -04:00
|
|
|
include_license_files = True,
|
2024-12-19 01:00:40 -05:00
|
|
|
strip_include_prefix = "src/main/native/include",
|
2025-06-13 23:53:09 -04:00
|
|
|
third_party_libraries = [
|
|
|
|
|
":generated_cc",
|
|
|
|
|
],
|
2024-12-19 01:00:40 -05:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
deps = [
|
2025-06-27 19:36:12 -04:00
|
|
|
"//cameraserver:cameraserver-headers",
|
|
|
|
|
"//cscore:cscore-headers",
|
|
|
|
|
"//datalog",
|
|
|
|
|
"//hal:wpiHal",
|
|
|
|
|
"//ntcore",
|
|
|
|
|
"//ntcore:ntcore-headers",
|
|
|
|
|
"//wpimath",
|
|
|
|
|
"//wpinet",
|
|
|
|
|
"//wpiutil",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-02 01:53:34 -04:00
|
|
|
wpilib_cc_shared_library(
|
|
|
|
|
name = "shared/wpilibc",
|
|
|
|
|
dynamic_deps = [
|
|
|
|
|
"//datalog:shared/datalog",
|
|
|
|
|
"//hal:shared/wpiHal",
|
|
|
|
|
"//ntcore:shared/ntcore",
|
|
|
|
|
"//wpimath:shared/wpimath",
|
|
|
|
|
"//wpinet:shared/wpinet",
|
|
|
|
|
"//wpiutil:shared/wpiutil",
|
|
|
|
|
],
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
deps = [
|
|
|
|
|
":wpilibc",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
2025-06-27 19:36:12 -04:00
|
|
|
wpilib_cc_static_library(
|
|
|
|
|
name = "static/wpilibc",
|
|
|
|
|
static_deps = [
|
|
|
|
|
"//datalog:static/datalog",
|
|
|
|
|
"//hal:static/wpiHal",
|
|
|
|
|
"//ntcore:static/ntcore",
|
|
|
|
|
"//wpimath:static/wpimath",
|
|
|
|
|
"//wpinet:static/wpinet",
|
|
|
|
|
"//wpiutil:static/wpiutil",
|
|
|
|
|
],
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
deps = [
|
|
|
|
|
":wpilibc",
|
2024-12-19 01:00:40 -05:00
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
|
name = "test-headers",
|
|
|
|
|
testonly = True,
|
|
|
|
|
hdrs = glob(["src/test/native/include/**"]),
|
|
|
|
|
includes = ["src/test/native/include"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
|
name = "wpilibc-test",
|
|
|
|
|
size = "small",
|
|
|
|
|
srcs = glob(["src/test/native/cpp/**"]),
|
|
|
|
|
tags = [
|
|
|
|
|
"no-tsan",
|
|
|
|
|
"no-ubsan",
|
|
|
|
|
],
|
|
|
|
|
deps = [
|
|
|
|
|
":test-headers",
|
2025-06-27 19:36:12 -04:00
|
|
|
":wpilibc",
|
|
|
|
|
"//thirdparty/googletest",
|
2024-12-19 01:00:40 -05:00
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
|
name = "DevMain-Cpp",
|
|
|
|
|
srcs = ["src/dev/native/cpp/main.cpp"],
|
|
|
|
|
deps = [
|
2025-06-27 19:36:12 -04:00
|
|
|
":wpilibc",
|
2024-12-19 01:00:40 -05:00
|
|
|
],
|
|
|
|
|
)
|
2025-07-24 09:11:09 -04:00
|
|
|
|
2025-11-10 09:10:49 -08:00
|
|
|
package_default_cc_project(
|
2025-07-24 09:11:09 -04:00
|
|
|
name = "wpilibc",
|
|
|
|
|
maven_artifact_name = "wpilibc-cpp",
|
2025-11-07 20:00:38 -05:00
|
|
|
maven_group_id = "org.wpilib.wpilibc",
|
2025-07-24 09:11:09 -04:00
|
|
|
)
|
2025-11-09 13:32:58 -05:00
|
|
|
|
|
|
|
|
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",
|
2026-06-06 12:15:17 -07:00
|
|
|
"//hal:native/wpihal/robotpy-native-mrclib.pc",
|
2025-11-09 13:32:58 -05:00
|
|
|
"//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_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_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",
|
2026-03-06 02:18:37 -05:00
|
|
|
srcs = glob(["src/test/python/**/*.py"]),
|
2025-12-31 12:05:00 -05:00
|
|
|
tags = ["exclusive"],
|
2025-11-09 13:32:58 -05:00
|
|
|
deps = [
|
|
|
|
|
":robotpy-wpilib",
|
|
|
|
|
requirement("pytest"),
|
|
|
|
|
],
|
|
|
|
|
)
|