mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
There were complaints about no patch files being created from CI when the examples pre-gen fails for people who don't build with bazel. This adds a new action step to run just the non-robotpy pregen. I also added an argument to the diff tests to make it a unified diff, which might make it easier to hand fix.
292 lines
7.8 KiB
Python
292 lines
7.8 KiB
Python
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_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",
|
|
srcs = glob([
|
|
"src/main/native/include/**/*.h",
|
|
"src/mrc/include/**/*.h",
|
|
]),
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "proto_files",
|
|
srcs = glob(["src/mrc/proto/**/*.proto"]),
|
|
)
|
|
|
|
py_binary(
|
|
name = "generate_nanopb",
|
|
srcs = ["generate_nanopb.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": [],
|
|
}),
|
|
)
|
|
|
|
generate_hal(
|
|
name = "generate_hal_files",
|
|
proto_files = ":proto_files",
|
|
)
|
|
|
|
write_source_files(
|
|
name = "write_hal",
|
|
diff_args = ["-u"],
|
|
files = {
|
|
"src/generated": ":generate_hal_files",
|
|
},
|
|
suggested_update_target = "//:write_all",
|
|
tags = ["pregeneration"],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
third_party_cc_lib_helper(
|
|
name = "mrc",
|
|
include_root = "src/mrc/include",
|
|
)
|
|
|
|
cc_library(
|
|
name = "generated_mrc_cc_headers",
|
|
hdrs = glob(["src/generated/main/native/cpp/mrc/protobuf/*.npb.h"]),
|
|
includes = ["src/generated/main/native/cpp/mrc/protobuf"],
|
|
strip_include_prefix = "src/generated/main/native/cpp/mrc/protobuf",
|
|
visibility = ["//hal:__subpackages__"],
|
|
alwayslink = True,
|
|
)
|
|
|
|
SYSTEMCORE_SRCS = glob(["src/main/native/systemcore/**"])
|
|
|
|
SIM_SRCS = glob(["src/main/native/sim/**"])
|
|
|
|
filegroup(
|
|
name = "platform-srcs",
|
|
srcs = select({
|
|
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": SYSTEMCORE_SRCS,
|
|
"//conditions:default": SIM_SRCS,
|
|
}),
|
|
)
|
|
|
|
pkg_files(
|
|
name = "hal-sim-pkg",
|
|
srcs = glob(["src/main/native/sim/**"]),
|
|
strip_prefix = "src/main/native",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "hal-systemcore-pkg",
|
|
srcs = glob(["src/main/native/systemcore/**"]),
|
|
strip_prefix = "src/main/native",
|
|
)
|
|
|
|
wpilib_cc_library(
|
|
name = "wpiHal",
|
|
srcs = [":platform-srcs"] + glob(
|
|
[
|
|
"src/main/native/cpp/**",
|
|
"src/generated/main/native/cpp/**",
|
|
],
|
|
exclude = ["src/main/native/cpp/jni/**"],
|
|
),
|
|
hdrs = glob(["src/main/native/include/**/*"]),
|
|
extra_src_pkg_files = [
|
|
":hal-sim-pkg",
|
|
":hal-systemcore-pkg",
|
|
":hal-java-jni-hdrs-pkg",
|
|
],
|
|
includes = ["src/main/native/include"],
|
|
strip_include_prefix = "src/main/native/include",
|
|
third_party_header_only_libraries = [
|
|
":mrc",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":generated_mrc_cc_headers",
|
|
"//ntcore",
|
|
"//wpinet",
|
|
"//wpiutil",
|
|
] + select({
|
|
"//conditions:default": [
|
|
"//ntcore:ntcore_c_headers",
|
|
],
|
|
}),
|
|
)
|
|
|
|
wpilib_cc_shared_library(
|
|
name = "shared/wpiHal",
|
|
dynamic_deps = [
|
|
"//ntcore:shared/ntcore",
|
|
"//wpinet:shared/wpinet",
|
|
"//wpiutil:shared/wpiutil",
|
|
] + select({
|
|
"//conditions:default": [],
|
|
}),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":wpiHal",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_static_library(
|
|
name = "static/wpiHal",
|
|
static_deps = [
|
|
"//ntcore:static/ntcore",
|
|
"//wpinet:static/wpinet",
|
|
"//wpiutil:static/wpiutil",
|
|
] + select({
|
|
"//conditions:default": [],
|
|
}),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":wpiHal",
|
|
],
|
|
)
|
|
|
|
wpilib_jni_cc_library(
|
|
name = "wpiHaljni",
|
|
srcs = glob(["src/main/native/cpp/jni/**"]),
|
|
java_dep = ":hal-java",
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":wpiHal",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_shared_library(
|
|
name = "shared/wpiHaljni",
|
|
auto_export_windows_symbols = False,
|
|
dynamic_deps = [
|
|
":shared/wpiHal",
|
|
"//wpiutil:shared/wpiutil",
|
|
],
|
|
use_debug_name = False,
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":wpiHaljni",
|
|
],
|
|
)
|
|
|
|
wpilib_jni_java_library(
|
|
name = "hal-java",
|
|
srcs = glob(["src/main/java/**/*.java"]),
|
|
maven_artifact_name = "hal-java",
|
|
maven_group_id = "org.wpilib.hal",
|
|
native_libs = [":wpiHaljni"],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//ntcore:ntcore-java",
|
|
"//wpinet:wpinet-java",
|
|
"//wpiutil:wpiutil-java",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "hal-cpp-test",
|
|
size = "small",
|
|
srcs = glob(["src/test/native/**/*.cpp"]),
|
|
deps = [
|
|
":wpiHal",
|
|
"//thirdparty/googletest",
|
|
],
|
|
)
|
|
|
|
wpilib_java_junit5_test(
|
|
name = "hal-java-test",
|
|
srcs = glob(["src/test/java/**/*.java"]),
|
|
deps = [
|
|
":hal-java",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "DevMain-Cpp",
|
|
srcs = ["src/dev/native/cpp/main.cpp"],
|
|
deps = [
|
|
":wpiHal",
|
|
],
|
|
)
|
|
|
|
java_binary(
|
|
name = "DevMain-Java",
|
|
srcs = ["src/dev/java/org/wpilib/hardware/hal/DevMain.java"],
|
|
main_class = "org.wpilib.hardware.hal.DevMain",
|
|
deps = [
|
|
],
|
|
)
|
|
|
|
package_default_jni_project(
|
|
name = "wpiHal",
|
|
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"),
|
|
],
|
|
)
|