[bazel] Create better static libraries and add basic publishing (#8029)

This commit is contained in:
PJ Reiniger
2025-06-27 19:36:12 -04:00
committed by GitHub
parent 22b58c1853
commit e13d237390
38 changed files with 1445 additions and 216 deletions

View File

@@ -42,7 +42,7 @@ build:build_buddy --remote_cache=grpcs://remote.buildbuddy.io
build:build_buddy --remote_timeout=3600
# Additional suggestions from buildbuddy for speed
build:build_buddy --experimental_remote_cache_compression
build:build_buddy --remote_cache_compression
build:build_buddy --experimental_remote_cache_compression_threshold=100
build:build_buddy --noslim_profile
build:build_buddy --experimental_profile_include_target_label

View File

@@ -1,8 +1,9 @@
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
filegroup(
name = "license",
pkg_files(
name = "license_pkg_files",
srcs = [
"LICENSE.md",
"ThirdPartyNotices.txt",

View File

@@ -1,11 +1,20 @@
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_pkg//pkg:zip.bzl", "pkg_zip")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_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", "pkg_java_files")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
pkg_files(
name = "thirdparty-apriltag-src-pkg",
srcs = glob(["src/main/native/thirdparty/apriltag/include/**"]),
strip_prefix = "src/main/native/thirdparty/apriltag/include",
)
cc_library(
name = "thirdparty-apriltag",
srcs = glob(["src/main/native/thirdparty/apriltag/src/**"]),
@@ -44,19 +53,33 @@ generate_resources(
)
wpilib_cc_library(
name = "apriltag.static",
name = "apriltag",
srcs = [":generate-resources"] + glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
defines = ["WPILIB_EXPORTS"],
extra_hdr_pkg_files = [":thirdparty-apriltag-src-pkg"],
extra_src_pkg_files = [":apriltag-java-jni-hdrs-pkg"],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
":thirdparty-apriltag",
"//wpimath:wpimath.static",
"//wpiutil:wpiutil.static",
"//wpimath",
"//wpiutil",
],
)
wpilib_cc_static_library(
name = "static/apriltag",
static_deps = [
"//wpimath:static/wpimath",
"//wpiutil:static/wpiutil",
],
visibility = ["//visibility:public"],
deps = [
":apriltag",
],
)
@@ -66,7 +89,7 @@ wpilib_jni_cc_library(
java_dep = ":apriltag-java",
visibility = ["//visibility:public"],
deps = [
":apriltag.static",
":apriltag",
],
)
@@ -87,6 +110,23 @@ wpilib_jni_java_library(
],
)
pkg_java_files(name = "apriltag-java-srcs")
pkg_files(
name = "resources",
srcs = glob(["src/main/native/resources/**"]),
strip_prefix = "src/main/native/resources/",
)
pkg_zip(
name = "libapriltag-java-sources",
srcs = [
":apriltag-java-srcs",
":resources",
],
out = "libapriltag-java-sources.jar",
)
cc_test(
name = "apriltag-cpp-test",
size = "small",
@@ -95,8 +135,8 @@ cc_test(
"no-asan",
],
deps = [
":apriltag.static",
"//thirdparty/googletest:googletest.static",
":apriltag",
"//thirdparty/googletest",
],
)
@@ -118,7 +158,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":apriltag.static",
":apriltag",
],
)

View File

@@ -1,9 +1,9 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
wpilib_cc_library(
name = "cameraserver.static",
name = "cameraserver",
srcs = glob(["src/main/native/cpp/**"]),
hdrs = glob(["src/main/native/include/**/*"]),
includes = [
@@ -13,11 +13,21 @@ wpilib_cc_library(
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//cscore:cscore.static",
"//ntcore:ntcore.static",
"//cscore",
"//ntcore",
],
)
wpilib_cc_static_library(
name = "static/cameraserver",
static_deps = [
"//cscore:static/cscore",
"//ntcore:static/ntcore",
],
visibility = ["//visibility:public"],
deps = [":cameraserver"],
)
java_library(
name = "cameraserver-java",
srcs = glob(["src/main/java/**/*.java"]),
@@ -25,7 +35,7 @@ java_library(
deps = [
"//cscore:cscore-java",
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpimath:wpimath-java",
"//wpinet:wpinet-java",
"//wpiutil:wpiutil-java",
@@ -38,8 +48,8 @@ cc_test(
size = "small",
srcs = glob(["src/test/native/**"]),
deps = [
":cameraserver.static",
"//thirdparty/googletest:googletest.static",
":cameraserver",
"//thirdparty/googletest",
],
)
@@ -47,7 +57,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":cameraserver.static",
":cameraserver",
],
)

View File

@@ -8,7 +8,7 @@ java_binary(
"//cameraserver:cameraserver-java",
"//cscore:cscore-java",
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
"@maven//:com_google_code_gson_gson",

View File

@@ -1,6 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_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:objectivec_rules.bzl", "wpilib_objc_library")
@@ -51,19 +51,22 @@ wpilib_objc_library(
"IOKit",
],
deps = [
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"//wpinet",
"//wpiutil",
"@bzlmodrio-opencv//libraries/cpp/opencv",
],
)
wpilib_cc_library(
name = "cscore.static",
name = "cscore",
srcs = [":native-srcs"] + glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
extra_src_pkg_files = [
":cscore-java-jni-hdrs-pkg",
],
includes = [
"src/main/native/cpp",
"src/main/native/include",
@@ -71,8 +74,8 @@ wpilib_cc_library(
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"//wpinet",
"//wpiutil",
"@bzlmodrio-opencv//libraries/cpp/opencv",
] + select({
"@bazel_tools//src/conditions:darwin": [":cscore-mac"],
@@ -80,13 +83,23 @@ wpilib_cc_library(
}),
)
wpilib_cc_static_library(
name = "static/cscore",
static_deps = [
"//wpinet:static/wpinet",
"//wpiutil:static/wpiutil",
],
visibility = ["//visibility:public"],
deps = [":cscore"],
)
wpilib_jni_cc_library(
name = "cscorejni",
srcs = glob(["src/main/native/cpp/jni/**"]),
java_dep = ":cscore-java",
visibility = ["//visibility:public"],
deps = [
":cscore.static",
":cscore",
],
)
@@ -106,8 +119,8 @@ cc_test(
size = "small",
srcs = glob(["src/test/native/**"]),
deps = [
":cscore.static",
"//thirdparty/googletest:googletest.static",
":cscore",
"//thirdparty/googletest",
],
)
@@ -124,7 +137,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":cscore.static",
":cscore",
],
)
@@ -147,7 +160,7 @@ java_binary(
"wpi-example",
],
deps = [
"//cscore:cscore.static",
"//cscore",
"//wpigui",
],
) for example in [

View File

@@ -1,17 +1,18 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_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")
wpilib_cc_library(
name = "datalog.static",
name = "datalog",
srcs = glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**"]),
extra_src_pkg_files = [":datalog-java-jni-hdrs-pkg"],
includes = [
"src/main/native/cpp",
"src/main/native/include",
@@ -19,17 +20,26 @@ wpilib_cc_library(
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpiutil:wpiutil.static",
"//wpiutil",
],
)
wpilib_cc_static_library(
name = "static/datalog",
static_deps = [
"//wpiutil:static/wpiutil",
],
visibility = ["//visibility:public"],
deps = [":datalog"],
)
wpilib_jni_cc_library(
name = "datalogjni",
srcs = glob(["src/main/native/cpp/jni/**"]),
java_dep = ":datalog-java",
visibility = ["//visibility:public"],
deps = [
":datalog.static",
":datalog",
],
)
@@ -45,8 +55,9 @@ wpilib_jni_java_library(
)
py_binary(
name = "datalog",
name = "datalog_example",
srcs = ["examples/printlog/datalog.py"],
main = "examples/printlog/datalog.py",
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
@@ -57,8 +68,8 @@ cc_binary(
name = "printlog",
srcs = ["examples/printlog/printlog.cpp"],
deps = [
":datalog.static",
"//wpiutil:wpiutil.static",
":datalog",
"//wpiutil",
],
)
@@ -66,8 +77,8 @@ cc_binary(
name = "writelog",
srcs = ["examples/writelog/writelog.cpp"],
deps = [
":datalog.static",
"//wpiutil:wpiutil.static",
":datalog",
"//wpiutil",
],
)
@@ -90,8 +101,8 @@ cc_test(
"no-tsan",
],
deps = [
":datalog.static",
"//thirdparty/googletest:googletest.static",
":datalog",
"//thirdparty/googletest",
"//wpiutil:wpiutil-testlib",
],
)

View File

@@ -50,7 +50,7 @@ cc_binary(
"//conditions:default": [],
}),
deps = [
"//datalog:datalog.static",
"//datalog",
"//glass:libglass",
"@bzlmodrio-libssh//libraries/cpp/libssh",
],

View File

@@ -1,24 +1,46 @@
load("@rules_java//java:defs.bzl", "java_library", "java_plugin")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
load("//shared/bazel/rules:packaging.bzl", "pkg_java_files")
java_library(
name = "processor",
name = "processor-java",
srcs = glob(["src/main/java/**/*.java"]),
resource_strip_prefix = "epilogue-processor/src/main/resources/",
resources = glob(["src/main/resources/**"]),
visibility = ["//visibility:public"],
runtime_deps = [
"//wpilibNewCommands:wpilibNewCommands-java",
],
deps = [
"//epilogue-runtime:epilogue",
"//epilogue-runtime:epilogue-java",
],
)
pkg_java_files(name = "epilogue-processor-java-srcs")
pkg_files(
name = "resources",
srcs = glob(["src/main/resources/**"]),
strip_prefix = "src/main/resources/",
)
pkg_zip(
name = "libepilogue-processor-java-sources",
srcs = [
":epilogue-processor-java-srcs",
":resources",
],
out = "libepilogue-processor-java-sources.jar",
)
java_plugin(
name = "plugin",
processor_class = "edu.wpi.first.epilogue.processor.AnnotationProcessor",
visibility = ["//visibility:public"],
deps = [
":processor",
":processor-java",
],
)
@@ -29,7 +51,7 @@ wpilib_java_junit5_test(
":plugin",
],
deps = [
":processor",
":processor-java",
"@maven//:com_google_testing_compile_compile_testing",
],
)

View File

@@ -2,13 +2,13 @@ load("@rules_java//java:defs.bzl", "java_library")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
java_library(
name = "epilogue",
name = "epilogue-java",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//datalog:datalog-java",
"//ntcore:networktables-java",
"//wpiunits",
"//ntcore:ntcore-java",
"//wpiunits:wpiunits-java",
"//wpiutil:wpiutil-java",
],
)
@@ -17,7 +17,7 @@ wpilib_java_junit5_test(
name = "epilogue-test",
srcs = glob(["src/test/java/**/*.java"]),
deps = [
":epilogue",
":epilogue-java",
"//wpiutil:wpiutil-java",
],
)

View File

@@ -1,6 +1,9 @@
load("@rules_java//java:defs.bzl", "java_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
load("//shared/bazel/rules:packaging.bzl", "pkg_java_files")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
generate_resources(
@@ -14,10 +17,23 @@ wpilib_cc_library(
name = "fieldImages",
srcs = [":generate-resources"] + glob(["src/main/native/cpp/**"]),
hdrs = glob(["src/main/native/include/**/*"]),
include_license_files = True,
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
)
wpilib_cc_static_library(
name = "static/fieldImages",
static_lib_name = select({
"@bazel_tools//src/conditions:windows": "static/fieldImages.lib",
"//conditions:default": "static/libfieldImages.a",
}),
visibility = ["//visibility:public"],
deps = [
":fieldImages",
],
)
java_library(
name = "fieldImages-java",
srcs = glob(["src/main/java/**/*.java"]),
@@ -30,6 +46,23 @@ java_library(
],
)
pkg_java_files(name = "fieldImages-java-srcs")
pkg_files(
name = "resources",
srcs = glob(["src/main/native/resources/**"]),
strip_prefix = "src/main/native/resources/",
)
pkg_zip(
name = "libfieldImages-java-sources",
srcs = [
":fieldImages-java-srcs",
":resources",
],
out = "libfieldImages-java-sources.jar",
)
wpilib_java_junit5_test(
name = "fieldImages-test",
srcs = glob(["src/test/java/**/*.java"]),

View File

@@ -1,5 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
@@ -7,6 +7,9 @@ wpilib_cc_library(
name = "libglass",
srcs = glob(["src/lib/native/cpp/**/*.cpp"]),
hdrs = glob(["src/lib/native/include/**"]),
hdrs_pkg_root = "src/lib/native/include",
include_license_files = True,
srcs_pkg_root = "src/lib/native/cpp",
strip_include_prefix = "src/lib/native/include",
tags = [
"wpi-cpp-gui",
@@ -15,8 +18,22 @@ wpilib_cc_library(
deps = [
"//fieldImages",
"//wpigui",
"//wpimath:wpimath.static",
"//wpiutil:wpiutil.static",
"//wpimath",
"//wpiutil",
],
)
wpilib_cc_static_library(
name = "static/glass",
static_deps = [
"//wpigui:static/wpigui",
"//wpimath:static/wpimath",
"//wpiutil:static/wpiutil",
"//fieldImages:static/fieldImages",
],
visibility = ["//visibility:public"],
deps = [
":libglass",
],
)
@@ -24,6 +41,9 @@ wpilib_cc_library(
name = "libglassnt",
srcs = glob(["src/libnt/native/cpp/*.cpp"]),
hdrs = glob(["src/libnt/native/include/**/*.h"]),
hdrs_pkg_root = "src/libnt/native/include",
include_license_files = True,
srcs_pkg_root = "src/libnt/native/cpp",
strip_include_prefix = "src/libnt/native/include",
tags = [
"wpi-cpp-gui",
@@ -31,7 +51,19 @@ wpilib_cc_library(
visibility = ["//visibility:public"],
deps = [
":libglass",
"//ntcore:ntcore.static",
"//ntcore",
],
)
wpilib_cc_static_library(
name = "static/glassnt",
static_deps = [
":static/glass",
"//ntcore:static/ntcore",
],
visibility = ["//visibility:public"],
deps = [
":libglassnt",
],
)

View File

@@ -1,9 +1,10 @@
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("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_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")
@@ -47,6 +48,8 @@ cc_library(
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/**"])
@@ -61,8 +64,20 @@ filegroup(
}),
)
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.static",
name = "wpiHal",
srcs = [":platform-srcs"] + glob(
[
"src/main/native/cpp/**",
@@ -71,6 +86,11 @@ wpilib_cc_library(
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 = [
@@ -79,9 +99,32 @@ wpilib_cc_library(
visibility = ["//visibility:public"],
deps = [
":generated_mrc_cc_headers",
"//ntcore:ntcore.static",
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"//wpiutil",
] + select({
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": [
"//ntcore",
"//wpinet",
],
"//conditions:default": [
"//ntcore:ntcore_c_headers",
],
}),
)
wpilib_cc_static_library(
name = "static/wpiHal",
static_deps = [
"//wpiutil:static/wpiutil",
] + select({
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": [
"//ntcore:static/ntcore",
"//wpinet:static/wpinet",
],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":wpiHal",
],
)
@@ -91,7 +134,7 @@ wpilib_jni_cc_library(
java_dep = ":hal-java",
visibility = ["//visibility:public"],
deps = [
":wpiHal.static",
":wpiHal",
],
)
@@ -101,7 +144,7 @@ wpilib_jni_java_library(
native_libs = [":wpiHaljni"],
visibility = ["//visibility:public"],
deps = [
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpinet:wpinet-java",
"//wpiutil:wpiutil-java",
],
@@ -112,8 +155,8 @@ cc_test(
size = "small",
srcs = glob(["src/test/native/**/*.cpp"]),
deps = [
":wpiHal.static",
"//thirdparty/googletest:googletest.static",
":wpiHal",
"//thirdparty/googletest",
],
)
@@ -129,7 +172,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":wpiHal.static",
":wpiHal",
],
)

View File

@@ -1,12 +1,14 @@
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_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
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")
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_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", "pkg_java_files")
generate_ntcore(
name = "generate_ntcore",
@@ -57,15 +59,32 @@ filegroup(
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.static",
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",
@@ -76,24 +95,37 @@ wpilib_cc_library(
],
visibility = ["//visibility:public"],
deps = [
"//datalog:datalog.static",
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"//datalog",
"//wpinet",
"//wpiutil",
],
)
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 = ":networktables-java",
java_dep = ":ntcore-java",
visibility = ["//visibility:public"],
deps = [
":ntcore.static",
":ntcore",
],
)
wpilib_jni_java_library(
name = "networktables-java",
name = "ntcore-java",
srcs = glob(["src/main/java/**/*.java"]) + [":generated_java"],
native_libs = [":ntcorejni"],
visibility = ["//visibility:public"],
@@ -104,6 +136,14 @@ wpilib_jni_java_library(
],
)
pkg_java_files(name = "ntcore-java-srcs")
pkg_zip(
name = "libntcore-java-sources",
srcs = [":ntcore-java-srcs"],
out = "libntcore-java-sources.jar",
)
cc_test(
name = "ntcore-cpp-test",
size = "small",
@@ -117,8 +157,8 @@ cc_test(
"no-tsan",
],
deps = [
":ntcore.static",
"//thirdparty/googletest:googletest.static",
":ntcore",
"//thirdparty/googletest",
"//wpiutil:wpiutil-testlib",
],
)
@@ -128,7 +168,7 @@ wpilib_java_junit5_test(
srcs = glob(["src/test/java/**/*.java"]),
tags = ["exclusive"],
deps = [
":networktables-java",
":ntcore-java",
"//wpiutil:wpiutil-java",
],
)
@@ -137,7 +177,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":ntcore.static",
":ntcore",
],
)
@@ -146,7 +186,7 @@ java_binary(
srcs = ["src/dev/java/edu/wpi/first/ntcore/DevMain.java"],
main_class = "edu.wpi.first.ntcore.DevMain",
deps = [
"networktables-java",
"ntcore-java",
"//wpiutil:wpiutil-java",
],
)

View File

@@ -1,9 +1,9 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
wpilib_cc_library(
name = "romi-cpp.static",
name = "romiVendordep",
srcs = glob([
"src/main/native/cpp/**",
]),
@@ -11,17 +11,32 @@ wpilib_cc_library(
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpilibc:wpilibc.static",
"//ntcore",
"//wpilibc",
"//wpinet",
],
)
wpilib_cc_static_library(
name = "static/romiVendordep",
static_deps = [
"//ntcore:static/ntcore",
"//wpilibc:static/wpilibc",
"//wpinet:static/wpinet",
],
visibility = ["//visibility:public"],
deps = [
":romiVendordep",
],
)
java_library(
name = "romi-java",
name = "romiVendordep-java",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//hal:hal-java",
"//wpilibj",
"//wpilibj:wpilibj-java",
],
)
@@ -30,7 +45,8 @@ cc_test(
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
deps = [
"//thirdparty/googletest:googletest.static",
":romiVendordep",
"//thirdparty/googletest",
],
)
@@ -38,7 +54,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":romi-cpp.static",
":romiVendordep",
],
)
@@ -48,7 +64,7 @@ java_binary(
main_class = "edu.wpi.first.wpilibj.romi.DevMain",
deps = [
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpiutil:wpiutil-java",
],
)

View File

@@ -0,0 +1,21 @@
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_pkg//:mappings.bzl", "pkg_files")
# Generate this because otherwise the linter wants to change the format.
write_file(
name = "manifest_write",
out = "MANIFEST.MF",
content = [
"Manifest-Version: 1.0",
"",
],
)
pkg_files(
name = "src_jar_dummy_manifest",
srcs = [
"MANIFEST.MF",
],
prefix = "META-INF",
visibility = ["//visibility:public"],
)

View File

@@ -1,4 +1,16 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:action_names.bzl", "CPP_LINK_STATIC_LIBRARY_ACTION_NAME")
load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_library")
load("@rules_cc//cc:find_cc_toolchain.bzl", "CC_TOOLCHAIN_ATTRS", "find_cpp_toolchain", "use_cc_toolchain")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//:pkg.bzl", "pkg_zip")
def _folder_prefix(name):
if "/" in name:
last_slash = name.rfind("/")
return (name[0:last_slash], name[last_slash + 1:])
else:
return ("", name)
def third_party_cc_lib_helper(
name,
@@ -13,7 +25,8 @@ def third_party_cc_lib_helper(
to make a header shim to deal with the include path, and a filegroup of the sources. This pattern is extermely
common for the thirdparty libraries that live beneath certain libraries.
This will produce a library shim with the include path stripped, and a filegroup of sources.
This will produce a library shim with the include path stripped, a filegroup of sources, and packages that can be
used to downstream to zip headers / sources with their "parent" library.
Params
include_root: The package relative path to the header files. This will be used to glob the files and strip the include prefix
@@ -31,6 +44,12 @@ def third_party_cc_lib_helper(
visibility = visibility,
)
pkg_files(
name = name + "-hdrs-pkg",
srcs = native.glob([include_root + "/**"]),
strip_prefix = include_root,
)
if src_root:
native.filegroup(
name = name + "-srcs",
@@ -38,23 +57,294 @@ def third_party_cc_lib_helper(
visibility = visibility,
)
pkg_files(
name = name + "-srcs-pkg",
srcs = native.glob([src_root + "/**"]),
strip_prefix = src_root,
)
def wpilib_cc_library(
name,
srcs = [],
hdrs = [],
deps = [],
copts = [],
third_party_libraries = [],
third_party_header_only_libraries = [],
extra_src_pkg_files = [],
extra_hdr_pkg_files = [],
include_license_files = False,
srcs_pkg_root = "src/main/native/cpp",
hdrs_pkg_root = "src/main/native/include",
strip_include_prefix = None,
linkopts = None,
**kwargs):
"""
This function is used to ease the creation of a cc_library with helpers for handling thirdparty libraries in the standard allwpilib format.
This function is used to ease the creation of a cc_library with publishing given the standard allwpilib directory structure.
This will create a cc_library as well as automatically create header, source, and library artifacts that can be used for publishing. This
also provides some syntactic sugar for third party library shims declared by third_party_cc_lib_helper.
Important outputs:
":name" - The cc_library
name + "-srcs-zip" - A zip file containing all the exported sources
name + "-hdrs-zip" - A zip file containing all the exported headers
name + "-zip" - A zip file that contains the compiled library
Params:
srcs: The sources used to compile the library. Note: This may be platform dependent and not include all the sources of the library for packaging
hdrs: The headers used to compile the library. Note: This may be platform dependent and not include all the sources of the library for packaging
third_party_libraries: These are helper dependencies, created by third_party_cc_lib_helper. Header shims will be added as deps and src filegroups will be added to srcs
third_party_header_only_libraries: Similar to third_party_libraries, but for shims that contain no sources
extra_src_pkg_files: Extra pkg_files to add to the source bundle. This is useful in the event that a library is complicated and requires
extra, customized sources to be added to the published zip file
extra_hdr_pkg_files: Extra pkg_files to add to the headers bundle. This is useful in the event that a library is complicated and requires
extra, customized headers to be added to the published zip file
include_license_files: If the header / source / library zip files should automatically includes the license files. This is used to maintain
consistency with the gradle publishing, as not all of them export the license files.
"""
maybe_license_pkg = ["//:license_pkg_files"] if include_license_files else []
cc_library(
name = name,
srcs = srcs + [lib + "-srcs" for lib in third_party_libraries],
deps = deps + [lib + "-headers" for lib in third_party_libraries + third_party_header_only_libraries],
name = name + "-headers",
hdrs = hdrs,
deps = [lib + "-headers" for lib in third_party_libraries + third_party_header_only_libraries],
strip_include_prefix = strip_include_prefix,
**kwargs
)
cc_library(
name = name,
hdrs = hdrs,
copts = copts,
srcs = srcs + [lib + "-srcs" for lib in third_party_libraries],
deps = deps + [lib + "-headers" for lib in third_party_libraries + third_party_header_only_libraries],
strip_include_prefix = strip_include_prefix,
**kwargs
)
if srcs_pkg_root:
pkg_files(
name = name + "-srcs-pkg",
srcs = native.glob([srcs_pkg_root + "/**"]),
strip_prefix = srcs_pkg_root,
)
pkg_zip(
name = name + "-srcs-zip",
srcs = maybe_license_pkg + extra_src_pkg_files + [name + "-srcs-pkg"] + [lib + "-srcs-pkg" for lib in third_party_libraries],
tags = ["no-remote"],
)
if hdrs_pkg_root:
pkg_files(
name = name + "-hdrs-pkg",
srcs = native.glob([hdrs_pkg_root + "/**"]),
strip_prefix = hdrs_pkg_root,
)
pkg_zip(
name = name + "-hdrs-zip",
srcs = extra_hdr_pkg_files + maybe_license_pkg + [name + "-hdrs-pkg"] + [lib + "-hdrs-pkg" for lib in third_party_libraries + third_party_header_only_libraries],
tags = ["no-remote"],
)
CcStaticLibraryInfo = provider(
"Information about a cc static library.",
fields = {
"linker_input": "the resulting linker input artifact for the static library",
"used_objects": "the object files already accounted for",
},
)
def _accumulate_used_objects(ctx):
transitive_used_objects = []
for dep in ctx.attr.static_deps:
transitive_used_objects.append(dep[CcStaticLibraryInfo].used_objects)
return transitive_used_objects
def _filter_inputs(
ctx,
feature_configuration,
cc_toolchain,
deps,
used_objects):
dependency_linker_inputs_sets = []
for dep in deps:
dependency_linker_inputs_sets.append(dep[CcInfo].linking_context.linker_inputs)
dependency_linker_inputs = depset(transitive = dependency_linker_inputs_sets, order = "topological").to_list()
used_objects_depset = depset(transitive = used_objects, order = "topological").to_list()
linker_inputs = []
for linker_input in dependency_linker_inputs:
for lib in linker_input.libraries:
if lib.pic_objects:
for o in lib.pic_objects:
if o not in used_objects_depset:
linker_inputs.append(o)
elif lib.objects:
for o in lib.objects:
if o not in used_objects_depset:
linker_inputs.append(o)
return sorted(linker_inputs)
def _cc_static_library_impl(ctx):
"""
This is a modified version of built in cc_static_library implementation
https://github.com/bazelbuild/bazel/blob/8.2.1/src/main/starlark/builtins_bzl/common/cc/experimental_cc_static_library.bzl
The built in version amalgamates all of the transative dependency objects into a single shared library. However, we do not want our
static libraries to only have the symbols related to the objects for this library, and not anything transative. In order to do this,
we add the option to specify transative static_libraries. The rule then filters out the objects that are defines in the other static
libraries.
"""
deps = ctx.attr.deps
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features + ["force_no_whole_archive"],
unsupported_features = ctx.disabled_features,
)
# Find all the objects which are already in another static library.
used_objects = _accumulate_used_objects(ctx)
# Now, find the ones we depend on which aren't.
libs = _filter_inputs(
ctx,
feature_configuration,
cc_toolchain,
deps,
used_objects,
)
used_objects_depset = depset(direct = libs, transitive = used_objects, order = "topological")
# Generate the output library name if one isn't provided.
output_file = ctx.actions.declare_file(ctx.attr.static_lib_name)
# And, now do it.
linker_input = cc_common.create_linker_input(
owner = ctx.label,
libraries = depset(direct = [
cc_common.create_library_to_link(
actions = ctx.actions,
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
static_library = output_file,
),
]),
)
compilation_context = cc_common.create_compilation_context()
linking_context = cc_common.create_linking_context(linker_inputs = depset(direct = [linker_input], order = "topological"))
archiver_path = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
action_name = CPP_LINK_STATIC_LIBRARY_ACTION_NAME,
)
archiver_variables = cc_common.create_link_variables(
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
output_file = output_file.path,
is_using_linker = False,
)
command_line = cc_common.get_memory_inefficient_command_line(
feature_configuration = feature_configuration,
action_name = CPP_LINK_STATIC_LIBRARY_ACTION_NAME,
variables = archiver_variables,
)
args = ctx.actions.args()
args.add_all(command_line)
args.add_all(libs)
if cc_common.is_enabled(
feature_configuration = feature_configuration,
feature_name = "archive_param_file",
):
# TODO: The flag file arg should come from the toolchain instead.
args.use_param_file("@%s", use_always = True)
env = cc_common.get_environment_variables(
feature_configuration = feature_configuration,
action_name = CPP_LINK_STATIC_LIBRARY_ACTION_NAME,
variables = archiver_variables,
)
ctx.actions.run(
executable = archiver_path,
arguments = [args],
env = env,
inputs = depset(
direct = libs,
transitive = [
cc_toolchain.all_files,
],
),
outputs = [output_file],
)
cc_info = cc_common.merge_cc_infos(cc_infos = [
CcInfo(compilation_context = compilation_context, linking_context = linking_context),
] + [dep[CcInfo] for dep in ctx.attr.deps])
# TODO(austin): Do we want this to be able to link into a binary? Probably... Need to figure out what the right result needs to be for that.
return [
cc_info,
DefaultInfo(
files = depset([output_file]),
),
CcStaticLibraryInfo(
used_objects = used_objects_depset,
linker_input = linker_input,
),
]
_wpilib_cc_static_library = rule(
implementation = _cc_static_library_impl,
attrs = {
"deps": attr.label_list(
providers = [CcInfo],
doc = """
List of all the dependencies to accumulate objects from to link into this static library.
""",
),
"static_deps": attr.label_list(
providers = [CcStaticLibraryInfo],
doc = """
List of all static libraries to not duplicate .o files from.
""",
),
"static_lib_name": attr.string(doc = """
By default cc_static_library will use a name for the static library output file based on
the target's name and the platform. This includes an extension and sometimes a prefix.
Sometimes you may not want the default name, in which case you can use this
attribute to choose a custom name."""),
} | CC_TOOLCHAIN_ATTRS,
toolchains = use_cc_toolchain(),
fragments = ["cpp"],
)
def wpilib_cc_static_library(
name,
static_lib_name = None,
**kwargs):
if not static_lib_name:
folder, lib = _folder_prefix(name)
static_lib_name = select({
"@bazel_tools//src/conditions:windows": folder + "/" + lib + ".lib",
"//conditions:default": folder + "/lib" + lib + ".a",
})
_wpilib_cc_static_library(
name = name,
static_lib_name = static_lib_name,
**kwargs
)

View File

@@ -1,6 +1,7 @@
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_pkg//:mappings.bzl", "filter_directory")
def _jni_headers_impl(ctx):
include_dir = ctx.actions.declare_directory(ctx.attr.name + ".h")
@@ -75,6 +76,7 @@ def wpilib_jni_java_library(
name = name,
visibility = visibility,
testonly = testonly,
tags = tags,
**java_library_args
)
@@ -87,14 +89,26 @@ def wpilib_jni_java_library(
visibility = visibility,
)
# Expose a pkg_files with the JNI generated header in it.
filter_directory(
name = name + "-jni-hdrs-pkg",
src = headers_name,
excludes = ["MANIFEST.MF"],
outdir_name = "jni/",
)
def wpilib_jni_cc_library(
name,
deps = [],
java_dep = None,
**kwargs):
jni = "@rules_bzlmodrio_toolchains//jni"
if java_dep[0] != ":":
fail("java_dep", java_dep, "should start with a :")
cc_library(
name = name + ".static",
name = name,
deps = [jni, java_dep + ".hdrs"] + deps,
**kwargs
)

View File

@@ -0,0 +1,30 @@
load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files")
def pkg_java_files(name):
pkg_files(
name = name + "-java-srcs",
srcs = native.glob(["src/main/java/**"]),
strip_prefix = "src/main/java",
)
pkg_files(
name = name + "-generated-java-srcs",
srcs = native.glob(["src/generated/main/java/**/*.java"], allow_empty = True),
strip_prefix = "src/generated/main/java",
)
pkg_files(
name = name + "-proto-srcs",
srcs = native.glob(["src/main/proto/**"], allow_empty = True),
strip_prefix = "src/main/proto",
)
pkg_filegroup(
name = name,
srcs = [
name + "-java-srcs",
name + "-proto-srcs",
name + "-generated-java-srcs",
"//shared/bazel/rules:src_jar_dummy_manifest",
],
)

View File

@@ -1,5 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//shared/bazel/rules:halsim_library.bzl", "wpilib_halsim_extension")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
cc_library(
name = "headers",
@@ -7,23 +7,60 @@ cc_library(
includes = ["src/main/native/include"],
)
wpilib_halsim_extension(
wpilib_cc_library(
name = "halsim_ds_socket",
srcs = glob(["src/main/native/cpp/**"]),
include_license_files = True,
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":headers",
"//hal:wpiHal.static",
"//wpinet:wpinet.static",
"//hal:wpiHal",
"//wpinet",
],
)
wpilib_cc_library(
name = "halsim_ds_socket_static",
srcs = glob(["src/main/native/cpp/**"]),
copts = [
"-DHALSIM_InitExtension=HALSIM_InitExtension_DS_SOCKET",
],
include_license_files = True,
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":headers",
"//hal:wpiHal",
"//wpinet",
],
)
wpilib_cc_static_library(
name = "static/halsim_ds_socket",
static_deps = [
"//hal:static/wpiHal",
"//wpinet:static/wpinet",
],
visibility = ["//visibility:public"],
deps = [":halsim_ds_socket_static"],
)
cc_test(
name = "halsim_ds_socket-test",
size = "small",
srcs = glob(["src/test/native/**/*.cpp"]),
deps = [
"//simulation/halsim_ds_socket",
"//thirdparty/googletest:googletest.static",
"//thirdparty/googletest",
],
)

View File

@@ -1,18 +1,73 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("//shared/bazel/rules:halsim_library.bzl", "wpilib_halsim_extension")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
wpilib_halsim_extension(
wpilib_cc_library(
name = "halsim_gui",
srcs = glob([
"src/main/native/cpp/*",
"src/main/native/include/*.h",
]),
include_license_files = True,
includes = ["src/main/native/include"],
linkopts = [
"-lm",
],
tags = [
"wpi-cpp-gui",
],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//glass:libglassnt",
"//hal:wpiHal.static",
"//hal:wpiHal",
],
)
wpilib_cc_library(
name = "halsim_gui_static",
srcs = glob([
"src/main/native/cpp/*",
"src/main/native/include/*.h",
]),
copts = [
"-DHALSIM_InitExtension=HALSIM_InitExtension_GUI",
],
include_license_files = True,
includes = ["src/main/native/include"],
linkopts = [
"-lm",
],
tags = [
"wpi-cpp-gui",
],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//glass:libglassnt",
"//hal:wpiHal",
],
)
wpilib_cc_static_library(
name = "static/halsim_gui",
static_deps = [
"//hal:static/wpiHal",
"//wpimath:static/wpimath",
"//datalog:static/datalog",
"//ntcore:static/ntcore",
"//glass:static/glassnt",
],
visibility = ["//visibility:public"],
deps = [
":halsim_gui_static",
],
)
@@ -26,7 +81,7 @@ cc_test(
],
deps = [
":halsim_gui",
"//thirdparty/googletest:googletest.static",
"//thirdparty/googletest",
],
)

