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.
424 lines
12 KiB
Python
424 lines
12 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("//shared/bazel/rules:cc_rules.bzl", "generate_def_windows", "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", "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_extension")
|
|
load("//wpimath:robotpy_pybind_test_info.bzl", "wpimath_test_extension", define_test_pybind_library = "define_pybind_library")
|
|
|
|
filegroup(
|
|
name = "doxygen-files",
|
|
srcs = glob([
|
|
"src/generated/main/native/cpp/wpimath/protobuf/*.h",
|
|
"src/main/native/include/**/*",
|
|
"src/main/native/thirdparty/gcem/include/**/*",
|
|
"src/main/native/thirdparty/sleipnir/include/**/*",
|
|
]),
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "templates",
|
|
srcs = glob(["src/generate/main/java/*.jinja"]),
|
|
)
|
|
|
|
filegroup(
|
|
name = "proto_files",
|
|
srcs = glob(["src/main/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": [],
|
|
}),
|
|
)
|
|
|
|
py_binary(
|
|
name = "generate_numbers",
|
|
srcs = ["generate_numbers.py"],
|
|
data = [":templates"],
|
|
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 = [requirement("jinja2")],
|
|
)
|
|
|
|
py_binary(
|
|
name = "generate_quickbuf",
|
|
srcs = ["generate_quickbuf.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": [],
|
|
}),
|
|
)
|
|
|
|
py_binary(
|
|
name = "generate_wpimath_py",
|
|
srcs = ["generate_wpimath.py"],
|
|
main = "generate_wpimath.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_nanopb",
|
|
":generate_numbers",
|
|
":generate_quickbuf",
|
|
],
|
|
)
|
|
|
|
generate_wpimath(
|
|
name = "generate_wpimath",
|
|
tags = ["pregeneration"],
|
|
)
|
|
|
|
write_source_files(
|
|
name = "write_wpimath",
|
|
diff_args = ["-u"],
|
|
files = {
|
|
"src/generated": ":generate_wpimath",
|
|
},
|
|
suggested_update_target = "//:write_all",
|
|
tags = ["pregeneration"],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "generated_java",
|
|
srcs = glob(["src/generated/main/java/**/*.java"]),
|
|
)
|
|
|
|
alias(
|
|
name = "eigen-headers",
|
|
actual = "@eigen",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
pkg_files_headers(
|
|
name = "eigen-hdrs-pkg",
|
|
dep = "@eigen",
|
|
)
|
|
|
|
third_party_cc_lib_helper(
|
|
name = "gcem",
|
|
include_root = "src/main/native/thirdparty/gcem/include",
|
|
)
|
|
|
|
third_party_cc_lib_helper(
|
|
name = "sleipnir",
|
|
include_root = "src/main/native/thirdparty/sleipnir/include",
|
|
src_root = "src/main/native/thirdparty/sleipnir/src",
|
|
)
|
|
|
|
cc_library(
|
|
name = "nanopb-generated-headers",
|
|
hdrs = glob(["src/generated/main/native/cpp/**/*.h"]),
|
|
includes = ["src/generated/main/native/cpp"],
|
|
strip_include_prefix = "src/generated/main/native/cpp",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "protobuf_hdr_pkg",
|
|
srcs = glob(["src/generated/main/native/cpp/wpimath/protobuf/*.npb.h"]),
|
|
strip_prefix = "src/generated/main/native/cpp/",
|
|
)
|
|
|
|
wpilib_cc_library(
|
|
name = "wpimath",
|
|
srcs = glob(
|
|
[
|
|
"src/main/native/cpp/**",
|
|
"src/generated/main/native/cpp/**/*.cpp",
|
|
],
|
|
exclude = ["src/main/native/cpp/jni/**"],
|
|
),
|
|
hdrs = glob(["src/main/native/include/**"]),
|
|
extra_hdr_pkg_files = [":protobuf_hdr_pkg"],
|
|
extra_src_pkg_files = [
|
|
":wpimath-java-jni-hdrs-pkg",
|
|
],
|
|
includes = [
|
|
"src/main/native/include",
|
|
"src/main/native/thirdparty/sleipnir/src",
|
|
],
|
|
local_defines = [
|
|
"WPILIB_EXPORTS",
|
|
"SLEIPNIR_EXPORTS",
|
|
],
|
|
strip_include_prefix = "src/main/native/include",
|
|
third_party_header_only_libraries = [
|
|
":eigen",
|
|
":gcem",
|
|
],
|
|
third_party_libraries = [
|
|
":sleipnir",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":nanopb-generated-headers",
|
|
"//wpiutil",
|
|
],
|
|
)
|
|
|
|
generate_def_windows(
|
|
name = "wpimath_def",
|
|
filters = [
|
|
".pb.obj",
|
|
".npb.obj",
|
|
],
|
|
deps = [
|
|
":wpimath",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_shared_library(
|
|
name = "shared/wpimath",
|
|
auto_export_windows_symbols = False,
|
|
dynamic_deps = [
|
|
"//wpiutil:shared/wpiutil",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
win_def_file = ":wpimath_def",
|
|
deps = [
|
|
":wpimath",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_static_library(
|
|
name = "static/wpimath",
|
|
static_deps = [
|
|
"//wpiutil:static/wpiutil",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":wpimath",
|
|
],
|
|
)
|
|
|
|
wpilib_jni_cc_library(
|
|
name = "wpimathjni",
|
|
srcs = glob(["src/main/native/cpp/jni/**"]),
|
|
java_dep = ":wpimath-java",
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":wpimath",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_shared_library(
|
|
name = "shared/wpimathjni",
|
|
auto_export_windows_symbols = False,
|
|
dynamic_deps = [
|
|
":shared/wpimath",
|
|
"//wpiutil:shared/wpiutil",
|
|
],
|
|
use_debug_name = False,
|
|
visibility = ["//visibility:public"],
|
|
deps = [":wpimathjni"],
|
|
)
|
|
|
|
wpilib_jni_java_library(
|
|
name = "wpimath-java",
|
|
srcs = [":generated_java"] + glob(["src/main/java/**/*.java"]),
|
|
exported_plugins = ["//javacPlugin:plugin"],
|
|
javacopts = [
|
|
"-Xep:UnicodeInCode:OFF",
|
|
],
|
|
maven_artifact_name = "wpimath-java",
|
|
maven_group_id = "org.wpilib.wpimath",
|
|
native_libs = [":wpimathjni"],
|
|
plugins = [
|
|
"//:avaje_jsonb_generator",
|
|
],
|
|
resource_strip_prefix = "wpimath/src/main/proto",
|
|
resources = glob(["src/main/proto/**"]),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//wpiannotations",
|
|
"//wpiunits:wpiunits-java",
|
|
"//wpiutil:wpiutil-java",
|
|
"@maven//:io_avaje_avaje_json_core",
|
|
"@maven//:io_avaje_avaje_jsonb",
|
|
"@maven//:org_ejml_ejml_core",
|
|
"@maven//:org_ejml_ejml_ddense",
|
|
"@maven//:org_ejml_ejml_simple",
|
|
"@maven//:us_hebi_quickbuf_quickbuf_runtime",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "test_headers",
|
|
hdrs = glob([
|
|
"src/test/native/include/**",
|
|
]),
|
|
strip_include_prefix = "src/test/native/include",
|
|
)
|
|
|
|
cc_test(
|
|
name = "wpimath-cpp-test",
|
|
size = "small",
|
|
srcs = glob([
|
|
"src/test/native/cpp/**/*.cpp",
|
|
"src/test/native/cpp/**/*.hpp",
|
|
]),
|
|
tags = [
|
|
"no-raspi",
|
|
],
|
|
deps = [
|
|
":test_headers",
|
|
":wpimath",
|
|
"//thirdparty/googletest",
|
|
],
|
|
)
|
|
|
|
wpilib_java_junit5_test(
|
|
name = "wpimath-java-test",
|
|
srcs = glob(["src/test/java/**/*.java"]),
|
|
deps = [
|
|
":wpimath-java",
|
|
"//wpiunits:wpiunits-java",
|
|
"//wpiutil:wpiutil-java",
|
|
"@maven//:org_ejml_ejml_core",
|
|
"@maven//:org_ejml_ejml_ddense",
|
|
"@maven//:org_ejml_ejml_simple",
|
|
"@maven//:us_hebi_quickbuf_quickbuf_runtime",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "DevMain-Cpp",
|
|
srcs = ["src/dev/native/cpp/main.cpp"],
|
|
deps = [
|
|
":wpimath",
|
|
],
|
|
)
|
|
|
|
java_binary(
|
|
name = "DevMain-Java",
|
|
srcs = ["src/dev/java/org/wpilib/math/DevMain.java"],
|
|
main_class = "org.wpilib.math.DevMain",
|
|
deps = [
|
|
":wpimath-java",
|
|
],
|
|
)
|
|
|
|
py_binary(
|
|
name = "ExponentialProfileModel",
|
|
srcs = ["algorithms/ExponentialProfileModel.py"],
|
|
target_compatible_with = select({
|
|
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
|
|
"//conditions:default": [],
|
|
}),
|
|
)
|
|
|
|
package_default_jni_project(
|
|
name = "wpimath",
|
|
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"]),
|
|
)
|
|
|
|
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("numpy"),
|
|
requirement("pytest"),
|
|
],
|
|
)
|