From ee9ed6069f09bb0f05a1a8a897bc96ffbfbf1ae9 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Sat, 28 Jan 2023 20:37:26 -0800 Subject: [PATCH] [workspace] Deprecate public use of several externals Add a suitesparse_internal repository to rebuild (the AMD part of) SuiteSparse from source with hidden visibility. Remove SuiteSparse from the host and wheel dependencies. Deprecate the public (host) suitesparse external. Rename OSQP, QDLDL, SCS to use the "_internal" suffix and deprecate their non-internal spellings. (They are all C libraries that already use hidden visibility, so they don't need any C++ vendoring changes to their BUILD.) --- setup/mac/binary_distribution/Brewfile | 1 - .../binary_distribution/packages-focal.txt | 1 - .../binary_distribution/packages-jammy.txt | 1 - .../source_distribution/packages-focal.txt | 1 - .../source_distribution/packages-jammy.txt | 1 - solvers/BUILD.bazel | 4 +- tools/install/check_licenses.bzl | 1 + .../patches/suitesparse/patch.cmake | 37 --------- .../patches/suitesparse/patch.diff | 50 ------------- tools/wheel/image/dependencies/projects.cmake | 6 -- .../dependencies/projects/suitesparse.cmake | 22 ------ tools/workspace/BUILD.bazel | 7 +- tools/workspace/default.bzl | 35 +++++++-- .../{osqp => osqp_internal}/BUILD.bazel | 0 .../package.BUILD.bazel | 9 ++- .../{osqp => osqp_internal}/repository.bzl | 2 +- .../{qdldl => qdldl_internal}/BUILD.bazel | 0 .../{qdldl => qdldl_internal}/README.md | 0 .../package.BUILD.bazel | 8 +- .../{qdldl => qdldl_internal}/repository.bzl | 2 +- .../{scs => scs_internal}/BUILD.bazel | 0 .../{scs => scs_internal}/package.BUILD.bazel | 8 +- .../{scs => scs_internal}/private.h.diff | 0 .../{scs => scs_internal}/repository.bzl | 4 +- .../workspace/suitesparse/package.BUILD.bazel | 1 + .../suitesparse_internal/BUILD.bazel | 8 ++ .../suitesparse_internal/package.BUILD.bazel | 75 +++++++++++++++++++ .../suitesparse_internal/repository.bzl | 15 ++++ 28 files changed, 152 insertions(+), 147 deletions(-) delete mode 100644 tools/wheel/image/dependencies/patches/suitesparse/patch.cmake delete mode 100644 tools/wheel/image/dependencies/patches/suitesparse/patch.diff delete mode 100644 tools/wheel/image/dependencies/projects/suitesparse.cmake rename tools/workspace/{osqp => osqp_internal}/BUILD.bazel (100%) rename tools/workspace/{osqp => osqp_internal}/package.BUILD.bazel (91%) rename tools/workspace/{osqp => osqp_internal}/repository.bzl (94%) rename tools/workspace/{qdldl => qdldl_internal}/BUILD.bazel (100%) rename tools/workspace/{qdldl => qdldl_internal}/README.md (100%) rename tools/workspace/{qdldl => qdldl_internal}/package.BUILD.bazel (84%) rename tools/workspace/{qdldl => qdldl_internal}/repository.bzl (93%) rename tools/workspace/{scs => scs_internal}/BUILD.bazel (100%) rename tools/workspace/{scs => scs_internal}/package.BUILD.bazel (85%) rename tools/workspace/{scs => scs_internal}/private.h.diff (100%) rename tools/workspace/{scs => scs_internal}/repository.bzl (89%) create mode 100644 tools/workspace/suitesparse_internal/BUILD.bazel create mode 100644 tools/workspace/suitesparse_internal/package.BUILD.bazel create mode 100644 tools/workspace/suitesparse_internal/repository.bzl diff --git a/setup/mac/binary_distribution/Brewfile b/setup/mac/binary_distribution/Brewfile index 09967d9631fa..79b5b468b4f0 100644 --- a/setup/mac/binary_distribution/Brewfile +++ b/setup/mac/binary_distribution/Brewfile @@ -24,7 +24,6 @@ brew 'openblas' brew 'pkg-config' brew 'python@3.10' brew 'spdlog' -brew 'suite-sparse' brew 'tinyxml' brew 'robotlocomotion/director/vtk@9.1.0' brew 'xz' diff --git a/setup/ubuntu/binary_distribution/packages-focal.txt b/setup/ubuntu/binary_distribution/packages-focal.txt index fa986d315ccb..c34376de8c84 100644 --- a/setup/ubuntu/binary_distribution/packages-focal.txt +++ b/setup/ubuntu/binary_distribution/packages-focal.txt @@ -3,7 +3,6 @@ coinor-libcoinutils3v5 coinor-libipopt1v5 default-jre jupyter-notebook -libamd2 libblas3 libbz2-1.0 libdouble-conversion3 diff --git a/setup/ubuntu/binary_distribution/packages-jammy.txt b/setup/ubuntu/binary_distribution/packages-jammy.txt index 7d320b841473..60e889dc4292 100644 --- a/setup/ubuntu/binary_distribution/packages-jammy.txt +++ b/setup/ubuntu/binary_distribution/packages-jammy.txt @@ -3,7 +3,6 @@ coinor-libcoinutils3v5 coinor-libipopt1v5 default-jre jupyter-notebook -libamd2 libblas-dev libbz2-1.0 libdouble-conversion3 diff --git a/setup/ubuntu/source_distribution/packages-focal.txt b/setup/ubuntu/source_distribution/packages-focal.txt index 6cd410715bc7..98dbdd8e9eca 100644 --- a/setup/ubuntu/source_distribution/packages-focal.txt +++ b/setup/ubuntu/source_distribution/packages-focal.txt @@ -24,7 +24,6 @@ libmumps-seq-dev libnlopt-cxx-dev libopengl-dev libpng-dev -libsuitesparse-dev libtiff-dev libtinyxml-dev libtool diff --git a/setup/ubuntu/source_distribution/packages-jammy.txt b/setup/ubuntu/source_distribution/packages-jammy.txt index 95f0fc882802..5c8698103b66 100644 --- a/setup/ubuntu/source_distribution/packages-jammy.txt +++ b/setup/ubuntu/source_distribution/packages-jammy.txt @@ -23,7 +23,6 @@ libmumps-seq-dev libnlopt-cxx-dev libopengl-dev libpng-dev -libsuitesparse-dev libtiff-dev libtinyxml-dev libtool diff --git a/solvers/BUILD.bazel b/solvers/BUILD.bazel index 277d6e2d5f3c..f8d59eccd8b8 100644 --- a/solvers/BUILD.bazel +++ b/solvers/BUILD.bazel @@ -980,7 +980,7 @@ drake_cc_variant_library( ], deps_enabled = [ "//math:eigen_sparse_triplet", - "@osqp", + "@osqp_internal//:osqp", ], ) @@ -1003,7 +1003,7 @@ drake_cc_variant_library( deps_enabled = [ "//common:scope_exit", "//math:eigen_sparse_triplet", - "@scs//:scsdir", + "@scs_internal//:scsdir", ], ) diff --git a/tools/install/check_licenses.bzl b/tools/install/check_licenses.bzl index 32827353a4c7..0ddc5614503d 100644 --- a/tools/install/check_licenses.bzl +++ b/tools/install/check_licenses.bzl @@ -16,6 +16,7 @@ LICENSE_LITERALS = [ LICENSE_PREFIXES = [ "COPYING.", "LICENSE.", + "License.", ] #------------------------------------------------------------------------------ diff --git a/tools/wheel/image/dependencies/patches/suitesparse/patch.cmake b/tools/wheel/image/dependencies/patches/suitesparse/patch.cmake deleted file mode 100644 index 992407ee354d..000000000000 --- a/tools/wheel/image/dependencies/patches/suitesparse/patch.cmake +++ /dev/null @@ -1,37 +0,0 @@ -if(APPLE) - execute_process( - COMMAND gfortran --print-file-name=libgfortran.dylib - OUTPUT_VARIABLE _gfortran_lib - RESULT_VARIABLE _gfortran_result - ) - - if(NOT _gfortran_result EQUAL 0) - message(FATAL_ERROR "gfortran was not found") - endif() - - get_filename_component(_gfortran_lib "${_gfortran_lib}" REALPATH) - get_filename_component(_gfortran_libdir "${_gfortran_lib}" DIRECTORY) - - set(LIBRT) - set(LDFLAGS_GFORTRAN "-L${_gfortran_libdir} -lgfortran") -else() - set(LIBRT "-lrt") - set(LDFLAGS_GFORTRAN "-lgfortran") -endif() - -file( - RENAME - ${suitesparse_source}/SuiteSparse_config/SuiteSparse_config.mk - ${suitesparse_source}/SuiteSparse_config/SuiteSparse_config.mk.in - ) - -execute_process( - COMMAND git apply ${suitesparse_patch}/patch.diff - WORKING_DIRECTORY ${suitesparse_source} - ) - -configure_file( - ${suitesparse_source}/SuiteSparse_config/SuiteSparse_config.mk.in - ${suitesparse_source}/SuiteSparse_config/SuiteSparse_config.mk - @ONLY - ) diff --git a/tools/wheel/image/dependencies/patches/suitesparse/patch.diff b/tools/wheel/image/dependencies/patches/suitesparse/patch.diff deleted file mode 100644 index b3609faeb715..000000000000 --- a/tools/wheel/image/dependencies/patches/suitesparse/patch.diff +++ /dev/null @@ -1,50 +0,0 @@ -diff --git a/SuiteSparse_config/SuiteSparse_config.mk.in b/SuiteSparse_config/SuiteSparse_config.mk.in -index 3ab813c..e5cba3e 100644 ---- a/SuiteSparse_config/SuiteSparse_config.mk.in -+++ b/SuiteSparse_config/SuiteSparse_config.mk.in -@@ -61,7 +61,7 @@ - # If OpenMP is used, it is recommended to define CHOLMOD_OMP_NUM_THREADS - # as the number of cores per socket on the machine being used to maximize - # memory performance -- CFLAGS = -+ CFLAGS = -fPIC - # CFLAGS = -g - # for the icc compiler and OpenMP: - # CFLAGS = -openmp -@@ -90,13 +90,13 @@ F77FLAGS = $(FFLAGS) -O - F77LIB = - - # C and Fortran libraries. Remove -lrt if you don't have it. -- LIB = -lm -lrt -+ LIB = -lm @LIBRT@ - # Using the following requires CF = ... -DNTIMER on POSIX C systems. - # LIB = -lm - - # For "make install" --INSTALL_LIB = /usr/local/lib --INSTALL_INCLUDE = /usr/local/include -+INSTALL_LIB = @INSTALL_PREFIX@/lib -+INSTALL_INCLUDE = @INSTALL_PREFIX@/include - - # Which version of MAKE you are using (default is "make") - # MAKE = make -@@ -119,8 +119,8 @@ INSTALL_INCLUDE = /usr/local/include - # naming the BLAS and LAPACK library (*.a or *.so) files. - - # This is probably slow ... it might connect to the Standard Reference BLAS: --# BLAS = -lblas -lgfortran -- LAPACK = -llapack -+BLAS = -L@INSTALL_PREFIX@/lib -lblas @LDFLAGS_GFORTRAN@ -+LAPACK = -L@INSTALL_PREFIX@/lib -llapack - - # MKL - # BLAS = -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a -Wl,--end-group -lpthread -lm -@@ -131,7 +131,7 @@ INSTALL_INCLUDE = /usr/local/include - # LAPACK = - - # OpenBLAS -- BLAS = -lopenblas -+# BLAS = -lopenblas - # LAPACK = - - # NOTE: this next option for the "Goto BLAS" has nothing to do with a "goto" diff --git a/tools/wheel/image/dependencies/projects.cmake b/tools/wheel/image/dependencies/projects.cmake index 1d7762cc2e7c..7709663b80f1 100644 --- a/tools/wheel/image/dependencies/projects.cmake +++ b/tools/wheel/image/dependencies/projects.cmake @@ -76,12 +76,6 @@ set(lapack_url "https://github.com/Reference-LAPACK/lapack/archive/v${lapack_ver set(lapack_md5 "d70fc27a8bdebe00481c97c728184f09") list(APPEND ALL_PROJECTS lapack) -# suitesparse -set(suitesparse_version 4.4.5) -set(suitesparse_url "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${suitesparse_version}.tar.gz") -set(SuiteSparse_md5 "a2926c27f8a5285e4a10265cc68bbc18") -list(APPEND ALL_PROJECTS suitesparse) - # coinutils set(coinutils_version 2.11.4) set(coinutils_url "https://github.com/coin-or/CoinUtils/archive/refs/tags/releases/${coinutils_version}.tar.gz") diff --git a/tools/wheel/image/dependencies/projects/suitesparse.cmake b/tools/wheel/image/dependencies/projects/suitesparse.cmake deleted file mode 100644 index 22a258121a95..000000000000 --- a/tools/wheel/image/dependencies/projects/suitesparse.cmake +++ /dev/null @@ -1,22 +0,0 @@ -ExternalProject_Add(suitesparse - DEPENDS lapack - URL ${suitesparse_url} - URL_MD5 ${suitesparse_md5} - ${COMMON_EP_ARGS} - BUILD_IN_SOURCE 1 - PATCH_COMMAND ${CMAKE_COMMAND} - -Dsuitesparse_patch=${CMAKE_SOURCE_DIR}/patches/suitesparse - -Dsuitesparse_source=${CMAKE_BINARY_DIR}/src/suitesparse - -DINSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} - -P ${CMAKE_SOURCE_DIR}/patches/suitesparse/patch.cmake - CONFIGURE_COMMAND "" - BUILD_COMMAND make - INSTALL_COMMAND make install - ) - -# Note: SuiteSparse consists of several "packages" with varying licenses; here, -# we extract the licenses only for packages Drake actually uses. If the set of -# used packages changes, this will need to be updated. -extract_license(suitesparse - AMD/Doc/License.txt -) diff --git a/tools/workspace/BUILD.bazel b/tools/workspace/BUILD.bazel index 3f61412ab5eb..f344028dce5e 100644 --- a/tools/workspace/BUILD.bazel +++ b/tools/workspace/BUILD.bazel @@ -100,6 +100,7 @@ _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [ "spdlog", "statsjs", "stduuid_internal", + "suitesparse_internal", "tinyobjloader", "tinyxml2_internal", "usockets", @@ -132,12 +133,12 @@ _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [ "//conditions:default": [], }) + select({ "//conditions:default": [ - "@osqp//:install", - "@qdldl//:install", + "@osqp_internal//:install", + "@qdldl_internal//:install", ], "//tools:no_osqp": [], }) + select({ - "//conditions:default": ["@scs//:install"], + "//conditions:default": ["@scs_internal//:install"], "//tools:no_scs": [], }) diff --git a/tools/workspace/default.bzl b/tools/workspace/default.bzl index e1f4e2974021..f74fa7215ded 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 @@ -69,7 +70,7 @@ load("@drake//tools/workspace/opencl:repository.bzl", "opencl_repository") load("@drake//tools/workspace/opengl:repository.bzl", "opengl_repository") load("@drake//tools/workspace/optitrack_driver:repository.bzl", "optitrack_driver_repository") # noqa load("@drake//tools/workspace/org_apache_xmlgraphics_commons:repository.bzl", "org_apache_xmlgraphics_commons_repository") # noqa -load("@drake//tools/workspace/osqp:repository.bzl", "osqp_repository") +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/picosat:repository.bzl", "picosat_repository") load("@drake//tools/workspace/picosha2:repository.bzl", "picosha2_repository") @@ -77,12 +78,12 @@ load("@drake//tools/workspace/platforms:repository.bzl", "platforms_repository") load("@drake//tools/workspace/pybind11:repository.bzl", "pybind11_repository") load("@drake//tools/workspace/pycodestyle:repository.bzl", "pycodestyle_repository") # noqa load("@drake//tools/workspace/python:repository.bzl", "python_repository") -load("@drake//tools/workspace/qdldl:repository.bzl", "qdldl_repository") +load("@drake//tools/workspace/qdldl_internal:repository.bzl", "qdldl_internal_repository") # noqa load("@drake//tools/workspace/qhull_internal:repository.bzl", "qhull_internal_repository") # noqa load("@drake//tools/workspace/ros_xacro_internal:repository.bzl", "ros_xacro_internal_repository") # noqa 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/scs_internal:repository.bzl", "scs_internal_repository") # noqa 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") @@ -92,6 +93,7 @@ load("@drake//tools/workspace/stduuid:repository.bzl", "stduuid_repository") load("@drake//tools/workspace/stduuid_internal:repository.bzl", "stduuid_internal_repository") # noqa load("@drake//tools/workspace/styleguide:repository.bzl", "styleguide_repository") # noqa load("@drake//tools/workspace/suitesparse:repository.bzl", "suitesparse_repository") # noqa +load("@drake//tools/workspace/suitesparse_internal:repository.bzl", "suitesparse_internal_repository") # noqa load("@drake//tools/workspace/tinyobjloader:repository.bzl", "tinyobjloader_repository") # noqa load("@drake//tools/workspace/tinyxml2_internal:repository.bzl", "tinyxml2_internal_repository") # noqa load("@drake//tools/workspace/tomli_internal:repository.bzl", "tomli_internal_repository") # noqa @@ -263,7 +265,13 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): if "org_apache_xmlgraphics_commons" not in excludes: org_apache_xmlgraphics_commons_repository(name = "org_apache_xmlgraphics_commons", mirrors = mirrors) # noqa if "osqp" not in excludes: - osqp_repository(name = "osqp", mirrors = mirrors) + add_deprecation( + name = "osqp", + date = "2023-05-01", + cc_aliases = {"osqp": "@osqp_internal//:osqp"}, + ) + if "osqp_internal" not in excludes: + osqp_internal_repository(name = "osqp_internal", mirrors = mirrors) if "petsc" not in excludes: petsc_repository(name = "petsc", mirrors = mirrors) if "picosat" not in excludes: @@ -281,7 +289,13 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): if "python" not in excludes: python_repository(name = "python") if "qdldl" not in excludes: - qdldl_repository(name = "qdldl", mirrors = mirrors) + add_deprecation( + name = "qdldl", + date = "2023-05-01", + cc_aliases = {"qdldl": "@qdldl_internal//:qdldl"}, + ) + if "qdldl_internal" not in excludes: + qdldl_internal_repository(name = "qdldl_internal", mirrors = mirrors) if "qhull_internal" not in excludes: qhull_internal_repository(name = "qhull_internal", mirrors = mirrors) if "ros_xacro_internal" not in excludes: @@ -291,7 +305,13 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): if "rules_python" not in excludes: rules_python_repository(name = "rules_python", mirrors = mirrors) if "scs" not in excludes: - scs_repository(name = "scs", mirrors = mirrors) + add_deprecation( + name = "scs", + date = "2023-05-01", + cc_aliases = {"scsdir": "@scs_internal//:scsdir"}, + ) + if "scs_internal" not in excludes: + scs_internal_repository(name = "scs_internal", mirrors = mirrors) if "sdformat_internal" not in excludes: sdformat_internal_repository(name = "sdformat_internal", mirrors = mirrors) # noqa if "snopt" not in excludes: @@ -309,7 +329,10 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): if "styleguide" not in excludes: styleguide_repository(name = "styleguide", mirrors = mirrors) if "suitesparse" not in excludes: + # N.B. This repository is deprecated for removal on 2023-05-01. suitesparse_repository(name = "suitesparse") + if "suitesparse_internal" not in excludes: + suitesparse_internal_repository(name = "suitesparse_internal", mirrors = mirrors) # noqa if "tinyobjloader" not in excludes: tinyobjloader_repository(name = "tinyobjloader", mirrors = mirrors) if "tinyxml2_internal" not in excludes: diff --git a/tools/workspace/osqp/BUILD.bazel b/tools/workspace/osqp_internal/BUILD.bazel similarity index 100% rename from tools/workspace/osqp/BUILD.bazel rename to tools/workspace/osqp_internal/BUILD.bazel diff --git a/tools/workspace/osqp/package.BUILD.bazel b/tools/workspace/osqp_internal/package.BUILD.bazel similarity index 91% rename from tools/workspace/osqp/package.BUILD.bazel rename to tools/workspace/osqp_internal/package.BUILD.bazel index c422313985d9..0d58645e250a 100644 --- a/tools/workspace/osqp/package.BUILD.bazel +++ b/tools/workspace/osqp_internal/package.BUILD.bazel @@ -24,8 +24,9 @@ cmake_configure_file( "PRINTING", "PROFILING", # Keep the default primitive size of `double` and `int`. Don't define - # 'DFLOAT' nor 'DLONG' unless @qdldl and @scs are also changed to use - # those primitive sizes. See drake/tools/workspace/qdldl/README.md. + # 'DFLOAT' nor 'DLONG' unless @qdldl_internal and @scs_internal are + # also changed to use those primitive sizes. + # See drake/tools/workspace/qdldl_internal/README.md. ] + select({ "@drake//tools/cc_toolchain:apple": [ "IS_MAC", @@ -99,8 +100,8 @@ cc_library( ], linkstatic = 1, deps = [ - "@qdldl", - "@suitesparse//:amd", + "@qdldl_internal//:qdldl", + "@suitesparse_internal//:amd", ], ) diff --git a/tools/workspace/osqp/repository.bzl b/tools/workspace/osqp_internal/repository.bzl similarity index 94% rename from tools/workspace/osqp/repository.bzl rename to tools/workspace/osqp_internal/repository.bzl index 1954d2ac9e78..0297a44bbc0b 100644 --- a/tools/workspace/osqp/repository.bzl +++ b/tools/workspace/osqp_internal/repository.bzl @@ -2,7 +2,7 @@ load("@drake//tools/workspace:github.bzl", "github_archive") -def osqp_repository( +def osqp_internal_repository( name, mirrors = None): github_archive( diff --git a/tools/workspace/qdldl/BUILD.bazel b/tools/workspace/qdldl_internal/BUILD.bazel similarity index 100% rename from tools/workspace/qdldl/BUILD.bazel rename to tools/workspace/qdldl_internal/BUILD.bazel diff --git a/tools/workspace/qdldl/README.md b/tools/workspace/qdldl_internal/README.md similarity index 100% rename from tools/workspace/qdldl/README.md rename to tools/workspace/qdldl_internal/README.md diff --git a/tools/workspace/qdldl/package.BUILD.bazel b/tools/workspace/qdldl_internal/package.BUILD.bazel similarity index 84% rename from tools/workspace/qdldl/package.BUILD.bazel rename to tools/workspace/qdldl_internal/package.BUILD.bazel index 09792607dac0..fc69b08dfe95 100644 --- a/tools/workspace/qdldl/package.BUILD.bazel +++ b/tools/workspace/qdldl_internal/package.BUILD.bazel @@ -22,12 +22,12 @@ cmake_configure_file( # https://github.com/osqp/qdldl/blob/v0.1.6/README.md#custom-types-for-integer-floats-and-booleans defines = [ "QDLDL_BOOL_TYPE=unsigned char", - # Keep the `int` type sync'd with the @osqp and @scs build. - # See drake/tools/workspace/qdldl/README.md. + # Keep the `int` type sync'd with the build of @osqp_internal and + # @scs_internal. See drake/tools/workspace/qdldl_internal/README.md. "QDLDL_INT_TYPE=int", "QDLDL_LONG=0", - # Keep the `double` type sync'd with the @osqp and @scs build. - # See drake/tools/workspace/qdldl/README.md. + # Keep the `int` type sync'd with the build of @osqp_internal and + # @scs_internal. See drake/tools/workspace/qdldl_internal/README.md. "QDLDL_FLOAT_TYPE=double", "QDLDL_FLOAT=0", # Match this to QDLDL_INT_TYPE above. diff --git a/tools/workspace/qdldl/repository.bzl b/tools/workspace/qdldl_internal/repository.bzl similarity index 93% rename from tools/workspace/qdldl/repository.bzl rename to tools/workspace/qdldl_internal/repository.bzl index b69a1e281c12..41aebed5502e 100644 --- a/tools/workspace/qdldl/repository.bzl +++ b/tools/workspace/qdldl_internal/repository.bzl @@ -2,7 +2,7 @@ load("@drake//tools/workspace:github.bzl", "github_archive") -def qdldl_repository( +def qdldl_internal_repository( name, mirrors = None): github_archive( diff --git a/tools/workspace/scs/BUILD.bazel b/tools/workspace/scs_internal/BUILD.bazel similarity index 100% rename from tools/workspace/scs/BUILD.bazel rename to tools/workspace/scs_internal/BUILD.bazel diff --git a/tools/workspace/scs/package.BUILD.bazel b/tools/workspace/scs_internal/package.BUILD.bazel similarity index 85% rename from tools/workspace/scs/package.BUILD.bazel rename to tools/workspace/scs_internal/package.BUILD.bazel index b18e0e768051..991040ad9f49 100644 --- a/tools/workspace/scs/package.BUILD.bazel +++ b/tools/workspace/scs_internal/package.BUILD.bazel @@ -30,8 +30,8 @@ cc_library( defines = [ "USE_LAPACK=1", # Keep the default primitive size of `double` and `int`. Don't define - # 'SFLOAT' nor 'DLONG' unless @qdldl and @osqp are also changed to use - # those primitive sizes. + # 'SFLOAT' nor 'DLONG' unless @qdldl_internal and @osqp_internal are + # also changed to use those primitive sizes. ], includes = [ "include", @@ -51,8 +51,8 @@ cc_library( deps = [ "@blas", "@lapack", - "@qdldl", - "@suitesparse//:amd", + "@qdldl_internal//:qdldl", + "@suitesparse_internal//:amd", ], ) diff --git a/tools/workspace/scs/private.h.diff b/tools/workspace/scs_internal/private.h.diff similarity index 100% rename from tools/workspace/scs/private.h.diff rename to tools/workspace/scs_internal/private.h.diff diff --git a/tools/workspace/scs/repository.bzl b/tools/workspace/scs_internal/repository.bzl similarity index 89% rename from tools/workspace/scs/repository.bzl rename to tools/workspace/scs_internal/repository.bzl index 7f8b4a56bb76..72884be4bd3f 100644 --- a/tools/workspace/scs/repository.bzl +++ b/tools/workspace/scs_internal/repository.bzl @@ -2,7 +2,7 @@ load("@drake//tools/workspace:github.bzl", "github_archive") -def scs_repository( +def scs_internal_repository( name, mirrors = None): github_archive( @@ -16,7 +16,7 @@ def scs_repository( # Fix some include paths for our build of QDLDL. # TODO(jwnimmer-tri) We should upstream these options under a # config switch. - "@drake//tools/workspace/scs:private.h.diff", + ":private.h.diff", ], mirrors = mirrors, ) diff --git a/tools/workspace/suitesparse/package.BUILD.bazel b/tools/workspace/suitesparse/package.BUILD.bazel index e631bc086b06..c65ebd7d778c 100644 --- a/tools/workspace/suitesparse/package.BUILD.bazel +++ b/tools/workspace/suitesparse/package.BUILD.bazel @@ -21,4 +21,5 @@ cc_library( "-lsuitesparseconfig", ], licenses = ["notice"], # BSD-3-Clause + deprecation = "DRAKE DEPRECATED: The @suitesparse external is deprecated. The deprecated code will be removed from Drake on or after 2023-05-01.", # noqa ) diff --git a/tools/workspace/suitesparse_internal/BUILD.bazel b/tools/workspace/suitesparse_internal/BUILD.bazel new file mode 100644 index 000000000000..2e5301dc6578 --- /dev/null +++ b/tools/workspace/suitesparse_internal/BUILD.bazel @@ -0,0 +1,8 @@ +# -*- python -*- + +# This file exists to make our directory into a Bazel package, so that our +# neighboring *.bzl file can be loaded elsewhere. + +load("//tools/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/tools/workspace/suitesparse_internal/package.BUILD.bazel b/tools/workspace/suitesparse_internal/package.BUILD.bazel new file mode 100644 index 000000000000..85b8c5cd994d --- /dev/null +++ b/tools/workspace/suitesparse_internal/package.BUILD.bazel @@ -0,0 +1,75 @@ +# -*- python -*- + +load( + "@drake//tools/install:install.bzl", + "install", +) + +licenses(["notice"]) # BSD-3-Clause + +package(default_visibility = ["//visibility:private"]) + +cc_library( + name = "config", + srcs = ["SuiteSparse_config/SuiteSparse_config.c"], + hdrs = ["SuiteSparse_config/SuiteSparse_config.h"], + strip_include_prefix = "SuiteSparse_config", + linkstatic = True, + visibility = ["//visibility:public"], +) + +# The header for libamd. +cc_library( + name = "amd_hdrs", + hdrs = [ + "AMD/Include/amd_internal.h", + "AMD/Include/amd.h", + ], + strip_include_prefix = "AMD/Include", + linkstatic = True, + deps = [ + ":config", + ], +) + +# The libamd sources are compiled twice, once as 32-bit and once as 64-bit. +_AMD_SRCS = glob( + ["AMD/Source/amd_*.c"], + exclude = ["AMD/Source/amd_l*.c"], + allow_empty = False, +) + +cc_library( + name = "amd_32bit", + srcs = _AMD_SRCS, + copts = ["-fvisibility=hidden"], + linkstatic = True, + deps = [":amd_hdrs"], +) + +cc_library( + name = "amd_64bit", + copts = ["-fvisibility=hidden", "-DDLONG=1"], + srcs = _AMD_SRCS, + linkstatic = True, + deps = [":amd_hdrs"], +) + +cc_library( + name = "amd", + linkstatic = True, + deps = [ + ":amd_32bit", + ":amd_64bit", + ], + visibility = ["//visibility:public"], +) + +# N.B. Most of SuiteSparse is GPL/LGPL licensed. Do NOT add any of those +# libraries here. We must only use the BSD components of SuiteSparse. + +install( + name = "install", + docs = ["AMD/Doc/License.txt"], + visibility = ["//visibility:public"], +) diff --git a/tools/workspace/suitesparse_internal/repository.bzl b/tools/workspace/suitesparse_internal/repository.bzl new file mode 100644 index 000000000000..bebaaf0e4054 --- /dev/null +++ b/tools/workspace/suitesparse_internal/repository.bzl @@ -0,0 +1,15 @@ +# -*- mode: python -*- + +load("@drake//tools/workspace:github.bzl", "github_archive") + +def suitesparse_internal_repository( + name, + mirrors = None): + github_archive( + name = name, + repository = "DrTimothyAldenDavis/SuiteSparse", + commit = "v7.0.1", + sha256 = "dc2f8d5c2657c120b30cce942f634ec08fc3a4b0b10e19d3eef7790b2bec8d1e", # noqa + build_file = ":package.BUILD.bazel", + mirrors = mirrors, + )