View File

@@ -1,9 +1,10 @@
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
wpilib_cc_library(
name = "halsim_ws_core",
srcs = glob(["src/main/native/cpp/*.cpp"]),
hdrs = glob(["src/main/native/include/*.h"]),
include_license_files = True,
strip_include_prefix = "src/main/native/include",
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
@@ -12,8 +13,21 @@ wpilib_cc_library(
}),
visibility = ["//visibility:public"],
deps = [
"//hal:wpiHal.static",
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"//hal:wpiHal",
"//wpinet",
"//wpiutil",
],
)
wpilib_cc_static_library(
name = "static/halsim_ws_core",
static_deps = [
"//hal:static/wpiHal",
"//wpinet:static/wpinet",
"//wpiutil:static/wpiutil",
],
visibility = ["//visibility:public"],
deps = [
":halsim_ws_core",
],
)

View File

@@ -1,5 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//shared/bazel/rules:halsim_library.bzl", "wpilib_halsim_extension")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
cc_library(
name = "headers",
@@ -7,15 +7,55 @@ cc_library(
includes = ["src/main/native/include"],
)
wpilib_halsim_extension(
wpilib_cc_library(
name = "halsim_ws_server",
srcs = glob(["src/main/native/cpp/**"]),
include_license_files = True,
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":headers",
"//simulation/halsim_ws_core",
],
)
wpilib_cc_library(
name = "halsim_ws_server_static",
srcs = glob(["src/main/native/cpp/**"]),
copts = [
"-DHALSIM_InitExtension=HALSIM_InitExtension_WS_SERVER",
],
include_license_files = True,
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":headers",
"//simulation/halsim_ws_core",
],
)
wpilib_cc_static_library(
name = "static/halsim_ws_server",
static_deps = [
"//hal:static/wpiHal",
"//wpinet:static/wpinet",
"//wpiutil:static/wpiutil",
"//simulation/halsim_ws_core:static/halsim_ws_core",
],
visibility = ["//visibility:public"],
deps = [
":halsim_ws_server_static",
],
)
cc_library(
name = "test_headers",
srcs = glob(["src/test/native/include/*.h"]),
@@ -33,7 +73,7 @@ cc_test(
deps = [
":halsim_ws_server",
":test_headers",
"//thirdparty/googletest:googletest.static",
"//thirdparty/googletest",
],
)

View File

@@ -1,15 +1,59 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//shared/bazel/rules:halsim_library.bzl", "wpilib_halsim_extension")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
wpilib_halsim_extension(
wpilib_cc_library(
name = "halsim_xrp",
srcs = glob([
"src/main/native/cpp/*",
"src/main/native/include/*.h",
]),
include_license_files = True,
includes = ["src/main/native/include"],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//simulation/halsim_ws_core",
"//xrpVendordep:xrp-cpp",
"//wpinet",
],
)
wpilib_cc_library(
name = "halsim_xrp_static",
srcs = glob([
"src/main/native/cpp/*",
"src/main/native/include/*.h",
]),
copts = [
"-DHALSIM_InitExtension=HALSIM_InitExtension_XRP",
],
include_license_files = True,
includes = ["src/main/native/include"],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//simulation/halsim_ws_core",
"//wpinet",
],
)
wpilib_cc_static_library(
name = "static/halsim_xrp",
static_deps = [
"//wpinet:static/wpinet",
"//hal:static/wpiHal",
"//simulation/halsim_ws_core:static/halsim_ws_core",
],
visibility = ["//visibility:public"],
deps = [
":halsim_xrp_static",
],
)

