Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bazel] MVP for building wpilibc + commands framework #7231

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,16 @@ setup_legacy_bzlmodrio_opencv_cpp_dependencies()
load("@bzlmodrio-opencv//:maven_java_deps.bzl", "setup_legacy_bzlmodrio_opencv_java_dependencies")

setup_legacy_bzlmodrio_opencv_java_dependencies()

http_archive(
name = "build_bazel_apple_support",
sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz",
)

load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)

apple_support_dependencies()
112 changes: 112 additions & 0 deletions apriltag/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")

cc_library(
name = "thirdparty-apriltag",
srcs = glob(["src/main/native/thirdparty/apriltag/src/**"]),
hdrs = glob(["src/main/native/thirdparty/apriltag/include/**"]),
copts = select({
"@bazel_tools//src/conditions:darwin": [
"-Wno-format-nonliteral",
"-Wno-gnu-zero-variadic-macro-arguments",
"-Wno-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
"@bazel_tools//src/conditions:windows": [
"/wd4005",
"/wd4018",
"/wd4244",
"/wd4267",
"/wd4996",
],
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [
"-Wno-format-nonliteral",
"-Wno-maybe-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
}),
includes = ["src/main/native/thirdparty/apriltag/include/common"],
strip_include_prefix = "src/main/native/thirdparty/apriltag/include",
visibility = ["//visibility:public"],
)

generate_resources(
name = "generate-resources",
namespace = "frc",
prefix = "APRILTAG",
resource_files = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
)

cc_library(
name = "apriltag.static",
srcs = [":generate-resources"] + glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
defines = ["WPILIB_EXPORTS"],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
":thirdparty-apriltag",
"//wpimath:wpimath.static",
"//wpiutil:wpiutil.static",
],
)

java_library(
name = "apriltag-java",
srcs = glob(["src/main/java/**/*.java"]),
resource_strip_prefix = "apriltag/src/main/native/resources",
resources = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
deps = [
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
"@bzlmodrio-opencv//libraries/java/opencv",
"@maven//:com_fasterxml_jackson_core_jackson_annotations",
"@maven//:com_fasterxml_jackson_core_jackson_core",
"@maven//:com_fasterxml_jackson_core_jackson_databind",
],
)

cc_test(
name = "apriltag-cpp-test",
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
tags = [
"no-asan",
],
deps = [
":apriltag.static",
"//thirdparty/googletest:googletest.static",
],
)

cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":apriltag.static",
],
)

java_binary(
name = "DevMain-Java",
srcs = ["src/dev/java/edu/wpi/first/apriltag/DevMain.java"],
main_class = "edu.wpi.first.apriltag.DevMain",
deps = [
":apriltag-java",
],
)

py_binary(
name = "convert_apriltag_layouts",
srcs = ["convert_apriltag_layouts.py"],
tags = ["manual"],
)
29 changes: 28 additions & 1 deletion cameraserver/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")

cc_library(
name = "cameraserver.static",
srcs = glob(["src/main/native/cpp/**"]),
hdrs = glob(["src/main/native/include/**/*"]),
includes = [
"cpp",
"src/main/native/include",
],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//cscore:cscore.static",
"//ntcore:ntcore.static",
],
)

java_library(
name = "cameraserver-java",
srcs = glob(["src/main/java/**/*.java"]),
Expand All @@ -16,10 +32,21 @@ java_library(
],
)

cc_test(
name = "cameraserver-cpp-test",
size = "small",
srcs = glob(["src/test/native/**"]),
deps = [
":cameraserver.static",
"//thirdparty/googletest:googletest.static",
],
)

cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":cameraserver.static",
],
)

Expand Down
89 changes: 89 additions & 0 deletions cscore/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")

WIN_SRCS = glob([
"src/main/native/windows/**/*.cpp",
"src/main/native/windows/**/*.h",
])

LINUX_SRCS = glob([
"src/main/native/linux/**/*.cpp",
"src/main/native/linux/**/*.h",
])

MAC_SRCS = glob(["src/main/native/osx/**/*.cpp"])

