From cfab47e871766782cb15a4d12633a660c6ce74a3 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 19 Jun 2026 18:25:07 -0400 Subject: [PATCH] [bazel] Improve vendored deps, make libssh vendored (#8948) TL;DR: kill https://github.com/wpilibsuite/bzlmodRio-libssh, update versions, and make things easier for a script to update. The main motivation behind this was that libssh was out of date with the gradle version. Using these "external" dependencies can cause agita as we churn through toolchain updates. Unlike the toolchains and opencv, which can be used by external users (i.e. a all bazel robot, if a vendor wanted to use bazel) a C++ wrapper around libssh maven deps almost certainly wouldn't be pulled in, much like ceres and mrclib. As a result of vendor'ing libssh, and knowing some potential pitfalls and annoyances, this PR does the following: - Vendor libssh, akin to how mrclib is pulled in - Moves the vendor'd ceres to `shared/bazel/thirdparty`, and refactors it to better match mrclib. To me it doesn't necessarily belong in its `thirdparty` location because it is bazel only. - Due to the refactoring, libssh and ceres can now be pulled into `MODULE.bazel` instead of the `WORKSPACE.bzlmod` helper. This is good prep for a potential upgrade to killing `--enable_workspace` / bazel 9 - Write a python script that can deal with the integrity / sha256 of the http_archives. I suggested this be added to davo's mrclib PR, but this one is a little bit more robust and will actually edit the files in place. This makes upgrading versions substantially easier. - Upgrade libssh version to what gradle is using, and mrclib to the version in #8858. These changes have been tested against that PR. --- MODULE.bazel | 4 + WORKSPACE | 0 WORKSPACE.bzlmod | 14 -- .../bazel/thirdparty}/ceres/BUILD.bazel | 0 .../bazel/thirdparty/ceres/ceres.MODULE.bazel | 60 ++++++ shared/bazel/thirdparty/integrity_helper.py | 190 ++++++++++++++++++ shared/bazel/thirdparty/libssh/BUILD.bazel | 28 +++ .../thirdparty/libssh/libssh.MODULE.bazel | 63 ++++++ shared/bazel/thirdparty/mrclib/BUILD.bazel | 4 +- .../thirdparty/mrclib/mrclib.MODULE.bazel | 103 ++++------ shared/ceres.gradle | 1 + shared/libssh.gradle | 1 + thirdparty/ceres/repositories.bzl | 60 ------ tools/datalogtool/BUILD.bazel | 2 +- tools/wpical/BUILD.bazel | 4 +- 15 files changed, 387 insertions(+), 147 deletions(-) create mode 100644 WORKSPACE rename {thirdparty => shared/bazel/thirdparty}/ceres/BUILD.bazel (100%) create mode 100644 shared/bazel/thirdparty/ceres/ceres.MODULE.bazel create mode 100644 shared/bazel/thirdparty/integrity_helper.py create mode 100644 shared/bazel/thirdparty/libssh/BUILD.bazel create mode 100644 shared/bazel/thirdparty/libssh/libssh.MODULE.bazel delete mode 100644 thirdparty/ceres/repositories.bzl diff --git a/MODULE.bazel b/MODULE.bazel index d059ab4a2c..a72e420cfa 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -5,6 +5,10 @@ module( include("//docs:doxygen.MODULE.bazel") +include("//shared/bazel/thirdparty/ceres:ceres.MODULE.bazel") + +include("//shared/bazel/thirdparty/libssh:libssh.MODULE.bazel") + include("//shared/bazel/thirdparty/mrclib:mrclib.MODULE.bazel") bazel_dep(name = "apple_support", version = "2.0.0", repo_name = "build_bazel_apple_support") diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index c19ff662d5..e1cf49a68e 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -1,9 +1,5 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("//thirdparty/ceres:repositories.bzl", "ceres_repositories") - -ceres_repositories() - http_archive( name = "pybind11_bazel", integrity = "sha256-iwRj1wuX2pDS6t6DqiCfhIXisv4y+7CvxSJtZoSAzGw=", @@ -29,16 +25,6 @@ load("@bzlmodrio-opencv//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_opencv_cp setup_legacy_bzlmodrio_opencv_cpp_dependencies() -http_archive( - name = "bzlmodrio-libssh", - sha256 = "f8fef627c7b393f7f6ed638e12b80ff90b2cfea11488b15214f25ce1e470723a", - url = "https://github.com/wpilibsuite/bzlmodRio-libssh/releases/download/2024.0.105-1.bcr1/bzlmodrio-libssh-2024.0.105-1.bcr1.tar.gz", -) - -load("@bzlmodrio-libssh//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_libssh_cpp_dependencies") - -setup_legacy_bzlmodrio_libssh_cpp_dependencies() - # Capture the repository environmental variables which specify the filter list for what architectures to build in CI. load("//shared/bazel/rules:publishing_rule.bzl", "publishing_repo") diff --git a/thirdparty/ceres/BUILD.bazel b/shared/bazel/thirdparty/ceres/BUILD.bazel similarity index 100% rename from thirdparty/ceres/BUILD.bazel rename to shared/bazel/thirdparty/ceres/BUILD.bazel diff --git a/shared/bazel/thirdparty/ceres/ceres.MODULE.bazel b/shared/bazel/thirdparty/ceres/ceres.MODULE.bazel new file mode 100644 index 0000000000..e1c4c00275 --- /dev/null +++ b/shared/bazel/thirdparty/ceres/ceres.MODULE.bazel @@ -0,0 +1,60 @@ +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +################################################################################ +# Generated by shared/bazel/thirdparty/integrity_helper.py +url_pattern = "https://frcmaven.wpi.edu/artifactory/development/edu/wpi/first/thirdparty/frc2026/ceres/ceres-cpp/2.2-1/ceres-cpp-2.2-1-%s.zip" + +headers_integrity = "sha256-ITP1hirOrcna3tyOUQyniUGPw5JeeC8Ffm5scno865w=" + +_LIB_ARTIFACTS = { + "linuxarm32static": ("linux", "**/*.a", "sha256-ptlO1AuEWz84nAZn0fdXDf6fRsfj1EQu+/FR7PQO8Pk="), + "linuxarm32staticdebug": ("linux", "**/*.a", "sha256-1n5wFPsML0HYuOodbiDTT4taxo5k/IC7to7YBPQtM1Q="), + "linuxarm64static": ("linux", "**/*.a", "sha256-sBoNq7nTyllKJnOvyNm+IAxnKi8wP3YymaMwK2m8qCw="), + "linuxarm64staticdebug": ("linux", "**/*.a", "sha256-44RmHzCSx8rptaaP3DC2IbTy4p61oAHzfzvomCALk6I="), + "linuxx86-64static": ("linux", "**/*.a", "sha256-ntuu0fS01f/vkL4rMaYEuUaDvuYqQwwqLKcQy6yJwd8="), + "linuxx86-64staticdebug": ("linux", "**/*.a", "sha256-2CmV1Z+gM3AKq/+rC9WSn8Gkx/OXLnVMjHlGT1kmB/c="), + "osxuniversalstatic": ("osx", "**/*.a", "sha256-ExnU2z+kGU0iaYRmOpcPCLWdwIDKhVpQnN2g6iJ/z/U="), + "osxuniversalstaticdebug": ("osx", "**/*.a", "sha256-dnqxm5qgVBKD43ORCIkYH+mXi7oQQKbCTWDY1GdTNfQ="), + "windowsarm64static": ("windows", "**/*.lib", "sha256-obWGoORklu5g//x7CmykDX4S4g7ixy9RECdui5zy28g="), + "windowsarm64staticdebug": ("windows", "**/*.lib", "sha256-iL/rdZ2i+9+48IxQEK3Ty8/zQkp/1h9halDG9YEEXz0="), + "windowsx86-64static": ("windows", "**/*.lib", "sha256-wPhWBdyEC3AK6KgUgbvJsxWODGPSUMbAZmdEE7zSJ9Y="), + "windowsx86-64staticdebug": ("windows", "**/*.lib", "sha256-ibozSdLVUEYAuECwKtTKrqZB5pNFdajktwF2TEw+aDg="), +} +# End auto-gen +################################################################################ + +http_archive( + name = "ceres_headers", + build_file_content = """ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "headers", + hdrs = glob(["ceres/**", "glog/**", "suitesparse/**", "openblas/**"]), + includes = ["."], + deps = ["@//wpimath:eigen-headers"], + visibility = ["//visibility:public"], +) +""", + integrity = headers_integrity, + url = url_pattern % "headers", +) + +library_build_content = """ +filegroup( + name = "lib", + srcs = glob(["%s"]), + visibility = ["//visibility:public"], +) +""" + +[ + http_archive( + name = "ceres_" + artifact, + build_file_content = library_build_content % glob_pattern, + integrity = integrity, + strip_prefix = prefix, + url = url_pattern % artifact, + ) + for artifact, (prefix, glob_pattern, integrity) in _LIB_ARTIFACTS.items() +] diff --git a/shared/bazel/thirdparty/integrity_helper.py b/shared/bazel/thirdparty/integrity_helper.py new file mode 100644 index 0000000000..e4759f418c --- /dev/null +++ b/shared/bazel/thirdparty/integrity_helper.py @@ -0,0 +1,190 @@ +import tempfile +import hashlib +from urllib.request import urlopen +import os +import base64 + + +def __try_download_sha(base_url, use_base64): + url = base_url + ".sha256" + print(f"Loading {url}") + + try: + url_result = urlopen(url) + except: + print(f"No uploaded sha256 hash at {url}") + return None + + data = url_result.read() + + sha_hex = data.decode("utf-8") + if use_base64: + return "sha256-" + base64.b64encode(bytes.fromhex(sha_hex)).decode("utf-8") + return sha_hex + + +def download_integrities( + module_file: str, + has_headers: bool, + classifiers: list[str], + url_base: str, + use_base64: bool, +): + hash_output = "# Generated by shared/bazel/thirdparty/integrity_helper.py\n" + + hash_output += f'url_pattern = "{url_base}"\n\n' + + if has_headers: + url = url_base % "headers" + sha = __try_download_sha(url, use_base64) + hash_output += f'headers_integrity = "{sha}"\n\n' + + hash_output += "_LIB_ARTIFACTS = {\n" + + static_glob_lookup = { + "linux": "**/*.a", + "osx": "**/*.a", + "windows": "**/*.lib", + } + + shared_glob_lookup = { + "linux": "**/*.so*", + "osx": "**/*.dylib", + "windows": "**/*.dll", + } + + for suffix in classifiers: + url = url_base % suffix + sha = __try_download_sha(url, use_base64) + + glob_lookup = static_glob_lookup if "static" in suffix else shared_glob_lookup + + if "linux" in suffix: + simple_suffix = "linux" + elif "osx" in suffix: + simple_suffix = "osx" + elif "windows" in suffix: + simple_suffix = "windows" + + hash_output += f' "{suffix}": ("{simple_suffix}", "{glob_lookup[simple_suffix]}", "{sha}"),\n' + + hash_output += "}\n" + hash_output += "# End auto-gen\n" + + updated_contents = "" + with open(module_file, "r") as f: + # Grab all the stuff before the auto gen + for line in f: + if line.startswith( + "# Generated by shared/bazel/thirdparty/integrity_helper.py" + ): + break + updated_contents += line + + updated_contents += hash_output + + # Skip the autogen chunk + for line in f: + if line.startswith("# End auto-gen"): + break + + updated_contents += "".join(f) + + with open(module_file, "w") as f: + f.write(updated_contents) + + # print(updated_contents) + + +def update_ceres(): + # Keep in sync with shared/ceres.gradle + year = "frc2026" + version = "2.2-1" + + has_headers = True + classifiers = [ + "linuxarm32static", + "linuxarm32staticdebug", + "linuxarm64static", + "linuxarm64staticdebug", + "linuxx86-64static", + "linuxx86-64staticdebug", + "osxuniversalstatic", + "osxuniversalstaticdebug", + "windowsarm64static", + "windowsarm64staticdebug", + "windowsx86-64static", + "windowsx86-64staticdebug", + ] + url_base = f"https://frcmaven.wpi.edu/artifactory/development/edu/wpi/first/thirdparty/{year}/ceres/ceres-cpp/{version}/ceres-cpp-{version}-%s.zip" + + download_integrities( + "shared/bazel/thirdparty/ceres/ceres.MODULE.bazel", + has_headers, + classifiers, + url_base, + True, + ) + + +def update_libssh(): + # Keep in sync with shared/libssh.gradle + version = "2027-0.120-1" + + has_headers = True + classifiers = [ + "linuxarm64static", + "linuxarm64staticdebug", + "linuxx86-64static", + "linuxx86-64staticdebug", + "osxuniversalstatic", + "osxuniversalstaticdebug", + "windowsx86-64static", + "windowsx86-64staticdebug", + "windowsarm64static", + "windowsarm64staticdebug", + ] + url_base = f"https://frcmaven.wpi.edu/release/org/wpilib/thirdparty/libssh/{version}/libssh-{version}-%s.zip" + + download_integrities( + "shared/bazel/thirdparty/libssh/libssh.MODULE.bazel", + has_headers, + classifiers, + url_base, + False, + ) + + +def update_mrclib(): + # Keep in sync with shared/libmrclib.gradle + version = "2027.1.0-alpha-1-50-gd008523" + + has_headers = True + classifiers = [ + "linuxarm64", + "linuxx86-64", + "osxuniversal", + "linuxsystemcore", + "windowsarm64", + "windowsx86-64", + ] + url_base = f"https://frcmaven.wpi.edu/artifactory/development-2027/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-%s.zip" + + download_integrities( + "shared/bazel/thirdparty/mrclib/mrclib.MODULE.bazel", + has_headers, + classifiers, + url_base, + False, + ) + + +def main(): + update_ceres() + update_libssh() + update_mrclib() + + +if __name__ == "__main__": + # python3 shared/bazel/thirdparty/integrity_helper.py + main() diff --git a/shared/bazel/thirdparty/libssh/BUILD.bazel b/shared/bazel/thirdparty/libssh/BUILD.bazel new file mode 100644 index 0000000000..1324336df7 --- /dev/null +++ b/shared/bazel/thirdparty/libssh/BUILD.bazel @@ -0,0 +1,28 @@ +load("@rules_cc//cc:defs.bzl", "cc_import") + +package(default_visibility = ["//visibility:public"]) + +cc_import( + name = "libssh", + linkopts = select({ + "@platforms//os:windows": [ + "-DEFAULTLIB:Iphlpapi.lib", + ], + "//conditions:default": [], + }), + static_library = select({ + "@rules_bzlmodrio_toolchains//conditions:linux_x86_64": "@libssh_linuxx86-64static//:static_libs", + "@rules_bzlmodrio_toolchains//conditions:linux_x86_64_debug": "@libssh_linuxx86-64staticdebug//:static_libs", + "@rules_bzlmodrio_toolchains//conditions:osx": "@libssh_osxuniversalstatic//:static_libs", + "@rules_bzlmodrio_toolchains//conditions:osx_debug": "@libssh_osxuniversalstaticdebug//:static_libs", + "@rules_bzlmodrio_toolchains//conditions:windows_arm64": "@libssh_windowsarm64static//:static_libs", + "@rules_bzlmodrio_toolchains//conditions:windows_arm64_debug": "@libssh_windowsarm64staticdebug//:static_libs", + "@rules_bzlmodrio_toolchains//conditions:windows_x86_64": "@libssh_windowsx86-64static//:static_libs", + "@rules_bzlmodrio_toolchains//conditions:windows_x86_64_debug": "@libssh_windowsx86-64staticdebug//:static_libs", + "@rules_bzlmodrio_toolchains//constraints/is_bookworm64:bookworm64": "@libssh_linuxarm64static//:static_libs", + "@rules_bzlmodrio_toolchains//constraints/is_bookworm64:bookworm64_debug": "@libssh_linuxarm64staticdebug//:static_libs", + }), + deps = [ + "@libssh_headers//:headers", + ], +) diff --git a/shared/bazel/thirdparty/libssh/libssh.MODULE.bazel b/shared/bazel/thirdparty/libssh/libssh.MODULE.bazel new file mode 100644 index 0000000000..580fc8f043 --- /dev/null +++ b/shared/bazel/thirdparty/libssh/libssh.MODULE.bazel @@ -0,0 +1,63 @@ +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +################################################################################ +# Generated by shared/bazel/thirdparty/integrity_helper.py +url_pattern = "https://frcmaven.wpi.edu/release/org/wpilib/thirdparty/libssh/2027-0.120-1/libssh-2027-0.120-1-%s.zip" + +headers_integrity = "ddd1f5078496ad3316cc2e35881380909fb536e450900a7d3efb57f1cefbf4d7" + +_LIB_ARTIFACTS = { + "linuxarm64static": ("linux", "**/*.a", "bf253a5dfec416137f1fad88c7ae5cb50d38757e60efcd0ef9ddf1f6af272b75"), + "linuxarm64staticdebug": ("linux", "**/*.a", "b93418670c1b93589d5851580afdfb1b69339b4606d52f9d7f0501e9a073cd17"), + "linuxx86-64static": ("linux", "**/*.a", "5d02d5aecc521d0c3cab5f3ec7c5668802f38337138e97fceb5e19a957888e60"), + "linuxx86-64staticdebug": ("linux", "**/*.a", "d7c75fabd584a6c155d3d784b8edeffa75296a96c03417a9fc0b4a5106c88210"), + "osxuniversalstatic": ("osx", "**/*.a", "7acdb5f49fb3aa5fcea9cf4b1d806a42ea845f9dd628d72dec55837de09f3d3e"), + "osxuniversalstaticdebug": ("osx", "**/*.a", "41863cf0a73256df147e6f72ead07b34111e13219dbdbabb082dea1ded8ece10"), + "windowsx86-64static": ("windows", "**/*.lib", "849be403d4785a432d377a0392332839d8e293401c0509bcf3a8ea0b8a9255cc"), + "windowsx86-64staticdebug": ("windows", "**/*.lib", "347116aa6173a916fbb3362634ccd996c771499a564ef2b455212e38e07b267d"), + "windowsarm64static": ("windows", "**/*.lib", "6d42d0854a6343ec30e7d569bddbfcefcafefcde8ed68f697ba7a0bc60446f2b"), + "windowsarm64staticdebug": ("windows", "**/*.lib", "51dd10884606d839ede280bafa1ffdcefc466ac034a24e600aac3aeddf9d0d02"), +} +# End auto-gen +################################################################################ + +http_archive( + name = "libssh_headers", + build_file_content = """ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "headers", + hdrs = glob(["**"]), + includes = ["."], + visibility = ["//visibility:public"], +) + +filegroup( + name = "header_files", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +) +""", + sha256 = headers_integrity, + url = url_pattern % "headers", +) + +library_build_content = """ +filegroup( + name = "static_libs", + srcs = glob(["%s"]), + visibility = ["//visibility:public"], +) +""" + +[ + http_archive( + name = "libssh_" + artifact, + build_file_content = library_build_content % glob_pattern, + sha256 = sha256, + strip_prefix = prefix, + url = url_pattern % artifact, + ) + for artifact, (prefix, glob_pattern, sha256) in _LIB_ARTIFACTS.items() +] diff --git a/shared/bazel/thirdparty/mrclib/BUILD.bazel b/shared/bazel/thirdparty/mrclib/BUILD.bazel index e60363443d..635a968fff 100644 --- a/shared/bazel/thirdparty/mrclib/BUILD.bazel +++ b/shared/bazel/thirdparty/mrclib/BUILD.bazel @@ -16,11 +16,11 @@ alias( name = "MrcLib", actual = select({ "@rules_bzlmodrio_toolchains//conditions:linux_x86_64": "@mrclib_linuxx86-64//:shared_libs", - "@rules_bzlmodrio_toolchains//conditions:osx": "@mrclib_osx//:shared_libs", + "@rules_bzlmodrio_toolchains//conditions:osx": "@mrclib_osxuniversal//:shared_libs", "@rules_bzlmodrio_toolchains//conditions:windows_arm64": "@mrclib_windowsarm64//:shared_libs", "@rules_bzlmodrio_toolchains//conditions:windows_x86_64": "@mrclib_windowsx86-64//:shared_libs", "@rules_bzlmodrio_toolchains//constraints/is_bookworm64:bookworm64": "@mrclib_linuxarm64//:shared_libs", - "@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": "@mrclib_systemcore//:shared_libs", + "@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": "@mrclib_linuxsystemcore//:shared_libs", }), visibility = ["//visibility:public"], ) diff --git a/shared/bazel/thirdparty/mrclib/mrclib.MODULE.bazel b/shared/bazel/thirdparty/mrclib/mrclib.MODULE.bazel index f6a911acf3..280662ed69 100644 --- a/shared/bazel/thirdparty/mrclib/mrclib.MODULE.bazel +++ b/shared/bazel/thirdparty/mrclib/mrclib.MODULE.bazel @@ -1,41 +1,26 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -cc_shared_library_build_contents = """ -filegroup( - name = "shared_interface", - srcs = glob(["**/*.lib"], allow_empty=True), - visibility = ["//visibility:public"], -) +################################################################################ +# Generated by shared/bazel/thirdparty/integrity_helper.py +url_pattern = "https://frcmaven.wpi.edu/artifactory/development-2027/org/wpilib/mrclib/mrclib-cpp/2027.1.0-alpha-1-50-gd008523/mrclib-cpp-2027.1.0-alpha-1-50-gd008523-%s.zip" -filegroup( - name = "shared_libs", - srcs = glob( - [ - "**/*.dll", - "**/*.so*", - "**/*.dylib", - ], - allow_empty = True, - ), - visibility = ["//visibility:public"], -) -""" +headers_integrity = "c71011e2c593749aca585eec308f394d5e7f34451c1a14cdd8e077ea3b1368b5" -mrclib_maven_base = "https://frcmaven.wpi.edu/artifactory/thirdparty-mvn-release" -mrclib_version = "2027.1.0-alpha-1-50-gd008523" - -mrclib_headers_hash = "c71011e2c593749aca585eec308f394d5e7f34451c1a14cdd8e077ea3b1368b5" -mrclib_linuxarm64_hash = "4673c573c25d1d9a03f1cf3d73c1e8a121718291171213813b95b451eea53f3a" -mrclib_linuxx86_64_hash = "8d986ed0ffb03be1215a3cf88716c31da82848f4524e723ac89aee4eca45eb12" -mrclib_osx_hash = "af05c46bffa58a1ca63bd18f4d8865b827746d1cdf94c8512c7f86d58731d16f" -mrclib_systemcore_hash = "c1cad49fb96caa73fddbc852588c67a2110402539b39dba40255c21974114e84" -mrclib_windowsarm64_hash = "8205701efbde585c6822981c7246c0a0d8e4b4cdb702097ec77674aa98aff7bb" -mrclib_windowsx86_64_hash = "dd4eef6e1aaba5b7034889a1646e259b3e91435b3084d43b3ff3b2c6adcc2122" +_LIB_ARTIFACTS = { + "linuxarm64": ("linux", "**/*.so*", "4673c573c25d1d9a03f1cf3d73c1e8a121718291171213813b95b451eea53f3a"), + "linuxx86-64": ("linux", "**/*.so*", "8d986ed0ffb03be1215a3cf88716c31da82848f4524e723ac89aee4eca45eb12"), + "osxuniversal": ("osx", "**/*.dylib", "af05c46bffa58a1ca63bd18f4d8865b827746d1cdf94c8512c7f86d58731d16f"), + "linuxsystemcore": ("linux", "**/*.so*", "c1cad49fb96caa73fddbc852588c67a2110402539b39dba40255c21974114e84"), + "windowsarm64": ("windows", "**/*.dll", "8205701efbde585c6822981c7246c0a0d8e4b4cdb702097ec77674aa98aff7bb"), + "windowsx86-64": ("windows", "**/*.dll", "dd4eef6e1aaba5b7034889a1646e259b3e91435b3084d43b3ff3b2c6adcc2122"), +} +# End auto-gen +################################################################################ http_archive( name = "mrclib_headers", - url = mrclib_maven_base + "/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-headers.zip".format(version = mrclib_version), - sha256 = mrclib_headers_hash, + url = url_pattern % "headers", + sha256 = headers_integrity, build_file_content = """ cc_library( name = "headers", @@ -46,44 +31,26 @@ cc_library( """, ) -http_archive( - name = "mrclib_linuxarm64", - url = mrclib_maven_base + "/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-linuxarm64.zip".format(version = mrclib_version), - sha256 = mrclib_linuxarm64_hash, - build_file_content = cc_shared_library_build_contents, +library_build_content = """ +filegroup( + name = "shared_interface", + srcs = glob(["**/*.lib"], allow_empty=True), + visibility = ["//visibility:public"], ) -http_archive( - name = "mrclib_linuxx86-64", - url = mrclib_maven_base + "/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-linuxx86-64.zip".format(version = mrclib_version), - sha256 = mrclib_linuxx86_64_hash, - build_file_content = cc_shared_library_build_contents, +filegroup( + name = "shared_libs", + srcs = glob(["%s"]), + visibility = ["//visibility:public"], ) +""" -http_archive( - name = "mrclib_osx", - url = mrclib_maven_base + "/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-osxuniversal.zip".format(version = mrclib_version), - sha256 = mrclib_osx_hash, - build_file_content = cc_shared_library_build_contents, -) - -http_archive( - name = "mrclib_systemcore", - url = mrclib_maven_base + "/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-linuxsystemcore.zip".format(version = mrclib_version), - sha256 = mrclib_systemcore_hash, - build_file_content = cc_shared_library_build_contents, -) - -http_archive( - name = "mrclib_windowsarm64", - url = mrclib_maven_base + "/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-windowsarm64.zip".format(version = mrclib_version), - sha256 = mrclib_windowsarm64_hash, - build_file_content = cc_shared_library_build_contents, -) - -http_archive( - name = "mrclib_windowsx86-64", - url = mrclib_maven_base + "/org/wpilib/mrclib/mrclib-cpp/{version}/mrclib-cpp-{version}-windowsx86-64.zip".format(version = mrclib_version), - sha256 = mrclib_windowsx86_64_hash, - build_file_content = cc_shared_library_build_contents, -) +[ + http_archive( + name = "mrclib_" + artifact, + url = url_pattern % artifact, + sha256 = integrity, + build_file_content = library_build_content % glob_pattern, + ) + for artifact, (prefix, glob_pattern, integrity) in _LIB_ARTIFACTS.items() +] diff --git a/shared/ceres.gradle b/shared/ceres.gradle index c9a9276369..61b88ef552 100644 --- a/shared/ceres.gradle +++ b/shared/ceres.gradle @@ -6,6 +6,7 @@ nativeUtils { headerClassifier = "headers" sourceClassifier = "sources" ext = "zip" + // Keep in sync with shared/bazel/thirdparty/integrity_helper.py version = '2.2-1' targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms) targetPlatforms.addAll("linuxarm32", "linuxarm64") diff --git a/shared/libssh.gradle b/shared/libssh.gradle index e9ba0a8188..61b65394e3 100644 --- a/shared/libssh.gradle +++ b/shared/libssh.gradle @@ -6,6 +6,7 @@ nativeUtils { headerClassifier = "headers" sourceClassifier = "sources" ext = "zip" + // Keep in sync with shared/bazel/thirdparty/integrity_helper.py version = '2027-0.120-1' targetPlatforms.addAll(nativeUtils.wpi.platforms.allPlatforms) } diff --git a/thirdparty/ceres/repositories.bzl b/thirdparty/ceres/repositories.bzl deleted file mode 100644 index a39df31411..0000000000 --- a/thirdparty/ceres/repositories.bzl +++ /dev/null @@ -1,60 +0,0 @@ -""" Starlark file for ceres repository definitions """ - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -def ceres_repositories(): - """ Fetches the ceres solver libraries """ - year = "frc2026" - version = "2.2-1" - - http_archive( - name = "ceres_headers", - build_file_content = """ -load(\"@rules_cc//cc:defs.bzl\", \"cc_library\") - -cc_library( - name = \"headers\", - hdrs = glob(["ceres/**", "glog/**", "suitesparse/**", "openblas/**"]), - includes = ["."], - deps = ["@//wpimath:eigen-headers"], - visibility = [\"//visibility:public\"], -) -""", - url = "https://frcmaven.wpi.edu/artifactory/development/edu/wpi/first/thirdparty/" + year + "/ceres/ceres-cpp/" + version + "/ceres-cpp-" + version + "-headers.zip", - integrity = "sha256-ITP1hirOrcna3tyOUQyniUGPw5JeeC8Ffm5scno865w=", - ) - - _LIB_ARTIFACTS = { - "linuxarm32static": ("linux", "**/*.a", "sha256-ptlO1AuEWz84nAZn0fdXDf6fRsfj1EQu+/FR7PQO8Pk="), - "linuxarm32staticdebug": ("linux", "**/*.a", "sha256-1n5wFPsML0HYuOodbiDTT4taxo5k/IC7to7YBPQtM1Q="), - "linuxarm64static": ("linux", "**/*.a", "sha256-sBoNq7nTyllKJnOvyNm+IAxnKi8wP3YymaMwK2m8qCw="), - "linuxarm64staticdebug": ("linux", "**/*.a", "sha256-44RmHzCSx8rptaaP3DC2IbTy4p61oAHzfzvomCALk6I="), - "linuxx86-64static": ("linux", "**/*.a", "sha256-ntuu0fS01f/vkL4rMaYEuUaDvuYqQwwqLKcQy6yJwd8="), - "linuxx86-64staticdebug": ("linux", "**/*.a", "sha256-2CmV1Z+gM3AKq/+rC9WSn8Gkx/OXLnVMjHlGT1kmB/c="), - "osxuniversalstatic": ("osx", "**/*.a", "sha256-ExnU2z+kGU0iaYRmOpcPCLWdwIDKhVpQnN2g6iJ/z/U="), - "osxuniversalstaticdebug": ("osx", "**/*.a", "sha256-dnqxm5qgVBKD43ORCIkYH+mXi7oQQKbCTWDY1GdTNfQ="), - "windowsarm64static": ("windows", "**/*.lib", "sha256-obWGoORklu5g//x7CmykDX4S4g7ixy9RECdui5zy28g="), - "windowsarm64staticdebug": ("windows", "**/*.lib", "sha256-iL/rdZ2i+9+48IxQEK3Ty8/zQkp/1h9halDG9YEEXz0="), - "windowsx86-64static": ("windows", "**/*.lib", "sha256-wPhWBdyEC3AK6KgUgbvJsxWODGPSUMbAZmdEE7zSJ9Y="), - "windowsx86-64staticdebug": ("windows", "**/*.lib", "sha256-ibozSdLVUEYAuECwKtTKrqZB5pNFdajktwF2TEw+aDg="), - } - - for artifact, (prefix, glob_pattern, integrity) in _LIB_ARTIFACTS.items(): - repo_name = "ceres_" + artifact - build_file_content = """ -filegroup( - name = \"lib\", - srcs = glob([\"%s\"]), - visibility = [\"//visibility:public\"], -) -""" % glob_pattern - - url_fname = "ceres-cpp-" + version + "-" + artifact + ".zip" - - http_archive( - name = repo_name, - build_file_content = build_file_content, - strip_prefix = prefix, - url = "https://frcmaven.wpi.edu/artifactory/development/edu/wpi/first/thirdparty/" + year + "/ceres/ceres-cpp/" + version + "/" + url_fname, - integrity = integrity, - ) diff --git a/tools/datalogtool/BUILD.bazel b/tools/datalogtool/BUILD.bazel index 15497fcd07..880adb2299 100644 --- a/tools/datalogtool/BUILD.bazel +++ b/tools/datalogtool/BUILD.bazel @@ -53,7 +53,7 @@ cc_binary( deps = [ "//datalog", "//glass", - "@bzlmodrio-libssh//libraries/cpp/libssh", + "//shared/bazel/thirdparty/libssh", ], ) diff --git a/tools/wpical/BUILD.bazel b/tools/wpical/BUILD.bazel index ade7ea66c7..b3db07aead 100644 --- a/tools/wpical/BUILD.bazel +++ b/tools/wpical/BUILD.bazel @@ -190,7 +190,7 @@ wpilib_cc_library( deps = [ ":headers", "//apriltag", - "//thirdparty/ceres", + "//shared/bazel/thirdparty/ceres", "//wpigui", "//wpiutil", "@bzlmodrio-opencv//libraries/cpp/opencv", @@ -235,7 +235,7 @@ cc_test( ], deps = [ ":wpical_lib", - "//thirdparty/ceres", + "//shared/bazel/thirdparty/ceres", "//thirdparty/googletest", "@bazel_tools//tools/cpp/runfiles", ],