Skip to content

Commit

Permalink
[workspace] Build vendored clp_internal from source
Browse files Browse the repository at this point in the history
Deprecate the clp external.
  • Loading branch information
jwnimmer-tri committed Aug 7, 2023
1 parent d717790 commit fdde418
Show file tree
Hide file tree
Showing 22 changed files with 420 additions and 75 deletions.
1 change: 0 additions & 1 deletion setup/mac/binary_distribution/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ tap 'robotlocomotion/director'

cask 'adoptopenjdk' unless system '/usr/libexec/java_home --version 1.8+ --failfast &> /dev/null'

brew 'clp'
brew 'cmake'
brew 'double-conversion'
brew 'eigen'
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/binary_distribution/packages-focal.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
coinor-libclp1
coinor-libcoinutils3v5
default-jre
jupyter-notebook
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/binary_distribution/packages-jammy.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
coinor-libclp1
coinor-libcoinutils3v5
default-jre
jupyter-notebook
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/source_distribution/packages-focal.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
clang-format-12
coinor-libclp-dev
coinor-libcoinutils-dev
default-jdk
file
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/source_distribution/packages-jammy.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
clang-format-12
coinor-libclp-dev
coinor-libcoinutils-dev
default-jdk
file
Expand Down
2 changes: 1 addition & 1 deletion solvers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ drake_cc_variant_library(
":mathematical_program",
],
deps_enabled = [
"@clp",
"@clp_internal//:clp",
"//common:unused",
"//math:autodiff",
],
Expand Down
12 changes: 0 additions & 12 deletions tools/install/libdrake/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,6 @@ install(
],
)

# Depend on CLP's shared library iff CLP is enabled.
cc_library(
name = "clp_deps",
deps = select({
"//conditions:default": [
"@clp",
],
"//tools:no_clp": [],
}),
)

