Skip to content

Commit

Permalink
[workspace] Flag sdformat, ignition_math, ignition_utils as internal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jwnimmer-tri committed Jun 2, 2022
1 parent e80d001 commit d017721
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 48 deletions.
8 changes: 4 additions & 4 deletions multibody/parsing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ drake_cc_library(
"//geometry:proximity_properties",
"//math:geometric_transform",
"//multibody/plant",
"@sdformat",
"@sdformat_internal//:sdformat",
"@tinyxml2",
],
)
Expand All @@ -99,7 +99,7 @@ drake_cc_library(
visibility = ["//visibility:private"],
deps = [
"//common:diagnostic_policy",
"@sdformat",
"@sdformat_internal//:sdformat",
],
)

Expand All @@ -118,7 +118,7 @@ drake_cc_library(
"//geometry:geometry_roles",
"//geometry:shape_specification",
"//multibody/plant:coulomb_friction",
"@sdformat",
"@sdformat_internal//:sdformat",
],
)

Expand All @@ -136,7 +136,7 @@ drake_cc_library(
":detail_urdf_parser",
":scoped_names",
"//multibody/plant",
"@sdformat",
"@sdformat_internal//:sdformat",
],
)

Expand Down
6 changes: 3 additions & 3 deletions tools/workspace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -87,7 +87,7 @@ _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [
"petsc",
"pybind11",
"qhull",
"sdformat",
"sdformat_internal",
"spdlog",
"tinyobjloader",
"usockets",
Expand Down
31 changes: 25 additions & 6 deletions tools/workspace/default.bzl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
44 changes: 44 additions & 0 deletions tools/workspace/deprecation.bzl
Original file line number Diff line number Diff line change
@@ -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,
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_*
Expand All @@ -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,
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
)
21 changes: 0 additions & 21 deletions tools/workspace/sdformat/repository.bzl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -15,7 +15,7 @@ drake_cc_binary(
deps = [
"//common:essential",
"@gflags",
"@sdformat//:ign_sdf_cmdline",
"@sdformat_internal//:ign_sdf_cmdline",
],
)

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions tools/workspace/sdformat_internal/repository.bzl
Original file line number Diff line number Diff line change
@@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit d017721

Please sign in to comment.