mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
216 lines
5.4 KiB
Python
216 lines
5.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_java//java:defs.bzl", "java_binary")
|
|
load("@rules_python//python:defs.bzl", "py_binary")
|
|
load("//ntcore:generate_ntcore.bzl", "generate_ntcore")
|
|
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_minimal_jni_project")
|
|
|
|
generate_ntcore(
|
|
name = "generate_ntcore",
|
|
)
|
|
|
|
filegroup(
|
|
name = "templates",
|
|
srcs = glob([
|
|
"src/generate/**/*.jinja",
|
|
"src/generate/*.json",
|
|
]),
|
|
)
|
|
|
|
py_binary(
|
|
name = "generate_topics",
|
|
srcs = ["generate_topics.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")],
|
|
)
|
|
|
|
write_source_files(
|
|
name = "write_ntcore",
|
|
files = {
|
|
"src/generated": ":generate_ntcore",
|
|
},
|
|
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_excludes = ["src/generated/main/native/cpp/jni/**"],
|
|
src_root = "src/generated/main/native/cpp",
|
|
)
|
|
|
|
filegroup(
|
|
name = "generated_jni",
|
|
srcs = glob(["src/generated/main/native/cpp/jni/**"]),
|
|
)
|
|
|
|
filegroup(
|
|
name = "generated_java",
|
|
srcs = glob(["src/generated/main/java/**/*.java"]),
|
|
visibility = ["//ntcore:__subpackages__"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "ntcore_c_headers",
|
|
hdrs = [
|
|
"src/generated/main/native/include/ntcore_c_types.h",
|
|
"src/main/native/include/ntcore_c.h",
|
|
],
|
|
includes = [
|
|
"src/generated/main/native/include",
|
|
"src/main/native/include",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
wpilib_cc_library(
|
|
name = "ntcore",
|
|
srcs = glob(
|
|
["src/main/native/cpp/**"],
|
|
exclude = ["src/main/native/cpp/jni/**"],
|
|
),
|
|
hdrs = glob(["src/main/native/include/**/*"]),
|
|
extra_src_pkg_files = [
|
|
":ntcore-java-jni-hdrs-pkg",
|
|
],
|
|
includes = [
|
|
"src/main/native/cpp",
|
|
"src/main/native/include",
|
|
],
|
|
strip_include_prefix = "src/main/native/include",
|
|
third_party_libraries = [
|
|
":generated_cc",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//datalog",
|
|
"//wpinet",
|
|
"//wpiutil",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_shared_library(
|
|
name = "shared/ntcore",
|
|
dynamic_deps = [
|
|
"//datalog:shared/datalog",
|
|
"//wpinet:shared/wpinet",
|
|
"//wpiutil:shared/wpiutil",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":ntcore",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_static_library(
|
|
name = "static/ntcore",
|
|
static_deps = [
|
|
"//datalog:static/datalog",
|
|
"//wpinet:static/wpinet",
|
|
"//wpiutil:static/wpiutil",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":ntcore",
|
|
],
|
|
)
|
|
|
|
wpilib_jni_cc_library(
|
|
name = "ntcorejni",
|
|
srcs = glob(["src/main/native/cpp/jni/**"]) + [":generated_jni"],
|
|
java_dep = ":ntcore-java",
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":ntcore",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_shared_library(
|
|
name = "shared/ntcorejni",
|
|
auto_export_windows_symbols = False,
|
|
dynamic_deps = [
|
|
":shared/ntcore",
|
|
"//wpiutil:shared/wpiutil",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [":ntcorejni"],
|
|
)
|
|
|
|
wpilib_jni_java_library(
|
|
name = "ntcore-java",
|
|
srcs = glob(["src/main/java/**/*.java"]) + [":generated_java"],
|
|
maven_artifact_name = "ntcore-java",
|
|
maven_group_id = "edu.wpi.first.ntcore",
|
|
native_libs = [":ntcorejni"],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//datalog:datalog-java",
|
|
"//wpiutil:wpiutil-java",
|
|
"@maven//:us_hebi_quickbuf_quickbuf_runtime",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "ntcore-cpp-test",
|
|
size = "small",
|
|
srcs = glob([
|
|
"src/test/native/**/*.cpp",
|
|
"src/test/native/**/*.h",
|
|
]),
|
|
tags = [
|
|
"exclusive",
|
|
"no-asan",
|
|
"no-tsan",
|
|
],
|
|
deps = [
|
|
":ntcore",
|
|
"//thirdparty/googletest",
|
|
"//wpiutil:wpiutil-testlib",
|
|
],
|
|
)
|
|
|
|
wpilib_java_junit5_test(
|
|
name = "ntcore-java-test",
|
|
srcs = glob(["src/test/java/**/*.java"]),
|
|
tags = ["exclusive"],
|
|
deps = [
|
|
":ntcore-java",
|
|
"//wpiutil:wpiutil-java",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "DevMain-Cpp",
|
|
srcs = ["src/dev/native/cpp/main.cpp"],
|
|
deps = [
|
|
":ntcore",
|
|
],
|
|
)
|
|
|
|
java_binary(
|
|
name = "DevMain-Java",
|
|
srcs = ["src/dev/java/edu/wpi/first/ntcore/DevMain.java"],
|
|
main_class = "edu.wpi.first.ntcore.DevMain",
|
|
deps = [
|
|
"ntcore-java",
|
|
"//wpiutil:wpiutil-java",
|
|
],
|
|
)
|
|
|
|
package_minimal_jni_project(
|
|
name = "ntcore",
|
|
maven_artifact_name = "ntcore-cpp",
|
|
maven_group_id = "edu.wpi.first.ntcore",
|
|
)
|