mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
172 lines
4.4 KiB
Python
172 lines
4.4 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", "wpilib_cc_shared_library", "wpilib_cc_static_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",
|
|
srcs = [
|
|
":generate-version",
|
|
] + glob([
|
|
"src/main/native/cppcs/**",
|
|
"src/main/native/cpp/**",
|
|
]),
|
|
hdrs = glob(["src/main/native/include/**"]),
|
|
copts = [
|
|
# TODO(austin): this needs to be different for shared vs dynamic.
|
|
"-DDYNAMIC_CAMERA_SERVER",
|
|
],
|
|
include_license_files = True,
|
|
strip_include_prefix = "src/main/native/include",
|
|
third_party_libraries = [
|
|
":generated_cc",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//cameraserver:cameraserver-headers",
|
|
"//cscore:cscore-headers",
|
|
"//datalog",
|
|
"//hal:wpiHal",
|
|
"//ntcore",
|
|
"//ntcore:ntcore-headers",
|
|
"//wpimath",
|
|
"//wpinet",
|
|
"//wpiutil",
|
|
],
|
|
)
|
|
|
|
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",
|
|
],
|
|
)
|
|
|
|
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",
|
|
],
|
|
)
|
|
|
|
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",
|
|
"//thirdparty/googletest",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "DevMain-Cpp",
|
|
srcs = ["src/dev/native/cpp/main.cpp"],
|
|
deps = [
|
|
":wpilibc",
|
|
],
|
|
)
|