From d01772119022c30b54abec4733732e0f10181320 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Thu, 2 Jun 2022 06:36:46 -0700 Subject: [PATCH] [workspace] Flag sdformat, ignition_math, ignition_utils as internal We are substantially patching these libraries to weave them into Drake. We should not give the illusion to users that they are available for reuse downstream. Also take this opportunity to track the ignition => gz project rename. --- multibody/parsing/BUILD.bazel | 8 ++-- tools/workspace/BUILD.bazel | 6 +-- tools/workspace/default.bzl | 31 ++++++++++--- tools/workspace/deprecation.bzl | 44 +++++++++++++++++++ .../BUILD.bazel | 0 .../package.BUILD.bazel | 2 +- .../repository.bzl | 5 +-- .../BUILD.bazel | 0 .../package.BUILD.bazel | 2 +- .../repository.bzl | 5 +-- tools/workspace/sdformat/repository.bzl | 21 --------- .../BUILD.bazel | 4 +- .../embed_sdf.py | 0 .../ign_sdf_main.cc | 0 .../package.BUILD.bazel | 6 +-- .../patches/console.patch | 0 .../patches/deprecation_unit_testing.patch | 0 .../patches/no_global_config.patch | 0 .../patches/no_urdf.patch | 0 .../sdformat_internal/repository.bzl | 21 +++++++++ .../test/ign_sdf_test.py | 2 +- 21 files changed, 109 insertions(+), 48 deletions(-) create mode 100644 tools/workspace/deprecation.bzl rename tools/workspace/{ignition_math => gz_math_internal}/BUILD.bazel (100%) rename tools/workspace/{ignition_math => gz_math_internal}/package.BUILD.bazel (99%) rename tools/workspace/{ignition_math => gz_math_internal}/repository.bzl (73%) rename tools/workspace/{ignition_utils => gz_utils_internal}/BUILD.bazel (100%) rename tools/workspace/{ignition_utils => gz_utils_internal}/package.BUILD.bazel (98%) rename tools/workspace/{ignition_utils => gz_utils_internal}/repository.bzl (73%) delete mode 100644 tools/workspace/sdformat/repository.bzl rename tools/workspace/{sdformat => sdformat_internal}/BUILD.bazel (82%) rename tools/workspace/{sdformat => sdformat_internal}/embed_sdf.py (100%) rename tools/workspace/{sdformat => sdformat_internal}/ign_sdf_main.cc (100%) rename tools/workspace/{sdformat => sdformat_internal}/package.BUILD.bazel (98%) rename tools/workspace/{sdformat => sdformat_internal}/patches/console.patch (100%) rename tools/workspace/{sdformat => sdformat_internal}/patches/deprecation_unit_testing.patch (100%) rename tools/workspace/{sdformat => sdformat_internal}/patches/no_global_config.patch (100%) rename tools/workspace/{sdformat => sdformat_internal}/patches/no_urdf.patch (100%) create mode 100644 tools/workspace/sdformat_internal/repository.bzl rename tools/workspace/{sdformat => sdformat_internal}/test/ign_sdf_test.py (97%) diff --git a/multibody/parsing/BUILD.bazel b/multibody/parsing/BUILD.bazel index e4b12c448c6e..361de302a9c3 100644 --- a/multibody/parsing/BUILD.bazel +++ b/multibody/parsing/BUILD.bazel @@ -86,7 +86,7 @@ drake_cc_library( "//geometry:proximity_properties", "//math:geometric_transform", "//multibody/plant", - "@sdformat", + "@sdformat_internal//:sdformat", "@tinyxml2", ], ) @@ -99,7 +99,7 @@ drake_cc_library( visibility = ["//visibility:private"], deps = [ "//common:diagnostic_policy", - "@sdformat", + "@sdformat_internal//:sdformat", ], ) @@ -118,7 +118,7 @@ drake_cc_library( "//geometry:geometry_roles", "//geometry:shape_specification", "//multibody/plant:coulomb_friction", - "@sdformat", + "@sdformat_internal//:sdformat", ], ) @@ -136,7 +136,7 @@ drake_cc_library( ":detail_urdf_parser", ":scoped_names", "//multibody/plant", - "@sdformat", + "@sdformat_internal//:sdformat", ], ) diff --git a/tools/workspace/BUILD.bazel b/tools/workspace/BUILD.bazel index 4dfdd3954521..048a5aa29880 100644 --- a/tools/workspace/BUILD.bazel +++ b/tools/workspace/BUILD.bazel @@ -77,8 +77,8 @@ _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [ "fcl", "fmt", "ghc_filesystem", - "ignition_math", - "ignition_utils", + "gz_math_internal", + "gz_utils_internal", "lcm", "meshcat", "meshcat_python", @@ -87,7 +87,7 @@ _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [ "petsc", "pybind11", "qhull", - "sdformat", + "sdformat_internal", "spdlog", "tinyobjloader", "usockets", diff --git a/tools/workspace/default.bzl b/tools/workspace/default.bzl index eee39dbd6340..d4e24b1ba20a 100644 --- a/tools/workspace/default.bzl +++ b/tools/workspace/default.bzl @@ -1,5 +1,6 @@ # -*- python -*- +load("@drake//tools/workspace:deprecation.bzl", "add_deprecation") load("@drake//tools/workspace:mirrors.bzl", "DEFAULT_MIRRORS") load("@drake//tools/workspace:os.bzl", "os_repository") load("@drake//tools/workspace/abseil_cpp_internal:repository.bzl", "abseil_cpp_internal_repository") # noqa @@ -36,9 +37,9 @@ load("@drake//tools/workspace/glx:repository.bzl", "glx_repository") load("@drake//tools/workspace/googlebenchmark:repository.bzl", "googlebenchmark_repository") # noqa load("@drake//tools/workspace/gtest:repository.bzl", "gtest_repository") load("@drake//tools/workspace/gurobi:repository.bzl", "gurobi_repository") +load("@drake//tools/workspace/gz_math_internal:repository.bzl", "gz_math_internal_repository") # noqa +load("@drake//tools/workspace/gz_utils_internal:repository.bzl", "gz_utils_internal_repository") # noqa load("@drake//tools/workspace/ibex:repository.bzl", "ibex_repository") -load("@drake//tools/workspace/ignition_math:repository.bzl", "ignition_math_repository") # noqa -load("@drake//tools/workspace/ignition_utils:repository.bzl", "ignition_utils_repository") # noqa load("@drake//tools/workspace/intel_realsense_ros:repository.bzl", "intel_realsense_ros_repository") # noqa load("@drake//tools/workspace/ipopt:repository.bzl", "ipopt_repository") load("@drake//tools/workspace/json:repository.bzl", "json_repository") @@ -79,7 +80,7 @@ load("@drake//tools/workspace/ros_xacro:repository.bzl", "ros_xacro_repository") load("@drake//tools/workspace/rules_pkg:repository.bzl", "rules_pkg_repository") # noqa load("@drake//tools/workspace/rules_python:repository.bzl", "rules_python_repository") # noqa load("@drake//tools/workspace/scs:repository.bzl", "scs_repository") -load("@drake//tools/workspace/sdformat:repository.bzl", "sdformat_repository") +load("@drake//tools/workspace/sdformat_internal:repository.bzl", "sdformat_internal_repository") # noqa load("@drake//tools/workspace/snopt:repository.bzl", "snopt_repository") load("@drake//tools/workspace/spdlog:repository.bzl", "spdlog_repository") load("@drake//tools/workspace/stduuid:repository.bzl", "stduuid_repository") @@ -178,12 +179,24 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): gtest_repository(name = "gtest", mirrors = mirrors) if "gurobi" not in excludes: gurobi_repository(name = "gurobi") + if "gz_math_internal" not in excludes: + gz_math_internal_repository(name = "gz_math_internal", mirrors = mirrors) # noqa + if "gz_utils_internal" not in excludes: + gz_utils_internal_repository(name = "gz_utils_internal", mirrors = mirrors) # noqa if "ibex" not in excludes: ibex_repository(name = "ibex", mirrors = mirrors) if "ignition_math" not in excludes: - ignition_math_repository(name = "ignition_math", mirrors = mirrors) + add_deprecation( + name = "ignition_math", + date = "2022-10-01", + cc_aliases = {"ignition_math": "@gz_math_internal//:gz_math"}, + ) if "ignition_utils" not in excludes: - ignition_utils_repository(name = "ignition_utils", mirrors = mirrors) + add_deprecation( + name = "ignition_utils", + date = "2022-10-01", + cc_aliases = {"ignition_utils": "@gz_utils_internal//:gz_utils"}, + ) if "intel_realsense_ros" not in excludes: intel_realsense_ros_repository(name = "intel_realsense_ros", mirrors = mirrors) # noqa if "ipopt" not in excludes: @@ -265,7 +278,13 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): if "scs" not in excludes: scs_repository(name = "scs", mirrors = mirrors) if "sdformat" not in excludes: - sdformat_repository(name = "sdformat", mirrors = mirrors) + add_deprecation( + name = "sdformat", + date = "2022-10-01", + cc_aliases = {"sdformat": "@sdformat_internal//:sdformat"}, + ) + if "sdformat_internal" not in excludes: + sdformat_internal_repository(name = "sdformat_internal", mirrors = mirrors) # noqa if "snopt" not in excludes: snopt_repository(name = "snopt") if "spdlog" not in excludes: diff --git a/tools/workspace/deprecation.bzl b/tools/workspace/deprecation.bzl new file mode 100644 index 000000000000..d0bdf583906f --- /dev/null +++ b/tools/workspace/deprecation.bzl @@ -0,0 +1,44 @@ +# -*- python -*- + +def _impl(repo_ctx): + name = repo_ctx.attr.name + date = repo_ctx.attr.date + cc_aliases = repo_ctx.attr.cc_aliases + + build = "package(default_visibility = [\"//visibility:public\"])\n" + deprecation = "".join([ + "DRAKE DEPRECATED: The @{} external is deprecated".format(name), + " and will be removed from Drake on or after {}.".format(date), + ]) + for label, actual in cc_aliases.items(): + build += "cc_library({})\n".format(", ".join([ + "name = " + repr(label), + "deprecation = " + repr(deprecation), + ])) + + repo_ctx.file("BUILD.bazel", build) + +add_deprecation = repository_rule( + doc = """Adds a repository rule with deprecated aliases to other targets. + + Example: + add_deprecation( + name = "qhull", + date = "2038-01-19", + cc_aliases = {"qhull": "@qhull_internal//:qhull"}, + ) + """, + attrs = { + "date": attr.string( + doc = "Scheduled removal date of the deprecated target(s).", + mandatory = True, + ), + "cc_aliases": attr.string_dict( + doc = """ + Optional mapping for cc_library deprecations. The keys are + deprecated target names, the values are the non-deprecated labels. + """, + ), + }, + implementation = _impl, +) diff --git a/tools/workspace/ignition_math/BUILD.bazel b/tools/workspace/gz_math_internal/BUILD.bazel similarity index 100% rename from tools/workspace/ignition_math/BUILD.bazel rename to tools/workspace/gz_math_internal/BUILD.bazel diff --git a/tools/workspace/ignition_math/package.BUILD.bazel b/tools/workspace/gz_math_internal/package.BUILD.bazel similarity index 99% rename from tools/workspace/ignition_math/package.BUILD.bazel rename to tools/workspace/gz_math_internal/package.BUILD.bazel index 76341dbc9a1f..d2fdf029d7a4 100644 --- a/tools/workspace/ignition_math/package.BUILD.bazel +++ b/tools/workspace/gz_math_internal/package.BUILD.bazel @@ -159,7 +159,7 @@ public_headers = public_headers_no_gen + [ # explicitly listed sources plus private headers. The explicitly listed # hdrs= matches upstream's public headers. cc_library( - name = "ignition_math", + name = "gz_math", srcs = [ "src/Angle.cc", "src/AxisAlignedBox.cc", diff --git a/tools/workspace/ignition_math/repository.bzl b/tools/workspace/gz_math_internal/repository.bzl similarity index 73% rename from tools/workspace/ignition_math/repository.bzl rename to tools/workspace/gz_math_internal/repository.bzl index f73311d54619..9a1d71db46f4 100644 --- a/tools/workspace/ignition_math/repository.bzl +++ b/tools/workspace/gz_math_internal/repository.bzl @@ -2,8 +2,7 @@ load("//tools/workspace:github.bzl", "github_archive") -# TODO(jwnimmer-tri) Rename this to match upstream gz-math. -def ignition_math_repository( +def gz_math_internal_repository( name, mirrors = None): # When updating this commit, also remember to adjust the PROJECT_* @@ -13,6 +12,6 @@ def ignition_math_repository( repository = "gazebosim/gz-math", commit = "ignition-math6_6.10.0", sha256 = "94e853e1dfba97ebec4b6152691a89af1e94660b02f4ecdf04356b763c2848bd", # noqa - build_file = "@drake//tools/workspace/ignition_math:package.BUILD.bazel", # noqa + build_file = "@drake//tools/workspace/gz_math_internal:package.BUILD.bazel", # noqa mirrors = mirrors, ) diff --git a/tools/workspace/ignition_utils/BUILD.bazel b/tools/workspace/gz_utils_internal/BUILD.bazel similarity index 100% rename from tools/workspace/ignition_utils/BUILD.bazel rename to tools/workspace/gz_utils_internal/BUILD.bazel diff --git a/tools/workspace/ignition_utils/package.BUILD.bazel b/tools/workspace/gz_utils_internal/package.BUILD.bazel similarity index 98% rename from tools/workspace/ignition_utils/package.BUILD.bazel rename to tools/workspace/gz_utils_internal/package.BUILD.bazel index 2ce8f04787d8..1a24f95b7cc6 100644 --- a/tools/workspace/ignition_utils/package.BUILD.bazel +++ b/tools/workspace/gz_utils_internal/package.BUILD.bazel @@ -87,7 +87,7 @@ public_headers = public_headers_no_gen + [ ] cc_library( - name = "ignition_utils", + name = "gz_utils", srcs = private_headers, hdrs = public_headers, includes = ["include"], diff --git a/tools/workspace/ignition_utils/repository.bzl b/tools/workspace/gz_utils_internal/repository.bzl similarity index 73% rename from tools/workspace/ignition_utils/repository.bzl rename to tools/workspace/gz_utils_internal/repository.bzl index ed6fcc6d343f..03cd32e5f05a 100644 --- a/tools/workspace/ignition_utils/repository.bzl +++ b/tools/workspace/gz_utils_internal/repository.bzl @@ -2,8 +2,7 @@ load("//tools/workspace:github.bzl", "github_archive") -# TODO(jwnimmer-tri) Rename this to match upstream gz-utils. -def ignition_utils_repository( +def gz_utils_internal_repository( name, mirrors = None): github_archive( @@ -13,6 +12,6 @@ def ignition_utils_repository( # constants in ./package.BUILD.bazel to match the new version number. commit = "ignition-utils1_1.0.0", sha256 = "55d3285692392f9493a35b680f275ec116584baedeef90de57d2b03dfd952d9d", # noqa - build_file = "@drake//tools/workspace/ignition_utils:package.BUILD.bazel", # noqa + build_file = "@drake//tools/workspace/gz_utils_internal:package.BUILD.bazel", # noqa mirrors = mirrors, ) diff --git a/tools/workspace/sdformat/repository.bzl b/tools/workspace/sdformat/repository.bzl deleted file mode 100644 index a01d618447dd..000000000000 --- a/tools/workspace/sdformat/repository.bzl +++ /dev/null @@ -1,21 +0,0 @@ -# -*- python -*- - -load("//tools/workspace:github.bzl", "github_archive") - -def sdformat_repository( - name, - mirrors = None): - github_archive( - name = name, - repository = "gazebosim/sdformat", - commit = "sdformat12_12.5.0", - build_file = "@drake//tools/workspace/sdformat:package.BUILD.bazel", - sha256 = "3896772db68b7ca7b18bbf1945a72206885b03d3f0caf29491be5b53b79a7124", # noqa - patches = [ - "@drake//tools/workspace/sdformat:patches/console.patch", - "@drake//tools/workspace/sdformat:patches/deprecation_unit_testing.patch", # noqa - "@drake//tools/workspace/sdformat:patches/no_global_config.patch", - "@drake//tools/workspace/sdformat:patches/no_urdf.patch", - ], - mirrors = mirrors, - ) diff --git a/tools/workspace/sdformat/BUILD.bazel b/tools/workspace/sdformat_internal/BUILD.bazel similarity index 82% rename from tools/workspace/sdformat/BUILD.bazel rename to tools/workspace/sdformat_internal/BUILD.bazel index d4b739ac34f4..df9c31528512 100644 --- a/tools/workspace/sdformat/BUILD.bazel +++ b/tools/workspace/sdformat_internal/BUILD.bazel @@ -6,7 +6,7 @@ load("//tools/lint:lint.bzl", "add_lint_tests") exports_files( ["embed_sdf.py"], - visibility = ["@sdformat//:__pkg__"], + visibility = ["@sdformat_internal//:__pkg__"], ) drake_cc_binary( @@ -15,7 +15,7 @@ drake_cc_binary( deps = [ "//common:essential", "@gflags", - "@sdformat//:ign_sdf_cmdline", + "@sdformat_internal//:ign_sdf_cmdline", ], ) diff --git a/tools/workspace/sdformat/embed_sdf.py b/tools/workspace/sdformat_internal/embed_sdf.py similarity index 100% rename from tools/workspace/sdformat/embed_sdf.py rename to tools/workspace/sdformat_internal/embed_sdf.py diff --git a/tools/workspace/sdformat/ign_sdf_main.cc b/tools/workspace/sdformat_internal/ign_sdf_main.cc similarity index 100% rename from tools/workspace/sdformat/ign_sdf_main.cc rename to tools/workspace/sdformat_internal/ign_sdf_main.cc diff --git a/tools/workspace/sdformat/package.BUILD.bazel b/tools/workspace/sdformat_internal/package.BUILD.bazel similarity index 98% rename from tools/workspace/sdformat/package.BUILD.bazel rename to tools/workspace/sdformat_internal/package.BUILD.bazel index 8c9aadc7fd56..f1edb8b647cc 100644 --- a/tools/workspace/sdformat/package.BUILD.bazel +++ b/tools/workspace/sdformat_internal/package.BUILD.bazel @@ -134,7 +134,7 @@ genrule( py_binary( name = "embed_sdf", - srcs = ["@drake//tools/workspace/sdformat:embed_sdf.py"], + srcs = ["@drake//tools/workspace/sdformat_internal:embed_sdf.py"], python_version = "PY3", srcs_version = "PY3", ) @@ -241,8 +241,8 @@ cc_library( includes = ["include"], linkstatic = 1, deps = [ - "@ignition_math", - "@ignition_utils", + "@gz_math_internal//:gz_math", + "@gz_utils_internal//:gz_utils", "@tinyxml2", # N.B. It's very unusual to add a dependency from a third-party library # onto Drake, but in this case it's the simplest way to be able to send diff --git a/tools/workspace/sdformat/patches/console.patch b/tools/workspace/sdformat_internal/patches/console.patch similarity index 100% rename from tools/workspace/sdformat/patches/console.patch rename to tools/workspace/sdformat_internal/patches/console.patch diff --git a/tools/workspace/sdformat/patches/deprecation_unit_testing.patch b/tools/workspace/sdformat_internal/patches/deprecation_unit_testing.patch similarity index 100% rename from tools/workspace/sdformat/patches/deprecation_unit_testing.patch rename to tools/workspace/sdformat_internal/patches/deprecation_unit_testing.patch diff --git a/tools/workspace/sdformat/patches/no_global_config.patch b/tools/workspace/sdformat_internal/patches/no_global_config.patch similarity index 100% rename from tools/workspace/sdformat/patches/no_global_config.patch rename to tools/workspace/sdformat_internal/patches/no_global_config.patch diff --git a/tools/workspace/sdformat/patches/no_urdf.patch b/tools/workspace/sdformat_internal/patches/no_urdf.patch similarity index 100% rename from tools/workspace/sdformat/patches/no_urdf.patch rename to tools/workspace/sdformat_internal/patches/no_urdf.patch diff --git a/tools/workspace/sdformat_internal/repository.bzl b/tools/workspace/sdformat_internal/repository.bzl new file mode 100644 index 000000000000..35d98edb2a83 --- /dev/null +++ b/tools/workspace/sdformat_internal/repository.bzl @@ -0,0 +1,21 @@ +# -*- python -*- + +load("//tools/workspace:github.bzl", "github_archive") + +def sdformat_internal_repository( + name, + mirrors = None): + github_archive( + name = name, + repository = "gazebosim/sdformat", + commit = "sdformat12_12.5.0", + build_file = "@drake//tools/workspace/sdformat_internal:package.BUILD.bazel", # noqa + sha256 = "3896772db68b7ca7b18bbf1945a72206885b03d3f0caf29491be5b53b79a7124", # noqa + patches = [ + "@drake//tools/workspace/sdformat_internal:patches/console.patch", + "@drake//tools/workspace/sdformat_internal:patches/deprecation_unit_testing.patch", # noqa + "@drake//tools/workspace/sdformat_internal:patches/no_global_config.patch", # noqa + "@drake//tools/workspace/sdformat_internal:patches/no_urdf.patch", + ], + mirrors = mirrors, + ) diff --git a/tools/workspace/sdformat/test/ign_sdf_test.py b/tools/workspace/sdformat_internal/test/ign_sdf_test.py similarity index 97% rename from tools/workspace/sdformat/test/ign_sdf_test.py rename to tools/workspace/sdformat_internal/test/ign_sdf_test.py index e13e2a7e5491..1bfc0bfecdd6 100644 --- a/tools/workspace/sdformat/test/ign_sdf_test.py +++ b/tools/workspace/sdformat_internal/test/ign_sdf_test.py @@ -57,7 +57,7 @@ class TestIgnSdf(unittest.TestCase): def setUp(self): self.maxDiff = None - self.bin = "tools/workspace/sdformat/ign_sdf" + self.bin = "tools/workspace/sdformat_internal/ign_sdf" self.input_file = os.path.join( os.environ["TEST_TMPDIR"], "example.sdf" )