# Depend on IPOPT's shared library iff IPOPT is enabled and we're on a platform
# that uses the host OS shared library.
selects.config_setting_group(
Expand Down Expand Up @@ -237,7 +226,6 @@ cc_library(
cc_library(
name = "libdrake_runtime_so_deps",
deps = [
":clp_deps",
":gurobi_deps",
":ipopt_deps",
":mosek_deps",
Expand Down
14 changes: 0 additions & 14 deletions tools/wheel/image/dependencies/projects.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,6 @@ set(lapack_url "https://github.com/Reference-LAPACK/lapack/archive/v${lapack_ver
set(lapack_md5 "d70fc27a8bdebe00481c97c728184f09")
list(APPEND ALL_PROJECTS lapack)

# coinutils
set(coinutils_version 2.11.4)
set(coinutils_url "https://github.com/coin-or/CoinUtils/archive/refs/tags/releases/${coinutils_version}.tar.gz")
set(coinutils_md5 "dcdb2a327344014de9d8b050575fa90b")
set(coinutils_dlname "coinutils-${coinutils_version}.tar.gz")
list(APPEND ALL_PROJECTS coinutils)

# clp
set(clp_version 1.17.5)
set(clp_url "https://github.com/coin-or/Clp/archive/refs/tags/releases/${clp_version}.tar.gz")
set(clp_md5 "f7c25af22d2f03398cbbdf38c8b4f6fd")
set(clp_dlname "clp-${clp_version}.tar.gz")
list(APPEND ALL_PROJECTS clp)

# ipopt (requires mumps)
if(APPLE)
set(mumps_version 5.4.1) # Latest available in Ubuntu.
Expand Down
19 changes: 0 additions & 19 deletions tools/wheel/image/dependencies/projects/clp.cmake

This file was deleted.

18 changes: 0 additions & 18 deletions tools/wheel/image/dependencies/projects/coinutils.cmake

This file was deleted.

4 changes: 4 additions & 0 deletions tools/workspace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ drake_py_binary(
srcs = ["vendor_cxx.py"],
visibility = [
# These should all be of the form "@foo_internal//:__subpackages__".
"@clp_internal//:__subpackages__",
"@coinutils_internal//:__subpackages__",
"@conex_internal//:__subpackages__",
"@fcl_internal//:__subpackages__",
"@gz_math_internal//:__subpackages__",
Expand Down Expand Up @@ -79,6 +81,8 @@ drake_py_binary(

_DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [
"ccd_internal",
"clp_internal",
"coinutils_internal",
"com_jidesoft_jide_oss",
"common_robotics_utilities",
"commons_io",
Expand Down
1 change: 1 addition & 0 deletions tools/workspace/clp/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ def clp_repository(
modname = modname,
pkg_config_paths = pkg_config_paths,
homebrew_subdir = homebrew_subdir,
extra_deprecation = "The @clp external is deprecated in Drake's WORKSPACE and will be removed on or after 2023-12-01.", # noqa
**kwargs
)
12 changes: 12 additions & 0 deletions tools/workspace/clp_internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//tools/lint:lint.bzl", "add_lint_tests")

filegroup(
name = "patches",
srcs = glob(
["patches/**"],
allow_empty = True,
),
visibility = ["//visibility:public"],
)

add_lint_tests()
166 changes: 166 additions & 0 deletions tools/workspace/clp_internal/package.BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# -*- bazel -*-

load(
"@drake//tools/install:install.bzl",
"install",
)
load(
"@drake//tools/workspace/coinutils_internal:defs.bzl",
"coin_cc_library",
)

licenses(["reciprocal"]) # EPL-2.0

package(default_visibility = ["//visibility:private"])

exports_files([
# Always provide access to license texts.
"LICENSE",
])

_HDRS = glob(
[
"Clp/src/*.h",
"Clp/src/*.hpp",
],
exclude = [
"**/config*",
"**/*Config.h",
],
allow_empty = False,
)

_SRCS = glob(
[
"Clp/src/*.cpp",
],
exclude = [
"**/ClpMain*",
# We treat COIN_HAS_ABC as OFF.
"**/Abc*",
"**/CoinAbc*",
# We treat COIN_HAS_AMD, COIN_HAS_CHOLMOD, and COIN_HAS_GLPK as OFF.
"**/ClpCholeskyUfl*",
# We treat COIN_HAS_MUMPS as OFF.
# TODO(jwnimmer-tri) We can probably enable this. I've left it off for
# now only out of inertia -- Ubuntu builds CLP without MUMPS.
"**/ClpCholeskyMumps*",
# We treat COIN_HAS_WSMP as OFF.
"**/ClpCholeskyWssmp*",
],
allow_empty = False,
)

_AUTOCONF_DEFINES = [
"CLP_VERSION=\"drake_vendor\"",
"PACKAGE_VERSION=\"drake_vendor\"",
"VERSION=\"drake_vendor\"",
# Features of the standard library and/or host system.
"HAVE_CFLOAT=1",
"HAVE_CMATH=1",
"HAVE_FLOAT_H=1",
"HAVE_INTTYPES_H=1",
"HAVE_MATH_H=1",
"HAVE_STDINT_H=1",
"HAVE_STDLIB_H=1",
"HAVE_STRINGS_H=1",
"HAVE_STRING_H=1",
"HAVE_SYS_STAT_H=1",
"HAVE_SYS_TYPES_H=1",
"HAVE_UNISTD_H=1",
"STDC_HEADERS=1",
# Optional dependencies that we do actually want to use.
"COIN_HAS_BLAS=1",
"COIN_HAS_COINUTILS=1",
# No debug self-checks (the default).
"COIN_CLP_CHECKLEVEL=0",
"COIN_CLP_VERBOSITY=0",
# These are no-ops, but they can't be omitted.
"CLP_VERSION_MAJOR",
"CLP_VERSION_MINOR",
"CLP_VERSION_RELEASE",
]

_AUTOCONF_UNDEFINES = [
# Don't use these features of the standard library and/or host system.
"F77_DUMMY_MAIN",
"F77_FUNC_",
"FC_DUMMY_MAIN_EQ_F77",
"HAVE_CIEEEFP",
"HAVE_DLFCN_H",
"HAVE_IEEEFP_H",
"HAVE_MEMORY_H",
# TODO(jwnimmer-tri) We can probably enable this. I've left it off for now
# only out of inertia -- Ubuntu builds CLP without MUMPS.
"COIN_HAS_MUMPS",
# Optional dependencies that we don't use.
"CLP_HAS_ABC",
"COIN_HAS_AMD",
"COIN_HAS_ASL",
"COIN_HAS_CHOLMOD",
"COIN_HAS_GLPK",
"COIN_HAS_NETLIB",
"COIN_HAS_OSI",
"COIN_HAS_OSITESTS",
"COIN_HAS_READLINE",
"COIN_HAS_SAMPLE",
"COIN_HAS_WSMP",
"HAVE_READLINE_READLINE_H",
# Chaff.
"CLP_SVN_REV",
"PACKAGE",
"PACKAGE_BUGREPORT",
"PACKAGE_NAME",
"PACKAGE_STRING",
"PACKAGE_TARNAME",
# This is actually used by the C++ code, but autoconf_configure_file can't
# handle it. We'll use _CONFIG_PRIVATE_DEFINES for this instead, below.
"F77_FUNC",
]

_CONFIG_PRIVATE_DEFINES = [
"F77_FUNC(name,NAME)=name##_",
# This is consistent with a bespoke definition in the upstream Makefile.am.
# This definition is somehow not provided by autoconf.
"COIN_HAS_CLP=1",
]

_INCLUDES = [
"Clp/src/",
]

coin_cc_library(
name = "clp",
config_h = "ClpConfig.h",
config_h_public = "Clp/src/config_clp_default.h",
config_h_private = "Clp/src/config.h.in",
autoconf_defines = _AUTOCONF_DEFINES,
autoconf_undefines = _AUTOCONF_UNDEFINES,
config_private_defines = _CONFIG_PRIVATE_DEFINES,
hdrs_public = _HDRS,
includes_public = _INCLUDES,
hdrs_private = _HDRS,
includes_private = _INCLUDES,
srcs = _SRCS,
vendor_tool_args = ["--no-inline-namespace"],
output_vendoring_patch = "drake_clp.patch",
deps = [
"@coinutils_internal//:coinutils",
],
visibility = ["//visibility:public"],
)

install(
name = "install",
docs = [
"LICENSE",
# We must redistribute our code changes, per Clp EPL-2.0 license.
":drake_clp.patch",
"@drake//tools/workspace/clp_internal:patches",
],
allowed_externals = [
"@drake//tools/workspace/clp_internal:patches",
],
doc_strip_prefix = ["patches"],
visibility = ["//visibility:public"],
)
12 changes: 12 additions & 0 deletions tools/workspace/clp_internal/patches/missing_include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[clp] Add missing include for COIN_DBL_MAX

--- Clp/src/CbcOrClpParam.cpp
+++ Clp/src/CbcOrClpParam.cpp
@@ -3,6 +3,7 @@
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).

+#include "CoinFinite.hpp"
#include "CoinPragma.hpp"
#include "CoinTime.hpp"
#include "CbcOrClpParam.hpp"
19 changes: 19 additions & 0 deletions tools/workspace/clp_internal/repository.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load(
"@drake//tools/workspace:github.bzl",
"github_archive",
)

def clp_internal_repository(
name,
mirrors = None):
github_archive(
name = name,
repository = "coin-or/Clp",
commit = "releases/1.17.8",
sha256 = "f9931b5ba44f0daf445c6b48fc2c250dc12e667e59ace8ea7b025f158fe31556", # noqa
build_file = ":package.BUILD.bazel",
patches = [
":patches/missing_include.patch",
],
mirrors = mirrors,
)
13 changes: 9 additions & 4 deletions tools/workspace/coinutils_internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
load("//tools/lint:lint.bzl", "add_lint_tests")

add_lint_tests()
filegroup(
name = "patches",
srcs = glob(
["patches/**"],
allow_empty = True,
),
visibility = ["//visibility:public"],
)

# TODO(jwnimmer-tri) In the future, we anticipate adding coinutils as an actual
# workspace dependency. For now, this is just a convenient place to store some
# COIN-OR related Bazel macros.
add_lint_tests()
Loading

0 comments on commit fdde418

Please sign in to comment.