mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
134 lines
3.6 KiB
Python
134 lines
3.6 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_python//python:defs.bzl", "py_binary")
|
|
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library")
|
|
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
|
|
load("//wpilibc:generate.bzl", "generate_wpilibc")
|
|
|
|
py_binary(
|
|
name = "generate_hids",
|
|
srcs = ["generate_hids.py"],
|
|
target_compatible_with = select({
|
|
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
|
|
"//conditions:default": [],
|
|
}),
|
|
deps = [requirement("jinja2")],
|
|
)
|
|
|
|
py_binary(
|
|
name = "generate_pwm_motor_controllers",
|
|
srcs = ["generate_pwm_motor_controllers.py"],
|
|
target_compatible_with = select({
|
|
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
|
|
"//conditions:default": [],
|
|
}),
|
|
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",
|
|
)
|
|
|
|
generate_version_file(
|
|
name = "generate-version",
|
|
output_file = "WPILibVersion.cpp",
|
|
template = "src/generate/WPILibVersion.cpp.in",
|
|
)
|
|
|
|
write_source_files(
|
|
name = "write_wpilibc",
|
|
files = {
|
|
"src/generated": ":generate_wpilibc",
|
|
},
|
|
suggested_update_target = "//:write_all",
|
|
tags = ["pregeneration"],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
third_party_cc_lib_helper(
|
|
name = "generated_cc",
|
|
include_root = "src/generated/main/native/include",
|
|
src_root = "src/generated/main/native/cpp",
|
|
)
|
|
|
|
wpilib_cc_library(
|
|
name = "wpilibc.static",
|
|
srcs = [
|
|
":generate-version",
|
|
] + glob([
|
|
"src/main/native/cppcs/**",
|
|
"src/main/native/cpp/**",
|
|
]),
|
|
hdrs = glob(["src/main/native/include/**"]),
|
|
strip_include_prefix = "src/main/native/include",
|
|
third_party_libraries = [
|
|
":generated_cc",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//cameraserver:cameraserver.static",
|
|
"//cscore:cscore.static",
|
|
"//datalog:datalog.static",
|
|
"//hal:wpiHal.static",
|
|
"//ntcore:ntcore.static",
|
|
"//wpimath:wpimath.static",
|
|
"//wpinet:wpinet.static",
|
|
"//wpiutil:wpiutil.static",
|
|
],
|
|
)
|
|
|
|
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-asan",
|
|
"no-tsan",
|
|
"no-ubsan",
|
|
],
|
|
deps = [
|
|
":test-headers",
|
|
":wpilibc.static",
|
|
"//thirdparty/googletest:googletest.static",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "DevMain-Cpp",
|
|
srcs = ["src/dev/native/cpp/main.cpp"],
|
|
deps = [
|
|
":wpilibc.static",
|
|
],
|
|
)
|