filegroup(
name = "native-srcs",
srcs = select({
"@bazel_tools//src/conditions:darwin": MAC_SRCS,
"@bazel_tools//src/conditions:windows": WIN_SRCS,
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_SRCS,
}),
)

objc_library(
name = "cscore-mac",
srcs = glob([
"src/main/native/objcpp/**/*.mm",
"src/main/native/cpp/*.h",
]),
hdrs = glob([
"src/main/native/include/**/*",
"src/main/native/objcpp/**/*.h",
]),
copts = [
"-std=c++20",
],
includes = [
"src/main/native/cpp",
"src/main/native/include",
"src/main/native/objcpp",
],
tags = ["manual"],
deps = [
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"@bzlmodrio-opencv//libraries/cpp/opencv",
],
)

cc_library(
name = "cscore.static",
srcs = [":native-srcs"] + glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
includes = [
"src/main/native/cpp",
"src/main/native/include",
],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"@bzlmodrio-opencv//libraries/cpp/opencv",
] + select({
"@bazel_tools//src/conditions:darwin": [":cscore-mac"],
"//conditions:default": [],
}),
)

java_library(
name = "cscore-java",
srcs = glob(["src/main/java/**/*.java"]),
Expand All @@ -10,6 +81,24 @@ java_library(
],
)

cc_test(
name = "cscore-cpp-test",
size = "small",
srcs = glob(["src/test/native/**"]),
deps = [
":cscore.static",
"//thirdparty/googletest:googletest.static",
],
)

cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":cscore.static",
],
)

java_binary(
name = "DevMain-Java",
srcs = ["src/dev/java/edu/wpi/first/cscore/DevMain.java"],
Expand Down
22 changes: 22 additions & 0 deletions epilogue-processor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
load("@rules_java//java:defs.bzl", "java_library", "java_plugin")

java_library(
name = "processor",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
runtime_deps = [
"//wpilibNewCommands:wpilibNewCommands-java",
],
deps = [
"//epilogue-runtime:epilogue",
],
)

java_plugin(
name = "plugin",
processor_class = "edu.wpi.first.epilogue.processor.AnnotationProcessor",
visibility = ["//visibility:public"],
deps = [
":processor",
],
)
12 changes: 12 additions & 0 deletions epilogue-runtime/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@rules_java//java:defs.bzl", "java_library")

java_library(
name = "epilogue",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//ntcore:networktables-java",
"//wpiunits",
"//wpiutil:wpiutil-java",
],
)
31 changes: 31 additions & 0 deletions fieldImages/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_java//java:defs.bzl", "java_library")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")

generate_resources(
name = "generate-resources",
namespace = "fields",
prefix = "FIELDS",
resource_files = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
)

cc_library(
name = "fieldImages",
srcs = [":generate-resources"] + glob(["src/main/native/cpp/**"]),
hdrs = glob(["src/main/native/include/**/*"]),
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
)

java_library(
name = "fieldImages-java",
srcs = glob(["src/main/java/**/*.java"]),
resource_strip_prefix = "fieldImages/src/main/native/resources",
resources = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
deps = [
"@maven//:com_fasterxml_jackson_core_jackson_annotations",
"@maven//:com_fasterxml_jackson_core_jackson_databind",
],
)
53 changes: 53 additions & 0 deletions romiVendordep/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")

cc_library(
name = "romi-cpp.static",
srcs = glob([
"src/main/native/cpp/**",
]),
hdrs = glob(["src/main/native/include/**"]),
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpilibc:wpilibc.static",
],
)

java_library(
name = "romi-java",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//hal:hal-java",
"//wpilibj",
],
)

cc_test(
name = "romi-test",
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
deps = [
"//thirdparty/googletest:googletest.static",
],
)

cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":romi-cpp.static",
],
)

java_binary(
name = "DevMain-Java",
srcs = ["src/dev/java/edu/wpi/first/wpilibj/romi/DevMain.java"],
main_class = "edu.wpi.first.wpilibj.romi.DevMain",
deps = [
"//hal:hal-java",
"//ntcore:networktables-java",
"//wpiutil:wpiutil-java",
],
)
Loading
Loading