View File

@@ -27,9 +27,9 @@ cc_library(
hdrs = glob(["src/main/native/include/**"]),
strip_include_prefix = "src/main/native/include",
deps = [
"//datalog:datalog.static",
"//datalog",
"//glass:libglass",
"//wpinet:wpinet.static",
"//wpinet",
],
)
@@ -52,6 +52,6 @@ cc_test(
],
deps = [
":sysid-lib",
"//thirdparty/googletest:googletest.static",
"//thirdparty/googletest",
],
)

View File

@@ -1,10 +1,25 @@
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
wpilib_cc_library(
name = "googletest.static",
name = "googletest",
srcs = glob(["src/**"]),
hdrs = glob(["include/**"]),
hdrs_pkg_root = "include",
include_license_files = True,
includes = ["src/googletest"],
srcs_pkg_root = "src",
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)
wpilib_cc_static_library(
name = "static/googletest",
static_lib_name = select({
"@bazel_tools//src/conditions:windows": "static/googletest.lib",
"//conditions:default": "static/libgoogletest.a",
}),
visibility = ["//visibility:public"],
deps = [
":googletest",
],
)

View File

@@ -1,6 +1,8 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//:pkg.bzl", "pkg_zip")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
load("//shared/bazel/rules:objectivec_rules.bzl", "wpilib_objc_library")
cc_library(
@@ -352,7 +354,9 @@ cc_library(
#########################################
wpilib_cc_library(
name = "imgui_suite",
hdrs_pkg_root = None,
linkstatic = True,
srcs_pkg_root = None,
visibility = ["//visibility:public"],
deps = [
":fonts",
@@ -362,3 +366,115 @@ wpilib_cc_library(
":stb",
],
)
wpilib_cc_static_library(
name = "static/imguiSuite",
visibility = ["//visibility:public"],
deps = [
":imgui_suite",
],
)
pkg_files(
name = "glfw-hdrs-pkg",
srcs = glob(["glfw/include/**"]),
strip_prefix = "glfw/include",
)
pkg_files(
name = "imgui-hdrs-pkg",
srcs = glob(["imgui/include/**"]),
strip_prefix = "imgui/include",
)
pkg_files(
name = "implot-hdrs-pkg",
srcs = glob(["implot/include/**"]),
strip_prefix = "implot/include",
)
pkg_files(
name = "stb-hdrs-pkg",
srcs = glob(["stb/include/**"]),
strip_prefix = "stb/include",
)
pkg_files(
name = "generated-fonts-hdrs-pkg",
srcs = glob(["generated/fonts/include/**"]),
strip_prefix = "generated/fonts/include/",
)
pkg_files(
name = "generated-gl3w-hdrs-pkg",
srcs = glob(["generated/gl3w/include/**"]),
strip_prefix = "generated/gl3w/include/",
)
pkg_zip(
name = "imgui-suite-hdrs",
srcs = [
"generated-fonts-hdrs-pkg",
"generated-gl3w-hdrs-pkg",
"glfw-hdrs-pkg",
"imgui-hdrs-pkg",
"implot-hdrs-pkg",
"stb-hdrs-pkg",
"//:license_pkg_files",
],
tags = [
"no-remote",
],
)
pkg_files(
name = "glfw-srcs-pkg",
srcs = glob(["glfw/src/**"]),
strip_prefix = "glfw/src",
)
pkg_files(
name = "imgui-srcs-pkg",
srcs = glob(["imgui/cpp/**"]),
strip_prefix = "imgui/cpp",
)
pkg_files(
name = "implot-srcs-pkg",
srcs = glob(["implot/cpp/**"]),
strip_prefix = "implot/cpp",
)
pkg_files(
name = "stb-srcs-pkg",
srcs = glob(["stb/cpp/**"]),
strip_prefix = "stb/cpp",
)
pkg_files(
name = "generated-fonts-srcs-pkg",
srcs = glob(["generated/fonts/src/**"]),
strip_prefix = "generated/fonts/src/",
)
pkg_files(
name = "generated-gl3w-srcs-pkg",
srcs = glob(["generated/gl3w/src/**"]),
strip_prefix = "generated/gl3w/src/",
)
pkg_zip(
name = "imgui-suite-srcs",
srcs = [
"generated-fonts-srcs-pkg",
"generated-gl3w-srcs-pkg",
"glfw-srcs-pkg",
"imgui-srcs-pkg",
"implot-srcs-pkg",
"stb-srcs-pkg",
"//:license_pkg_files",
],
tags = [
"no-remote",
],
)

View File

@@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
load("//shared/bazel/rules:objectivec_rules.bzl", "wpilib_objc_library")
WIN_SRCS = glob(["src/main/native/directx11/**/*.cpp"])
@@ -32,6 +33,15 @@ wpilib_objc_library(
],
)
pkg_files(
name = "native-pkg",
srcs = glob([
"src/main/native/directx11/**",
"src/main/native/opengl3/**",
"src/main/native/metal/**",
]),
)
wpilib_cc_library(
name = "wpigui",
srcs = glob(["src/main/native/cpp/**/*.cpp"]) +
@@ -40,6 +50,8 @@ wpilib_cc_library(
"@bazel_tools//src/conditions:windows": WIN_SRCS,
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_SRCS,
}),
extra_src_pkg_files = [":native-pkg"],
include_license_files = True,
strip_include_prefix = "include",
tags = [
"wpi-cpp-gui",
@@ -53,3 +65,18 @@ wpilib_cc_library(
"//conditions:default": [],
}),
)
wpilib_cc_static_library(
name = "static/wpigui",
static_deps = [
"//thirdparty/imgui_suite:static/imguiSuite",
],
static_lib_name = select({
"@bazel_tools//src/conditions:windows": "static/wpigui.lib",
"//conditions:default": "static/libwpigui.a",
}),
visibility = ["//visibility:public"],
deps = [
":wpigui",
],
)

View File

@@ -2,9 +2,11 @@ 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_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
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:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_static_library")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
load("//shared/bazel/rules:packaging.bzl", "pkg_java_files")
load("//wpilibNewCommands:generate.bzl", "generate_wpilib_new_commands")
py_binary(
@@ -50,7 +52,7 @@ filegroup(
)
wpilib_cc_library(
name = "wpilibNewCommands.static",
name = "wpilibNewCommands",
srcs = glob(["src/main/native/cpp/**"]),
hdrs = glob(["src/main/native/include/**"]),
includes = ["src/main/native/include"],
@@ -60,10 +62,23 @@ wpilib_cc_library(
],
visibility = ["//visibility:public"],
deps = [
"//wpilibc:wpilibc.static",
"//ntcore",
"//wpilibc",
"//wpinet",
],
)
wpilib_cc_static_library(
name = "static/wpilibNewCommands",
static_deps = [
"//ntcore:static/ntcore",
"//wpilibc:static/wpilibc",
"//wpinet:static/wpinet",
],
visibility = ["//visibility:public"],
deps = [":wpilibNewCommands"],
)
java_library(
name = "wpilibNewCommands-java",
srcs = glob(["src/main/java/**/*.java"]) + [":generated_java"],
@@ -71,15 +86,23 @@ java_library(
deps = [
"//cscore:cscore-java",
"//hal:hal-java",
"//ntcore:networktables-java",
"//wpilibj",
"//ntcore:ntcore-java",
"//wpilibj:wpilibj-java",
"//wpimath:wpimath-java",
"//wpinet:wpinet-java",
"//wpiunits",
"//wpiunits:wpiunits-java",
"//wpiutil:wpiutil-java",
],
)
pkg_java_files(name = "wpilibNewCommands-java-srcs")
pkg_zip(
name = "libwpilibNewCommands-java-sources",
srcs = [":wpilibNewCommands-java-srcs"],
out = "libwpilibNewCommands-java-sources.jar",
)
cc_test(
name = "wpilibNewCommands-cpp-test",
size = "small",
@@ -92,8 +115,8 @@ cc_test(
"no-ubsan",
],
deps = [
":wpilibNewCommands.static",
"//thirdparty/googletest:googletest.static",
":wpilibNewCommands",
"//thirdparty/googletest",
],
)
@@ -105,10 +128,10 @@ wpilib_java_junit5_test(
deps = [
":wpilibNewCommands-java",
"//hal:hal-java",
"//ntcore:networktables-java",
"//wpilibj",
"//ntcore:ntcore-java",
"//wpilibj:wpilibj-java",
"//wpimath:wpimath-java",
"//wpiunits",
"//wpiunits:wpiunits-java",
"//wpiutil:wpiutil-java",
"@maven//:org_mockito_mockito_core",
],
@@ -127,7 +150,7 @@ java_binary(
main_class = "edu.wpi.first.wpilibj2.commands.DevMain",
deps = [
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
],

View File

@@ -2,7 +2,7 @@ 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:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_static_library")
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
load("//wpilibc:generate.bzl", "generate_wpilibc")
@@ -76,7 +76,7 @@ third_party_cc_lib_helper(
)
wpilib_cc_library(
name = "wpilibc.static",
name = "wpilibc",
srcs = [
":generate-version",
] + glob([
@@ -84,20 +84,42 @@ wpilib_cc_library(
"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.static",
"//cscore:cscore.static",
"//datalog:datalog.static",
"//hal:wpiHal.static",
"//ntcore:ntcore.static",
"//wpimath:wpimath.static",
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"//cameraserver:cameraserver-headers",
"//cscore:cscore-headers",
"//datalog",
"//hal:wpiHal",
"//ntcore",
"//ntcore:ntcore-headers",
"//wpimath",
"//wpinet",
"//wpiutil",
],
)
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",
],
)
@@ -119,8 +141,8 @@ cc_test(
],
deps = [
":test-headers",
":wpilibc.static",
"//thirdparty/googletest:googletest.static",
":wpilibc",
"//thirdparty/googletest",
],
)
@@ -128,6 +150,6 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":wpilibc.static",
":wpilibc",
],
)

View File

@@ -1,7 +1,34 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//:pkg.bzl", "pkg_zip")
load("//wpilibcExamples:example_projects.bzl", "COMMANDS_V2_FOLDERS", "EXAMPLE_FOLDERS", "SNIPPETS_FOLDERS", "TEMPLATES_FOLDERS", "TESTS_FOLDERS")
def _package_type(package_type):
pkg_files(
name = package_type + "-pkg",
srcs = native.glob(["src/main/cpp/" + package_type + "/**"]),
strip_prefix = "src/main/cpp",
)
pkgs = ["//:license_pkg_files", ":" + package_type + "-pkg"]
if package_type == "examples":
pkg_files(
name = package_type + "-tests-pkg",
srcs = native.glob(["src/test/cpp/" + package_type + "/**"]),
strip_prefix = "src/test/cpp/" + package_type,
prefix = "examples_test",
)
pkgs.append(package_type + "-tests-pkg")
pkg_zip(
name = package_type + "-zip",
srcs = pkgs,
tags = ["no-remote"],
)
def build_examples(halsim_deps = []):
_package_type("examples")
for folder in EXAMPLE_FOLDERS:
cc_library(
name = folder + "-examples-headers",
@@ -13,48 +40,56 @@ def build_examples(halsim_deps = []):
name = folder + "-example",
srcs = native.glob(["src/main/cpp/examples/" + folder + "/cpp/**/*.cpp", "src/main/cpp/examples/" + folder + "/c/**/*.c"], allow_empty = True),
deps = [
"//wpilibNewCommands:wpilibNewCommands.static",
"//apriltag:apriltag.static",
"//romiVendordep:romi-cpp.static",
"//xrpVendordep:xrp-cpp",
"//wpilibNewCommands",
"//apriltag",
"//romiVendordep",
"//xrpVendordep",
"//cameraserver",
":{}-examples-headers".format(folder),
],
tags = ["wpi-example"],
)
def build_commands():
_package_type("commands")
for folder in COMMANDS_V2_FOLDERS:
cc_library(
name = folder + "-command",
srcs = native.glob(["src/main/cpp/commands/" + folder + "/**/*.cpp"]),
hdrs = native.glob(["src/main/cpp/commands/" + folder + "/**/*.h"]),
deps = [
"//wpilibNewCommands:wpilibNewCommands.static",
"//wpilibNewCommands",
],
strip_include_prefix = "src/main/cpp/commands/" + folder,
tags = ["wpi-example"],
)
def build_snippets():
_package_type("snippets")
for folder in SNIPPETS_FOLDERS:
cc_library(
name = folder + "-template",
srcs = native.glob(["src/main/cpp/snippets/" + folder + "/**/*.cpp"]),
hdrs = native.glob(["src/main/cpp/snippets/" + folder + "/**/*.h"], allow_empty = True),
deps = [
"//wpilibNewCommands:wpilibNewCommands.static",
"//wpilibNewCommands",
],
strip_include_prefix = "src/main/cpp/snippets/" + folder + "/include",
tags = ["wpi-example"],
)
def build_templates():
_package_type("templates")
for folder in TEMPLATES_FOLDERS:
cc_library(
name = folder + "-template",
srcs = native.glob(["src/main/cpp/templates/" + folder + "/**/*.cpp"]),
hdrs = native.glob(["src/main/cpp/templates/" + folder + "/**/*.h"]),
deps = [
"//wpilibNewCommands:wpilibNewCommands.static",
"//wpilibNewCommands",
],
strip_include_prefix = "src/main/cpp/templates/" + folder + "/include",
tags = ["wpi-example"],
@@ -69,9 +104,9 @@ def build_tests():
size = "small",
srcs = native.glob([example_test_folder + "/**/*.cpp", example_src_folder + "/cpp/**/*.cpp", example_src_folder + "/c/**/*.c"], allow_empty = True),
deps = [
"//wpilibNewCommands:wpilibNewCommands.static",
"//wpilibNewCommands",
":{}-examples-headers".format(folder),
"//thirdparty/googletest:googletest.static",
"//thirdparty/googletest",
],
defines = ["RUNNING_FRC_TESTS=1"],
tags = ["wpi-example", "no-tsan", "no-asan", "no-ubsan", "exclusive"],

View File

@@ -2,8 +2,11 @@ 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")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
load("//shared/bazel/rules:packaging.bzl", "pkg_java_files")
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
load("//wpilibj:generate.bzl", "generate_wpilibj")
@@ -70,7 +73,7 @@ filegroup(
)
java_library(
name = "wpilibj",
name = "wpilibj-java",
srcs = [
":generate-version",
":generated_java",
@@ -81,27 +84,47 @@ java_library(
"//cscore:cscore-java",
"//datalog:datalog-java",
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpimath:wpimath-java",
"//wpinet:wpinet-java",
"//wpiunits",
"//wpiunits:wpiunits-java",
"//wpiutil:wpiutil-java",
"@maven//:org_ejml_ejml_core",
"@maven//:org_ejml_ejml_simple",
],
)
# Strip the corresponding prefixes off the generated and source files.
pkg_java_files(name = "java-srcs")
pkg_files(
name = "generated_version_files",
srcs = [
":generate-version",
],
prefix = "edu/wpi/first/wpilibj/util/",
)
pkg_zip(
name = "libwpilibj-java-sources",
srcs = [
":generated_version_files",
":java-srcs",
],
out = "libwpilibj-java-sources.jar",
)
wpilib_java_junit5_test(
name = "wpilibj-java-test",
srcs = glob(["src/test/java/**/*.java"]),
resource_strip_prefix = "wpilibj/src/test/resources",
resources = glob(["src/test/resources/**"]),
deps = [
":wpilibj",
":wpilibj-java",
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpimath:wpimath-java",
"//wpiunits",
"//wpiunits:wpiunits-java",
"//wpiutil:wpiutil-java",
],
)
@@ -119,7 +142,7 @@ java_binary(
main_class = "edu.wpi.first.wpilibj.DevMain",
deps = [
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
],

View File

@@ -1,8 +1,35 @@
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//:pkg.bzl", "pkg_zip")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
load("//wpilibjExamples:example_projects.bzl", "COMMANDS_V2_FOLDERS", "EXAMPLES_FOLDERS", "SNIPPETS_FOLDERS", "TEMPLATES_FOLDERS", "TEST_FOLDERS")
def _package_type(package_type):
pkg_files(
name = package_type + "-pkg",
srcs = native.glob(["src/main/java/edu/wpi/first/wpilibj/" + package_type + "/**"]),
strip_prefix = "src/main/java/edu/wpi/first/wpilibj",
)
pkgs = ["//:license_pkg_files", ":" + package_type + "-pkg"]
if package_type == "examples":
pkg_files(
name = package_type + "-tests-pkg",
srcs = native.glob(["src/test/java/edu/wpi/first/wpilibj/" + package_type + "/**"]),
strip_prefix = "src/test/java/edu/wpi/first/wpilibj/" + package_type,
prefix = "examples_test",
)
pkgs.append(package_type + "-tests-pkg")
pkg_zip(
name = package_type + "-zip",
srcs = pkgs,
tags = ["no-remote"],
)
def build_examples(halsim_deps):
_package_type("examples")
for folder in EXAMPLES_FOLDERS:
java_binary(
name = folder + "-example",
@@ -16,28 +43,30 @@ def build_examples(halsim_deps):
"//cameraserver:cameraserver-java",
"//cscore:cscore-java",
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpimath:wpimath-java",
"//wpilibj:wpilibj",
"//wpilibj:wpilibj-java",
"//wpilibNewCommands:wpilibNewCommands-java",
"//wpiutil:wpiutil-java",
"//romiVendordep:romi-java",
"//xrpVendordep:xrp-java",
"//wpiunits",
"//epilogue-runtime:epilogue",
"//romiVendordep:romiVendordep-java",
"//xrpVendordep:xrpVendordep-java",
"//wpiunits:wpiunits-java",
"//epilogue-runtime:epilogue-java",
"@bzlmodrio-opencv//libraries/java/opencv",
],
tags = ["wpi-example"],
)
def build_commands():
_package_type("commands")
for folder in COMMANDS_V2_FOLDERS:
java_library(
name = folder + "-command",
srcs = native.glob(["src/main/java/edu/wpi/first/wpilibj/commands/" + folder + "/**/*.java"]),
deps = [
"//hal:hal-java",
"//wpilibj:wpilibj",
"//wpilibj:wpilibj-java",
"//wpilibNewCommands:wpilibNewCommands-java",
"//wpimath:wpimath-java",
],
@@ -45,28 +74,32 @@ def build_commands():
)
def build_snippets():
_package_type("snippets")
for folder in SNIPPETS_FOLDERS:
java_library(
name = folder + "-snippet",
srcs = native.glob(["src/main/java/edu/wpi/first/wpilibj/snippets/" + folder + "/**/*.java"]),
deps = [
"//wpilibj:wpilibj",
"//wpilibj:wpilibj-java",
],
tags = ["wpi-example"],
)
def build_templates():
_package_type("templates")
for folder in TEMPLATES_FOLDERS:
java_library(
name = folder + "-template",
srcs = native.glob(["src/main/java/edu/wpi/first/wpilibj/templates/" + folder + "/**/*.java"]),
deps = [
"//hal:hal-java",
"//wpilibj:wpilibj",
"//wpilibj:wpilibj-java",
"//wpilibNewCommands:wpilibNewCommands-java",
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
"//xrpVendordep:xrp-java",
"//xrpVendordep:xrpVendordep-java",
],
tags = ["wpi-example"],
)
@@ -79,8 +112,8 @@ def build_tests():
deps = [
":" + folder + "-example",
"//hal:hal-java",
"//ntcore:networktables-java",
"//wpilibj:wpilibj",
"//ntcore:ntcore-java",
"//wpilibj:wpilibj-java",
"//wpilibNewCommands:wpilibNewCommands-java",
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",

View File

@@ -2,10 +2,12 @@ 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//pkg:zip.bzl", "pkg_zip")
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:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_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", "pkg_java_files")
load("//wpimath:generate.bzl", "generate_wpimath")
filegroup(
@@ -110,7 +112,7 @@ cc_library(
)
wpilib_cc_library(
name = "wpimath.static",
name = "wpimath",
srcs = glob(
[
"src/main/native/cpp/**",
@@ -120,6 +122,9 @@ wpilib_cc_library(
),
hdrs = glob(["src/main/native/include/**"]),
defines = ["WPILIB_EXPORTS"],
extra_src_pkg_files = [
":wpimath-java-jni-hdrs-pkg",
],
includes = [
"src/main/native/include",
"src/main/native/thirdparty/sleipnir/src",
@@ -135,7 +140,18 @@ wpilib_cc_library(
visibility = ["//visibility:public"],
deps = [
":nanopb-generated-headers",
"//wpiutil:wpiutil.static",
"//wpiutil",
],
)
wpilib_cc_static_library(
name = "static/wpimath",
static_deps = [
"//wpiutil:static/wpiutil",
],
visibility = ["//visibility:public"],
deps = [
":wpimath",
],
)
@@ -145,7 +161,7 @@ wpilib_jni_cc_library(
java_dep = ":wpimath-java",
visibility = ["//visibility:public"],
deps = [
":wpimath.static",
":wpimath",
],
)
@@ -153,9 +169,11 @@ wpilib_jni_java_library(
name = "wpimath-java",
srcs = [":generated_java"] + glob(["src/main/java/**/*.java"]),
native_libs = [":wpimathjni"],
resource_strip_prefix = "wpimath/src/main/proto",
resources = glob(["src/main/proto/**"]),
visibility = ["//visibility:public"],
deps = [
"//wpiunits",
"//wpiunits:wpiunits-java",
"//wpiutil:wpiutil-java",
"@maven//:com_fasterxml_jackson_core_jackson_annotations",
"@maven//:com_fasterxml_jackson_core_jackson_core",
@@ -167,6 +185,14 @@ wpilib_jni_java_library(
],
)
pkg_java_files(name = "wpimath-java-srcs")
pkg_zip(
name = "libwpimath-java-sources",
srcs = [":wpimath-java-srcs"],
out = "libwpimath-java-sources.jar",
)
cc_library(
name = "test_headers",
hdrs = glob([
@@ -182,10 +208,14 @@ cc_test(
"src/test/native/cpp/**/*.cpp",
"src/test/native/cpp/**/*.h",
]),
tags = [
"no-bullseye",
"no-raspi",
],
deps = [
":test_headers",
":wpimath.static",
"//thirdparty/googletest:googletest.static",
":wpimath",
"//thirdparty/googletest",
],
)
@@ -194,7 +224,7 @@ wpilib_java_junit5_test(
srcs = glob(["src/test/java/**/*.java"]),
deps = [
":wpimath-java",
"//wpiunits",
"//wpiunits:wpiunits-java",
"//wpiutil:wpiutil-java",
"@maven//:org_ejml_ejml_core",
"@maven//:org_ejml_ejml_simple",
@@ -206,7 +236,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":wpimath.static",
":wpimath",
],
)

View File

@@ -1,6 +1,7 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary")
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_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/gen:gen-resources.bzl", "generate_resources")
@@ -69,6 +70,19 @@ filegroup(
"@bazel_tools//src/conditions:windows": WIN_UV_SRCS,
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_UV_SRCS,
}) + glob(["src/main/native/thirdparty/libuv/src/*"]),
visibility = ["//wpinet:__subpackages__"],
)
pkg_files(
name = "thirdparty-libuv-hdr-pkg",
srcs = glob(["src/main/native/thirdparty/libuv/include/**"]),
strip_prefix = "src/main/native/thirdparty/libuv/include",
)
pkg_files(
name = "thirdparty-libuv-src-pkg",
srcs = glob(["src/main/native/thirdparty/libuv/src/**"]),
strip_prefix = "src/main/native/thirdparty/libuv/src",
)
third_party_cc_lib_helper(
@@ -102,7 +116,7 @@ cc_library(
)
wpilib_cc_library(
name = "wpinet.static",
name = "wpinet",
srcs = glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
@@ -110,12 +124,17 @@ wpilib_cc_library(
":libuv-srcs",
] + ["native-srcs"],
hdrs = glob(["src/main/native/include/**/*"]),
implementation_deps = [
":private_includes",
extra_hdr_pkg_files = [":thirdparty-libuv-hdr-pkg"],
extra_src_pkg_files = [
":wpinet-java-jni-hdrs-pkg",
],
includes = ["src/main/native/include"],
linkopts = select({
"@bazel_tools//src/conditions:linux": ["-ldl"],
"@bazel_tools//src/conditions:linux": [
"-Wl,--push-state,-as-needed",
"-ldl",
"-Wl,--pop-state",
],
"//conditions:default": [],
}),
strip_include_prefix = "src/main/native/include",
@@ -125,7 +144,19 @@ wpilib_cc_library(
visibility = ["//visibility:public"],
deps = [
":libuv-headers",
"//wpiutil:wpiutil.static",
":private_includes",
"//wpiutil",
],
)
wpilib_cc_static_library(
name = "static/wpinet",
static_deps = [
"//wpiutil:static/wpiutil",
],
visibility = ["//visibility:public"],
deps = [
":wpinet",
],
)
@@ -138,7 +169,7 @@ wpilib_jni_cc_library(
java_dep = ":wpinet-java",
visibility = ["//visibility:public"],
deps = [
":wpinet.static",
":wpinet",
],
)
@@ -161,9 +192,8 @@ cc_test(
]),
tags = ["no-asan"],
deps = [
":private_includes",
":wpinet.static",
"//thirdparty/googletest:googletest.static",
":wpinet",
"//thirdparty/googletest",
"//wpiutil:wpiutil-testlib",
],
)
@@ -180,7 +210,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":wpinet.static",
":wpinet",
],
)
@@ -202,7 +232,7 @@ cc_binary(
"//conditions:default": [],
}),
deps = [
":wpinet.static",
":wpinet",
],
)
@@ -210,7 +240,7 @@ cc_binary(
name = "netconsoleTee",
srcs = ["src/netconsoleTee/native/cpp/main.cpp"],
deps = [
":wpinet.static",
":wpinet",
],
)
@@ -218,7 +248,7 @@ cc_binary(
name = "dsclient",
srcs = ["examples/dsclient/dsclient.cpp"],
deps = [
":wpinet.static",
":wpinet",
],
)
@@ -226,7 +256,7 @@ cc_binary(
name = "parallelconnect",
srcs = ["examples/parallelconnect/parallelconnect.cpp"],
deps = [
":wpinet.static",
":wpinet",
],
)
@@ -234,6 +264,6 @@ cc_binary(
name = "webserver",
srcs = ["examples/webserver/webserver.cpp"],
deps = [
":wpinet.static",
":wpinet",
],
)

View File

@@ -1,8 +1,10 @@
load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
load("//shared/bazel/rules:packaging.bzl", "pkg_java_files")
load("//wpiunits:generate_wpiunits.bzl", "generate_wpiunits")
py_binary(
@@ -31,17 +33,25 @@ write_source_files(
)
java_library(
name = "wpiunits",
name = "wpiunits-java",
srcs = glob(["src/main/java/**/*.java"]) + glob(["src/generated/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [],
)
pkg_java_files(name = "wpiunits-java-srcs")
pkg_zip(
name = "libwpiunits-java-sources",
srcs = [":wpiunits-java-srcs"],
out = "libwpiunits-java-sources.jar",
)
wpilib_java_junit5_test(
name = "wpiunits-test",
srcs = glob(["src/test/java/**/*.java"]),
deps = [
":wpiunits",
":wpiunits-java",
],
)
@@ -50,6 +60,6 @@ java_binary(
srcs = ["src/dev/java/edu/wpi/first/units/DevMain.java"],
main_class = "edu.wpi.first.units.DevMain",
deps = [
":wpiunits",
":wpiunits-java",
],
)

View File

@@ -2,10 +2,12 @@ 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//pkg:zip.bzl", "pkg_zip")
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:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_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", "pkg_java_files")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
load("//wpiutil:generate.bzl", "generate_wpiutil")
@@ -59,6 +61,7 @@ write_source_files(
third_party_cc_lib_helper(
name = "argparse",
include_root = "src/main/native/thirdparty/argparse/include",
src_root = None,
)
third_party_cc_lib_helper(
@@ -134,7 +137,7 @@ filegroup(
)
wpilib_cc_library(
name = "wpiutil.static",
name = "wpiutil",
srcs = glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
@@ -143,6 +146,7 @@ wpilib_cc_library(
":native-srcs",
],
hdrs = glob(["src/main/native/include/**/*"]),
extra_src_pkg_files = [":wpiutil-java-jni-hdrs-pkg"],
includes = ["src/main/native/include"],
strip_include_prefix = "src/main/native/include",
third_party_header_only_libraries = [
@@ -167,13 +171,46 @@ wpilib_cc_library(
}),
)
wpilib_cc_static_library(
name = "static/wpiutil",
visibility = ["//visibility:public"],
deps = [
":wpiutil",
],
)
cc_library(
name = "wpiutil-jni-hdrs",
hdrs = glob([
"src/main/native/include/**",
"src/main/native/thirdparty/llvm/include/**",
"src/main/native/thirdparty/fmtlib/include/**",
]),
includes = [
"src/main/native/include",
"src/main/native/thirdparty/fmtlib/include",
"src/main/native/thirdparty/llvm/include",
],
)
wpilib_jni_cc_library(
name = "wpiutiljni",
srcs = glob(["src/main/native/cpp/jni/**"]),
java_dep = ":wpiutil-java",
visibility = ["//visibility:public"],
deps = [
":wpiutil.static",
":wpiutil",
],
)
wpilib_cc_static_library(
name = "static/wpiutiljni",
static_deps = [
":static/wpiutil",
],
visibility = ["//visibility:public"],
deps = [
":wpiutiljni",
],
)
@@ -190,6 +227,14 @@ wpilib_jni_java_library(
],
)
pkg_java_files(name = "wpiutil-java-srcs")
pkg_zip(
name = "libwpiutil-java-sources",
srcs = [":wpiutil-java-srcs"],
out = "libwpiutil-java-sources.jar",
)
cc_library(
name = "wpiutil-testlib",
hdrs = glob(["src/test/native/include/**"]),
@@ -215,9 +260,9 @@ cc_test(
tags = ["no-tsan"], # TODO(pj.reiniger) Find problem
deps = [
":nanopb-test-headers",
":wpiutil.static",
":wpiutil",
":wpiutil-testlib",
"//thirdparty/googletest:googletest.static",
"//thirdparty/googletest",
],
)
@@ -233,7 +278,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":wpiutil.static",
":wpiutil",
],
)

View File

@@ -1,9 +1,9 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
wpilib_cc_library(
name = "xrp-cpp",
name = "xrpVendordep",
srcs = glob([
"src/main/native/cpp/**",
]),
@@ -11,17 +11,30 @@ wpilib_cc_library(
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpilibc:wpilibc.static",
"//ntcore",
"//wpilibc",
"//wpinet",
],
)
wpilib_cc_static_library(
name = "static/xrpVendordep",
static_deps = [
"//ntcore:static/ntcore",
"//wpilibc:static/wpilibc",
"//wpinet:static/wpinet",
],
visibility = ["//visibility:public"],
deps = [":xrpVendordep"],
)
java_library(
name = "xrp-java",
name = "xrpVendordep-java",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//hal:hal-java",
"//wpilibj",
"//wpilibj:wpilibj-java",
"//wpimath:wpimath-java",
],
)
@@ -31,7 +44,8 @@ cc_test(
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
deps = [
"//thirdparty/googletest:googletest.static",
":xrpVendordep",
"//thirdparty/googletest",
],
)
@@ -39,7 +53,7 @@ cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
"//wpiutil:wpiutil.static",
"//wpiutil",
],
)
@@ -49,7 +63,7 @@ java_binary(
main_class = "edu.wpi.first.wpilibj.xrp.DevMain",
deps = [
"//hal:hal-java",
"//ntcore:networktables-java",
"//ntcore:ntcore-java",
"//wpiutil:wpiutil-java",
],
)