mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[bazel] Implement cscore shared libraries (#8089)
Use all our fancy new linking code to link cscore properly. nm reports that the symbols look quite good. Signed-off-by: Austin Schuh <austin.linux@gmail.com> Co-authored-by: PJ Reiniger <pj.reiniger@gmail.com> Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
load("@bzlmodrio-opencv//libraries/cpp/opencv:libraries.bzl", "opencv_shared_libraries")
|
||||
load("@rules_cc//cc:cc_shared_library.bzl", "cc_shared_library")
|
||||
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", "wpilib_cc_static_library")
|
||||
load("//shared/bazel/rules:cc_rules.bzl", "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:objectivec_rules.bzl", "wpilib_objc_library")
|
||||
@@ -21,8 +23,8 @@ 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,
|
||||
"@platforms//os:osx": MAC_SRCS,
|
||||
"@platforms//os:windows": WIN_SRCS,
|
||||
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_SRCS,
|
||||
}),
|
||||
)
|
||||
@@ -79,11 +81,56 @@ wpilib_cc_library(
|
||||
"//wpiutil",
|
||||
"@bzlmodrio-opencv//libraries/cpp/opencv",
|
||||
] + select({
|
||||
"@bazel_tools//src/conditions:darwin": [":cscore-mac"],
|
||||
"@platforms//os:osx": [":cscore-mac"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
sdk_framework_flags = [
|
||||
"-framework",
|
||||
"Metal",
|
||||
"-framework",
|
||||
"MetalKit",
|
||||
"-framework",
|
||||
"Cocoa",
|
||||
"-framework",
|
||||
"IOKit",
|
||||
"-framework",
|
||||
"CoreFoundation",
|
||||
"-framework",
|
||||
"AVFoundation",
|
||||
"-framework",
|
||||
"Foundation",
|
||||
"-framework",
|
||||
"CoreMedia",
|
||||
"-framework",
|
||||
"CoreVideo",
|
||||
"-framework",
|
||||
"QuartzCore",
|
||||
]
|
||||
|
||||
wpilib_cc_shared_library(
|
||||
name = "shared/cscore",
|
||||
additional_linker_inputs = select({
|
||||
"@platforms//os:osx": [":cscore-mac"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
dynamic_deps = [
|
||||
"//wpinet:shared/wpinet",
|
||||
"//wpiutil:shared/wpiutil",
|
||||
] + opencv_shared_libraries,
|
||||
user_link_flags = select({
|
||||
"@platforms//os:osx": [
|
||||
"-Wl,-force_load,$(location :cscore-mac)",
|
||||
] + sdk_framework_flags,
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":cscore",
|
||||
],
|
||||
)
|
||||
|
||||
wpilib_cc_static_library(
|
||||
name = "static/cscore",
|
||||
static_deps = [
|
||||
@@ -104,6 +151,53 @@ wpilib_jni_cc_library(
|
||||
],
|
||||
)
|
||||
|
||||
wpilib_cc_shared_library(
|
||||
name = "shared/cscorejni",
|
||||
dynamic_deps = [
|
||||
":shared/cscore",
|
||||
"//wpiutil:shared/wpiutil",
|
||||
],
|
||||
use_debug_name = False,
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":cscorejni"],
|
||||
)
|
||||
|
||||
cc_shared_library(
|
||||
name = "shared/cscorejnicvstatic",
|
||||
additional_linker_inputs = select({
|
||||
"@platforms//os:osx": [":cscore-mac"],
|
||||
"//conditions:default": [],
|
||||
}) + [
|
||||
":src/main/native/LinuxSymbolScript.txt",
|
||||
":src/main/native/MacSymbolScript.txt",
|
||||
],
|
||||
dynamic_deps = [
|
||||
"//wpinet:shared/wpinet",
|
||||
"//wpiutil:shared/wpiutil",
|
||||
] + opencv_shared_libraries,
|
||||
user_link_flags = select({
|
||||
"@platforms//os:osx": [
|
||||
"-Wl,-install_name,libcscorejnicvstatic.so",
|
||||
"-exported_symbols_list",
|
||||
"$(location :src/main/native/MacSymbolScript.txt)",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"-Wl,-soname,libcscorejnicvstatic.so",
|
||||
"-Wl,--version-script=$(location :src/main/native/LinuxSymbolScript.txt)",
|
||||
],
|
||||
}) + select({
|
||||
"@platforms//os:osx": [
|
||||
"-Wl,-force_load,$(location :cscore-mac)",
|
||||
] + sdk_framework_flags,
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":cscore",
|
||||
":cscorejni",
|
||||
],
|
||||
)
|
||||
|
||||
wpilib_jni_java_library(
|
||||
name = "cscore-java",
|
||||
srcs = glob(["src/main/java/**/*.java"]),
|
||||
@@ -165,6 +259,7 @@ java_binary(
|
||||
deps = [
|
||||
"//cscore",
|
||||
"//wpigui",
|
||||
"@bzlmodrio-opencv//libraries/cpp/opencv",
|
||||
],
|
||||
) for example in [
|
||||
"enum_usb",
|
||||
|
||||
Reference in New Issue
Block a user