From 9e57607390dbf2d605fb2bead29f72bff9a22c36 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Sun, 30 Jul 2023 12:07:26 -0700 Subject: [PATCH] [workspace] Deprecate picosha2 Use vendored picosha2_internal instead (with an ODR-safe namespace). Install the LICENSE file. --- geometry/render_gltf_client/BUILD.bazel | 2 +- multibody/parsing/BUILD.bazel | 4 ++-- tools/workspace/BUILD.bazel | 1 + tools/workspace/default.bzl | 5 ++++ tools/workspace/picosha2/package.BUILD.bazel | 1 + tools/workspace/picosha2/repository.bzl | 3 +++ tools/workspace/picosha2_internal/BUILD.bazel | 3 +++ .../picosha2_internal/package.BUILD.bazel | 23 +++++++++++++++++++ .../picosha2_internal/patches/vendor.patch | 18 +++++++++++++++ .../picosha2_internal/repository.bzl | 16 +++++++++++++ 10 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 tools/workspace/picosha2_internal/BUILD.bazel create mode 100644 tools/workspace/picosha2_internal/package.BUILD.bazel create mode 100644 tools/workspace/picosha2_internal/patches/vendor.patch create mode 100644 tools/workspace/picosha2_internal/repository.bzl diff --git a/geometry/render_gltf_client/BUILD.bazel b/geometry/render_gltf_client/BUILD.bazel index 73b76074957d..41577e258eb7 100644 --- a/geometry/render_gltf_client/BUILD.bazel +++ b/geometry/render_gltf_client/BUILD.bazel @@ -98,7 +98,7 @@ drake_cc_library( "//geometry/render:render_camera", "//geometry/render:render_engine", "//systems/sensors:image", - "@picosha2", + "@picosha2_internal//:picosha2", "@vtk//:vtkIOImage", ], ) diff --git a/multibody/parsing/BUILD.bazel b/multibody/parsing/BUILD.bazel index 0649e312e1d4..43227462deae 100644 --- a/multibody/parsing/BUILD.bazel +++ b/multibody/parsing/BUILD.bazel @@ -86,7 +86,7 @@ drake_cc_library( "//common:network_policy", "//common:scope_exit", "//common/yaml", - "@picosha2", + "@picosha2_internal//:picosha2", "@tinyxml2_internal//:tinyxml2", ], ) @@ -637,7 +637,7 @@ drake_cc_googletest( "//common:find_resource", "//common:scope_exit", "//common/test_utilities:expect_throws_message", - "@picosha2", + "@picosha2_internal//:picosha2", ], ) diff --git a/tools/workspace/BUILD.bazel b/tools/workspace/BUILD.bazel index 228b6715d95c..2f256a699cc1 100644 --- a/tools/workspace/BUILD.bazel +++ b/tools/workspace/BUILD.bazel @@ -96,6 +96,7 @@ _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [ "nlopt_internal", "org_apache_xmlgraphics_commons", "petsc", + "picosha2_internal", "pybind11", "qhull_internal", "sdformat_internal", diff --git a/tools/workspace/default.bzl b/tools/workspace/default.bzl index 31cb322ce8c3..42fcc4f33f7d 100644 --- a/tools/workspace/default.bzl +++ b/tools/workspace/default.bzl @@ -68,6 +68,7 @@ load("@drake//tools/workspace/org_apache_xmlgraphics_commons:repository.bzl", "o load("@drake//tools/workspace/osqp_internal:repository.bzl", "osqp_internal_repository") # noqa load("@drake//tools/workspace/petsc:repository.bzl", "petsc_repository") load("@drake//tools/workspace/picosha2:repository.bzl", "picosha2_repository") +load("@drake//tools/workspace/picosha2_internal:repository.bzl", "picosha2_internal_repository") # noqa load("@drake//tools/workspace/platforms:repository.bzl", "platforms_repository") # noqa load("@drake//tools/workspace/pybind11:repository.bzl", "pybind11_repository") load("@drake//tools/workspace/pycodestyle:repository.bzl", "pycodestyle_repository") # noqa @@ -247,7 +248,11 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): if "petsc" not in excludes: petsc_repository(name = "petsc", mirrors = mirrors) if "picosha2" not in excludes: + # The @picosha2 external is deprecated in Drake's WORKSPACE and will + # be removed on or after 2023-11-01. picosha2_repository(name = "picosha2", mirrors = mirrors) + if "picosha2_internal" not in excludes: + picosha2_internal_repository(name = "picosha2_internal", mirrors = mirrors) # noqa if "platforms" not in excludes: platforms_repository(name = "platforms", mirrors = mirrors) if "pybind11" not in excludes: diff --git a/tools/workspace/picosha2/package.BUILD.bazel b/tools/workspace/picosha2/package.BUILD.bazel index 949f41e42c2e..7f4ec762d64d 100644 --- a/tools/workspace/picosha2/package.BUILD.bazel +++ b/tools/workspace/picosha2/package.BUILD.bazel @@ -15,4 +15,5 @@ cc_library( name = "picosha2", hdrs = ["picosha2.h"], includes = ["."], + deprecation = "DRAKE DEPRECATED: The @picosha2 external is deprecated in Drake's WORKSPACE and will be removed on or after 2023-11-01.", # noqa ) diff --git a/tools/workspace/picosha2/repository.bzl b/tools/workspace/picosha2/repository.bzl index ceb24e0439d9..e8a521e2e300 100644 --- a/tools/workspace/picosha2/repository.bzl +++ b/tools/workspace/picosha2/repository.bzl @@ -3,6 +3,9 @@ load("@drake//tools/workspace:github.bzl", "github_archive") def picosha2_repository( name, mirrors = None): + """The @picosha2 external is deprecated in Drake's WORKSPACE and will be + removed on or after 2023-11-01. + """ github_archive( name = name, repository = "okdshin/PicoSHA2", diff --git a/tools/workspace/picosha2_internal/BUILD.bazel b/tools/workspace/picosha2_internal/BUILD.bazel new file mode 100644 index 000000000000..67914ea7e0a0 --- /dev/null +++ b/tools/workspace/picosha2_internal/BUILD.bazel @@ -0,0 +1,3 @@ +load("//tools/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/tools/workspace/picosha2_internal/package.BUILD.bazel b/tools/workspace/picosha2_internal/package.BUILD.bazel new file mode 100644 index 000000000000..09458e09cced --- /dev/null +++ b/tools/workspace/picosha2_internal/package.BUILD.bazel @@ -0,0 +1,23 @@ +# -*- bazel -*- + +load( + "@drake//tools/install:install.bzl", + "install", +) + +licenses(["notice"]) # MIT + +package( + default_visibility = ["//visibility:public"], +) + +cc_library( + name = "picosha2", + hdrs = ["picosha2.h"], + includes = ["."], +) + +install( + name = "install", + docs = ["LICENSE"], +) diff --git a/tools/workspace/picosha2_internal/patches/vendor.patch b/tools/workspace/picosha2_internal/patches/vendor.patch new file mode 100644 index 000000000000..e691a700b147 --- /dev/null +++ b/tools/workspace/picosha2_internal/patches/vendor.patch @@ -0,0 +1,18 @@ +Adds a hidden drake_vendor namespace for ODR safety + +--- picosha2.h ++++ picosha2.h +@@ -36,6 +36,7 @@ + #include + #include + #include ++inline namespace drake_vendor __attribute__ ((visibility ("hidden"))) { + namespace picosha2 { + typedef unsigned long word_t; + typedef unsigned char byte_t; +@@ -374,4 +375,5 @@ + + } + }// namespace picosha2 ++}// namespace drake_vendor + #endif // PICOSHA2_H diff --git a/tools/workspace/picosha2_internal/repository.bzl b/tools/workspace/picosha2_internal/repository.bzl new file mode 100644 index 000000000000..17cd700db0a5 --- /dev/null +++ b/tools/workspace/picosha2_internal/repository.bzl @@ -0,0 +1,16 @@ +load("@drake//tools/workspace:github.bzl", "github_archive") + +def picosha2_internal_repository( + name, + mirrors = None): + github_archive( + name = name, + repository = "okdshin/PicoSHA2", + commit = "27fcf6979298949e8a462e16d09a0351c18fcaf2", + sha256 = "18d82bb79c021ccf4ce58125b64691accef54237ba5194462740bacf8b39d8a9", # noqa + build_file = ":package.BUILD.bazel", + patches = [ + ":patches/vendor.patch", + ], + mirrors = mirrors, + )