From 2245dccff6ec0f53bf405ff667154bdcce3b1e36 Mon Sep 17 00:00:00 2001 From: Austin Schuh Date: Thu, 31 Jul 2025 23:02:56 -0700 Subject: [PATCH] [bazel] Link cscorestatic correctly (#8134) Statically link opencv, and make it work on all the architectures. --- cscore/BUILD.bazel | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/cscore/BUILD.bazel b/cscore/BUILD.bazel index 9a30ceb9fe..85f52bb4db 100644 --- a/cscore/BUILD.bazel +++ b/cscore/BUILD.bazel @@ -1,5 +1,4 @@ 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_shared_library", "wpilib_cc_static_library") @@ -162,7 +161,7 @@ wpilib_cc_shared_library( deps = [":cscorejni"], ) -cc_shared_library( +wpilib_cc_shared_library( name = "shared/cscorejnicvstatic", additional_linker_inputs = select({ "@platforms//os:osx": [":cscore-mac"], @@ -174,17 +173,18 @@ cc_shared_library( dynamic_deps = [ "//wpinet:shared/wpinet", "//wpiutil:shared/wpiutil", - ] + opencv_shared_libraries, + ], user_link_flags = select({ + "@platforms//os:linux": [ + "-Wl,-soname,libcscorejnicvstatic.so", + "-Wl,--version-script=$(location :src/main/native/LinuxSymbolScript.txt)", + ], "@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)", - ], + "//conditions:default": [], }) + select({ "@platforms//os:osx": [ "-Wl,-force_load,$(location :cscore-mac)", @@ -275,3 +275,13 @@ package_minimal_jni_project( maven_artifact_name = "cscore-cpp", maven_group_id = "edu.wpi.first.cscore", ) + +alias( + name = "cscorejnicvstatic-hdrs-zip", + actual = "cscore-hdrs-zip", +) + +alias( + name = "cscorejnicvstatic-srcs-zip", + actual = "cscore-srcs-zip", +)