From 639be094273f6798268348c27cff502451eafb3e Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Wed, 18 Jan 2023 16:35:30 -0800 Subject: [PATCH 1/2] [workspace] Switch ccd and fcl to be internal --- geometry/BUILD.bazel | 4 ++-- geometry/proximity/BUILD.bazel | 14 +++++++------- tools/install/check_licenses.bzl | 2 +- tools/workspace/BUILD.bazel | 4 ++-- tools/workspace/{ccd => ccd_internal}/BUILD.bazel | 0 .../{ccd => ccd_internal}/package.BUILD.bazel | 0 .../workspace/{ccd => ccd_internal}/repository.bzl | 2 +- tools/workspace/default.bzl | 12 ++++++------ tools/workspace/{fcl => fcl_internal}/BUILD.bazel | 0 .../{fcl => fcl_internal}/package.BUILD.bazel | 6 +++--- .../workspace/{fcl => fcl_internal}/repository.bzl | 2 +- .../{fcl => fcl_internal}/version-from-xml.sed | 0 12 files changed, 23 insertions(+), 23 deletions(-) rename tools/workspace/{ccd => ccd_internal}/BUILD.bazel (100%) rename tools/workspace/{ccd => ccd_internal}/package.BUILD.bazel (100%) rename tools/workspace/{ccd => ccd_internal}/repository.bzl (93%) rename tools/workspace/{fcl => fcl_internal}/BUILD.bazel (100%) rename tools/workspace/{fcl => fcl_internal}/package.BUILD.bazel (94%) rename tools/workspace/{fcl => fcl_internal}/repository.bzl (93%) rename tools/workspace/{fcl => fcl_internal}/version-from-xml.sed (100%) diff --git a/geometry/BUILD.bazel b/geometry/BUILD.bazel index fb0a67b892dc..03545843bdbc 100644 --- a/geometry/BUILD.bazel +++ b/geometry/BUILD.bazel @@ -87,7 +87,7 @@ drake_cc_library( "//geometry/proximity:hydroelastic_callback", "//geometry/proximity:obj_to_surface_mesh", "//geometry/proximity:penetration_as_point_pair_callback", - "@fcl", + "@fcl_internal//:fcl", "@fmt", ], ) @@ -668,7 +668,7 @@ drake_cc_googletest( "//geometry/proximity:hydroelastic_callback", "//geometry/proximity:make_sphere_mesh", "//math", - "@fcl", + "@fcl_internal//:fcl", ], ) diff --git a/geometry/proximity/BUILD.bazel b/geometry/proximity/BUILD.bazel index 8509daf55c38..fe0aa73c6f24 100644 --- a/geometry/proximity/BUILD.bazel +++ b/geometry/proximity/BUILD.bazel @@ -146,7 +146,7 @@ drake_cc_library( ":collision_filter", ":proximity_utilities", "//geometry:geometry_ids", - "@fcl", + "@fcl_internal//:fcl", ], ) @@ -234,7 +234,7 @@ drake_cc_library( "//geometry:geometry_ids", "//geometry/query_results:signed_distance_to_point", "//math:geometric_transform", - "@fcl", + "@fcl_internal//:fcl", ], ) @@ -285,7 +285,7 @@ drake_cc_library( ":collision_filter", ":proximity_utilities", "//common:sorted_pair", - "@fcl", + "@fcl_internal//:fcl", "@fmt", ], ) @@ -312,7 +312,7 @@ drake_cc_library( "//geometry:proximity_properties", "//geometry/query_results:contact_surface", "//math:geometric_transform", - "@fcl", + "@fcl_internal//:fcl", "@fmt", ], ) @@ -683,7 +683,7 @@ drake_cc_library( "//common:nice_type_name", "//geometry/query_results:penetration_as_point_pair", "//geometry/query_results:signed_distance_to_point", - "@fcl", + "@fcl_internal//:fcl", ], ) @@ -734,7 +734,7 @@ drake_cc_library( "//common:sorted_pair", "//geometry:geometry_ids", "//geometry:shape_specification", - "@fcl", + "@fcl_internal//:fcl", "@fmt", ], ) @@ -870,7 +870,7 @@ drake_cc_library( "//geometry:utilities", "//geometry/proximity:proximity_utilities", "//math:geometric_transform", - "@fcl", + "@fcl_internal//:fcl", ], ) diff --git a/tools/install/check_licenses.bzl b/tools/install/check_licenses.bzl index 08fbf0b296bd..32827353a4c7 100644 --- a/tools/install/check_licenses.bzl +++ b/tools/install/check_licenses.bzl @@ -4,7 +4,7 @@ load("@drake//tools/install:install.bzl", "InstallInfo") # List of exact file names of license files LICENSE_LITERALS = [ - "BSD-LICENSE", # @ccd + "BSD-LICENSE", # @ccd_internal "COPYING", "Copyright.txt", # @vtk "EULA.pdf", # @gurobi diff --git a/tools/workspace/BUILD.bazel b/tools/workspace/BUILD.bazel index 45537cde836e..3f61412ab5eb 100644 --- a/tools/workspace/BUILD.bazel +++ b/tools/workspace/BUILD.bazel @@ -77,12 +77,12 @@ drake_py_binary( ) _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [ - "ccd", + "ccd_internal", "com_jidesoft_jide_oss", "common_robotics_utilities", "commons_io", "curl_internal", - "fcl", + "fcl_internal", "fmt", "gz_math_internal", "gz_utils_internal", diff --git a/tools/workspace/ccd/BUILD.bazel b/tools/workspace/ccd_internal/BUILD.bazel similarity index 100% rename from tools/workspace/ccd/BUILD.bazel rename to tools/workspace/ccd_internal/BUILD.bazel diff --git a/tools/workspace/ccd/package.BUILD.bazel b/tools/workspace/ccd_internal/package.BUILD.bazel similarity index 100% rename from tools/workspace/ccd/package.BUILD.bazel rename to tools/workspace/ccd_internal/package.BUILD.bazel diff --git a/tools/workspace/ccd/repository.bzl b/tools/workspace/ccd_internal/repository.bzl similarity index 93% rename from tools/workspace/ccd/repository.bzl rename to tools/workspace/ccd_internal/repository.bzl index 08e5144b6559..92f29d832819 100644 --- a/tools/workspace/ccd/repository.bzl +++ b/tools/workspace/ccd_internal/repository.bzl @@ -2,7 +2,7 @@ load("@drake//tools/workspace:github.bzl", "github_archive") -def ccd_repository( +def ccd_internal_repository( name, mirrors = None): github_archive( diff --git a/tools/workspace/default.bzl b/tools/workspace/default.bzl index ddb294a94ea8..33601eb90efa 100644 --- a/tools/workspace/default.bzl +++ b/tools/workspace/default.bzl @@ -7,7 +7,7 @@ load("@drake//tools/workspace/bazel_skylib:repository.bzl", "bazel_skylib_reposi load("@drake//tools/workspace/blas:repository.bzl", "blas_repository") load("@drake//tools/workspace/buildifier:repository.bzl", "buildifier_repository") # noqa load("@drake//tools/workspace/cc:repository.bzl", "cc_repository") -load("@drake//tools/workspace/ccd:repository.bzl", "ccd_repository") +load("@drake//tools/workspace/ccd_internal:repository.bzl", "ccd_internal_repository") # noqa load("@drake//tools/workspace/cds:repository.bzl", "cds_repository") load("@drake//tools/workspace/clang_cindex_python3_internal:repository.bzl", "clang_cindex_python3_internal_repository") # noqa load("@drake//tools/workspace/clp:repository.bzl", "clp_repository") @@ -24,7 +24,7 @@ load("@drake//tools/workspace/drake_visualizer:repository.bzl", "drake_visualize load("@drake//tools/workspace/dreal:repository.bzl", "dreal_repository") load("@drake//tools/workspace/eigen:repository.bzl", "eigen_repository") load("@drake//tools/workspace/expat:repository.bzl", "expat_repository") -load("@drake//tools/workspace/fcl:repository.bzl", "fcl_repository") +load("@drake//tools/workspace/fcl_internal:repository.bzl", "fcl_internal_repository") # noqa load("@drake//tools/workspace/fmt:repository.bzl", "fmt_repository") load("@drake//tools/workspace/gflags:repository.bzl", "gflags_repository") load("@drake//tools/workspace/gfortran:repository.bzl", "gfortran_repository") @@ -124,8 +124,8 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): buildifier_repository(name = "buildifier", mirrors = mirrors) if "cc" not in excludes: cc_repository(name = "cc") - if "ccd" not in excludes: - ccd_repository(name = "ccd", mirrors = mirrors) + if "ccd_internal" not in excludes: + ccd_internal_repository(name = "ccd_internal", mirrors = mirrors) if "cds" not in excludes: # N.B. This repository is deprecated for removal on 2023-02-01. # For details see https://github.com/RobotLocomotion/drake/pull/18156. @@ -164,8 +164,8 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): eigen_repository(name = "eigen") if "expat" not in excludes: expat_repository(name = "expat") - if "fcl" not in excludes: - fcl_repository(name = "fcl", mirrors = mirrors) + if "fcl_internal" not in excludes: + fcl_internal_repository(name = "fcl_internal", mirrors = mirrors) if "fmt" not in excludes: fmt_repository(name = "fmt", mirrors = mirrors) if "gflags" not in excludes: diff --git a/tools/workspace/fcl/BUILD.bazel b/tools/workspace/fcl_internal/BUILD.bazel similarity index 100% rename from tools/workspace/fcl/BUILD.bazel rename to tools/workspace/fcl_internal/BUILD.bazel diff --git a/tools/workspace/fcl/package.BUILD.bazel b/tools/workspace/fcl_internal/package.BUILD.bazel similarity index 94% rename from tools/workspace/fcl/package.BUILD.bazel rename to tools/workspace/fcl_internal/package.BUILD.bazel index 1189063c819b..0747ebd51a87 100644 --- a/tools/workspace/fcl/package.BUILD.bazel +++ b/tools/workspace/fcl_internal/package.BUILD.bazel @@ -35,14 +35,14 @@ genrule( name = "version-from-xml.cmake_genrule", srcs = [ "package.xml", - "@drake//tools/workspace/fcl:version-from-xml.sed", + "@drake//tools/workspace/fcl_internal:version-from-xml.sed", ], outs = [ "version-from-xml.cmake", ], cmd = " ".join([ "sed", - "-f $(execpath @drake//tools/workspace/fcl:version-from-xml.sed)", + "-f $(execpath @drake//tools/workspace/fcl_internal:version-from-xml.sed)", # noqa "-n $(execpath package.xml) > $@", "&&", "test -s $@", @@ -133,7 +133,7 @@ cc_library( includes = ["include"], linkstatic = 1, deps = [ - "@ccd", + "@ccd_internal//:ccd", "@eigen", ], ) diff --git a/tools/workspace/fcl/repository.bzl b/tools/workspace/fcl_internal/repository.bzl similarity index 93% rename from tools/workspace/fcl/repository.bzl rename to tools/workspace/fcl_internal/repository.bzl index 38600dce946c..642f7de8aeeb 100644 --- a/tools/workspace/fcl/repository.bzl +++ b/tools/workspace/fcl_internal/repository.bzl @@ -2,7 +2,7 @@ load("@drake//tools/workspace:github.bzl", "github_archive") -def fcl_repository( +def fcl_internal_repository( name, mirrors = None): github_archive( diff --git a/tools/workspace/fcl/version-from-xml.sed b/tools/workspace/fcl_internal/version-from-xml.sed similarity index 100% rename from tools/workspace/fcl/version-from-xml.sed rename to tools/workspace/fcl_internal/version-from-xml.sed From 1dbf9496f5ef07d6f63ea2c394b93a87d35da817 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Wed, 18 Jan 2023 16:35:30 -0800 Subject: [PATCH 2/2] [workspace] Add back copies of ccd and fcl, with deprecation --- tools/workspace/ccd/BUILD.bazel | 5 + tools/workspace/ccd/package.BUILD.bazel | 58 ++++++++++ tools/workspace/ccd/repository.bzl | 15 +++ tools/workspace/default.bzl | 6 + tools/workspace/fcl/BUILD.bazel | 7 ++ tools/workspace/fcl/package.BUILD.bazel | 136 +++++++++++++++++++++++ tools/workspace/fcl/repository.bzl | 15 +++ tools/workspace/fcl/version-from-xml.sed | 4 + 8 files changed, 246 insertions(+) create mode 100644 tools/workspace/ccd/BUILD.bazel create mode 100644 tools/workspace/ccd/package.BUILD.bazel create mode 100644 tools/workspace/ccd/repository.bzl create mode 100644 tools/workspace/fcl/BUILD.bazel create mode 100644 tools/workspace/fcl/package.BUILD.bazel create mode 100644 tools/workspace/fcl/repository.bzl create mode 100644 tools/workspace/fcl/version-from-xml.sed diff --git a/tools/workspace/ccd/BUILD.bazel b/tools/workspace/ccd/BUILD.bazel new file mode 100644 index 000000000000..7198e3bb9b53 --- /dev/null +++ b/tools/workspace/ccd/BUILD.bazel @@ -0,0 +1,5 @@ +# -*- python -*- + +load("//tools/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/tools/workspace/ccd/package.BUILD.bazel b/tools/workspace/ccd/package.BUILD.bazel new file mode 100644 index 000000000000..636c2626226b --- /dev/null +++ b/tools/workspace/ccd/package.BUILD.bazel @@ -0,0 +1,58 @@ +# -*- python -*- + +load( + "@drake//tools/workspace:cmake_configure_file.bzl", + "cmake_configure_file", +) + +licenses(["notice"]) # BSD-3-Clause + +package( + default_visibility = ["//visibility:public"], +) + +# Generates config.h based on the defines= we want in Drake. +cmake_configure_file( + name = "config", + src = "src/ccd/config.h.cmake.in", + out = "src/ccd/config.h", + defines = ["CCD_DOUBLE"], + visibility = ["//visibility:private"], +) + +# Guessing headers with +# install(... +# guess_hdrs = "PACKAGE", +# ) +# fails and lists internal headers in addition to the public headers. +CCD_PUBLIC_HEADERS = [ + "src/ccd/ccd.h", + "src/ccd/config.h", + "src/ccd/compiler.h", + "src/ccd/quat.h", + "src/ccd/vec3.h", + "src/ccd/ccd_export.h", +] + +# Options used when building the ccd code. Handled by cmake in upstream code +CCD_COPTS = [ + "-Wno-all", + "-fvisibility=hidden", +] + +# Generates the library exported to users. Upstream's CMake code lists out all +# sources instead of globbing, but conveniently puts the public headers in one +# place and private sources and headers in another; we'll use globbing here. +cc_library( + name = "ccd", + srcs = glob([ + "src/*.c", + "src/*.h", + ]), + hdrs = CCD_PUBLIC_HEADERS, + copts = CCD_COPTS, + defines = ["CCD_STATIC_DEFINE"], + includes = ["src"], + linkstatic = 1, + deprecation = "DRAKE DEPRECATED: The @ccd external is deprecated. The deprecated code will be removed from Drake on or after 2023-05-01.", # noqa, +) diff --git a/tools/workspace/ccd/repository.bzl b/tools/workspace/ccd/repository.bzl new file mode 100644 index 000000000000..08e5144b6559 --- /dev/null +++ b/tools/workspace/ccd/repository.bzl @@ -0,0 +1,15 @@ +# -*- python -*- + +load("@drake//tools/workspace:github.bzl", "github_archive") + +def ccd_repository( + name, + mirrors = None): + github_archive( + name = name, + repository = "danfis/libccd", + commit = "7931e764a19ef6b21b443376c699bbc9c6d4fba8", + sha256 = "479994a86d32e2effcaad64204142000ee6b6b291fd1859ac6710aee8d00a482", # noqa + build_file = ":package.BUILD.bazel", + mirrors = mirrors, + ) diff --git a/tools/workspace/default.bzl b/tools/workspace/default.bzl index 33601eb90efa..e1f4e2974021 100644 --- a/tools/workspace/default.bzl +++ b/tools/workspace/default.bzl @@ -7,6 +7,7 @@ load("@drake//tools/workspace/bazel_skylib:repository.bzl", "bazel_skylib_reposi load("@drake//tools/workspace/blas:repository.bzl", "blas_repository") load("@drake//tools/workspace/buildifier:repository.bzl", "buildifier_repository") # noqa load("@drake//tools/workspace/cc:repository.bzl", "cc_repository") +load("@drake//tools/workspace/ccd:repository.bzl", "ccd_repository") load("@drake//tools/workspace/ccd_internal:repository.bzl", "ccd_internal_repository") # noqa load("@drake//tools/workspace/cds:repository.bzl", "cds_repository") load("@drake//tools/workspace/clang_cindex_python3_internal:repository.bzl", "clang_cindex_python3_internal_repository") # noqa @@ -24,6 +25,7 @@ load("@drake//tools/workspace/drake_visualizer:repository.bzl", "drake_visualize load("@drake//tools/workspace/dreal:repository.bzl", "dreal_repository") load("@drake//tools/workspace/eigen:repository.bzl", "eigen_repository") load("@drake//tools/workspace/expat:repository.bzl", "expat_repository") +load("@drake//tools/workspace/fcl:repository.bzl", "fcl_repository") # noqa load("@drake//tools/workspace/fcl_internal:repository.bzl", "fcl_internal_repository") # noqa load("@drake//tools/workspace/fmt:repository.bzl", "fmt_repository") load("@drake//tools/workspace/gflags:repository.bzl", "gflags_repository") @@ -124,6 +126,8 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): buildifier_repository(name = "buildifier", mirrors = mirrors) if "cc" not in excludes: cc_repository(name = "cc") + if "ccd" not in excludes: + ccd_repository(name = "ccd", mirrors = mirrors) if "ccd_internal" not in excludes: ccd_internal_repository(name = "ccd_internal", mirrors = mirrors) if "cds" not in excludes: @@ -164,6 +168,8 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): eigen_repository(name = "eigen") if "expat" not in excludes: expat_repository(name = "expat") + if "fcl" not in excludes: + fcl_repository(name = "fcl", mirrors = mirrors) if "fcl_internal" not in excludes: fcl_internal_repository(name = "fcl_internal", mirrors = mirrors) if "fmt" not in excludes: diff --git a/tools/workspace/fcl/BUILD.bazel b/tools/workspace/fcl/BUILD.bazel new file mode 100644 index 000000000000..3fd11df9ff21 --- /dev/null +++ b/tools/workspace/fcl/BUILD.bazel @@ -0,0 +1,7 @@ +# -*- python -*- + +load("//tools/lint:lint.bzl", "add_lint_tests") + +exports_files(["version-from-xml.sed"]) + +add_lint_tests() diff --git a/tools/workspace/fcl/package.BUILD.bazel b/tools/workspace/fcl/package.BUILD.bazel new file mode 100644 index 000000000000..0d9793c05e73 --- /dev/null +++ b/tools/workspace/fcl/package.BUILD.bazel @@ -0,0 +1,136 @@ +# -*- python -*- + +load( + "@drake//tools/workspace:cmake_configure_file.bzl", + "cmake_configure_file", +) +load( + "@drake//tools/workspace:generate_export_header.bzl", + "generate_export_header", +) +load( + "@drake//tools/workspace:generate_include_header.bzl", + "drake_generate_include_header", +) + +licenses(["notice"]) # BSD-3-Clause + +package( + default_visibility = ["//visibility:public"], +) + +# Generate header to provide ABI export symbols for fcl. +generate_export_header( + out = "include/fcl/export.h", + lib = "fcl", + static_define = "FCL_STATIC_DEFINE", +) + +# Generates a version.cmake stub based on package.xml contents. +genrule( + name = "version-from-xml.cmake_genrule", + srcs = [ + "package.xml", + "@drake//tools/workspace/fcl:version-from-xml.sed", + ], + outs = [ + "version-from-xml.cmake", + ], + cmd = " ".join([ + "sed", + "-f $(execpath @drake//tools/workspace/fcl:version-from-xml.sed)", + "-n $(execpath package.xml) > $@", + "&&", + "test -s $@", + ]), +) + +# Generates config.h based on the version numbers in CMake code. +cmake_configure_file( + name = "config", + src = "include/fcl/config.h.in", + out = "include/fcl/config.h", + cmakelists = [ + ":version-from-xml.cmake", + ], + defines = [ + "OCTOMAP_MAJOR_VERSION=0", + "OCTOMAP_MINOR_VERSION=0", + "OCTOMAP_PATCH_VERSION=0", + "GENERATED_FILE_MARKER=GENERATED FILE DO NOT EDIT", + ], + visibility = ["//visibility:private"], +) + +# Provide all headers (except octomap-related ones) for simplicitly, even +# though many of these will not have their '*.cpp' mate compiled. +_HDRS = glob( + include = [ + "include/**/*.h", + ], + exclude = [ + "**/octree/**", + ], + allow_empty = False, +) + +# To minimize the build footprint, only build the fraction of FCL that is +# needed by Drake. +_DRAKE_RELEVANT_SRCS = glob( + include = [ + "src/**/*.cpp", + ], + exclude = [ + # We use none of this code. + "**/*conservative_advancement*.cpp", + "**/*continuous_collision*.cpp", + "**/octree/**", + "src/common/**", + "src/math/motion/**", + "src/math/sampler/**", + # We list out the few of these that we need immediately below. + "src/broadphase/*.cpp", + "src/broadphase/detail/*.cpp", + "src/math/*.cpp", + "src/math/detail/*.cpp", + ], + allow_empty = False, +) + [ + "src/broadphase/broadphase_collision_manager.cpp", + "src/broadphase/broadphase_dynamic_AABB_tree.cpp", + "src/broadphase/detail/morton.cpp", + "src/math/geometry.cpp", + "src/math/triangle.cpp", + "src/math/detail/polysolver.cpp", + "src/math/detail/project.cpp", +] + +# Generates fcl.h, which consists of #include statements for *all* of the other +# headers in the library (!!!). The first line is '#pragma once' followed by +# one line like '#include "fcl/common/types.h"' for each non-generated header. +drake_generate_include_header( + name = "fcl_h_genrule", + out = "include/fcl/fcl.h", + hdrs = _HDRS, +) + +cc_library( + name = "fcl", + srcs = _DRAKE_RELEVANT_SRCS, + hdrs = _HDRS + [ + ":config", + ":fcl_h_genrule", + ":include/fcl/export.h", + ], + copts = ["-fvisibility=hidden"], + defines = [ + "FCL_STATIC_DEFINE", + ], + includes = ["include"], + linkstatic = 1, + deps = [ + "@ccd", + "@eigen", + ], + deprecation = "DRAKE DEPRECATED: The @fcl external is deprecated. The deprecated code will be removed from Drake on or after 2023-05-01.", # noqa, +) diff --git a/tools/workspace/fcl/repository.bzl b/tools/workspace/fcl/repository.bzl new file mode 100644 index 000000000000..38600dce946c --- /dev/null +++ b/tools/workspace/fcl/repository.bzl @@ -0,0 +1,15 @@ +# -*- python -*- + +load("@drake//tools/workspace:github.bzl", "github_archive") + +def fcl_repository( + name, + mirrors = None): + github_archive( + name = name, + repository = "flexible-collision-library/fcl", + commit = "df2702ca5e703dec98ebd725782ce13862e87fc8", + sha256 = "3ebcf2470a3ee372440cdec4cb78d1723411c3cf84f419679c2c85317c4c2dae", # noqa + build_file = ":package.BUILD.bazel", + mirrors = mirrors, + ) diff --git a/tools/workspace/fcl/version-from-xml.sed b/tools/workspace/fcl/version-from-xml.sed new file mode 100644 index 000000000000..7deca92e612a --- /dev/null +++ b/tools/workspace/fcl/version-from-xml.sed @@ -0,0 +1,4 @@ +s|.*\(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\).*|set(FCL_VERSION \1)\ +set(FCL_MAJOR_VERSION \2)\ +set(FCL_MINOR_VERSION \3)\ +set(FCL_PATCH_VERSION \4)|p