diff --git a/solvers/test/ibex_solver_test.cc b/solvers/test/ibex_solver_test.cc index 422dbd3c3a6d..60272bca9dee 100644 --- a/solvers/test/ibex_solver_test.cc +++ b/solvers/test/ibex_solver_test.cc @@ -1,5 +1,7 @@ #include "drake/solvers/ibex_solver.h" +#include + #include #include #include @@ -108,13 +110,13 @@ TEST_F(IbexSolverTest, GenericCost) { prog_.AddCost(Binding(generic_cost, x_)); EXPECT_FALSE(prog_.generic_costs().empty()); if (solver_.available()) { - auto result = solver_.Solve(prog_, {}); + auto result = solver_.Solve(prog_); ASSERT_TRUE(result.is_success()); const auto x_val = result.GetSolution(prog_.decision_variables()); const double v0{result.GetSolution(x0)}; const double v1{result.GetSolution(x1)}; const double v2{result.GetSolution(x2)}; - EXPECT_NEAR(v0, 1.4142135623730951, 1e-8); + EXPECT_NEAR(v0, M_SQRT2, 1e-8); EXPECT_NEAR(v1, 1, 1e-8); EXPECT_NEAR(v2, 1, 1e-8); } diff --git a/tools/install/libdrake/BUILD.bazel b/tools/install/libdrake/BUILD.bazel index 4180a122fa3a..1fae73be6759 100644 --- a/tools/install/libdrake/BUILD.bazel +++ b/tools/install/libdrake/BUILD.bazel @@ -110,7 +110,7 @@ cc_library( }), ) -# Depend on a shared library used by dReal iff dReal is enabled. +# Depend on the shared libraries used by dReal iff dReal is enabled. cc_library( name = "dreal_deps", deps = select({ diff --git a/tools/workspace/dreal/ibex_2.8.6.patch b/tools/workspace/dreal/ibex_2.8.6.patch index 57613dfebf69..ab8a69d57b61 100644 --- a/tools/workspace/dreal/ibex_2.8.6.patch +++ b/tools/workspace/dreal/ibex_2.8.6.patch @@ -28,26 +28,3 @@ index da7215a..52c83ad 100644 std::unique_ptr ctc_; std::vector> expr_ctrs_; }; -diff --git dreal/util/test/box_test.cc dreal/util/test/box_test.cc -index 365de51..6ea6a12 100644 ---- dreal/util/test/box_test.cc -+++ dreal/util/test/box_test.cc -@@ -277,12 +277,12 @@ TEST_F(BoxTest, Equality) { - // Checks types in Box are nothrow move-constructible so that the - // vectors including them can be processed efficiently. - TEST_F(BoxTest, IsNothrowMoveConstructible) { -- static_assert(is_nothrow_move_constructible::value, -- "Box::Interval should be nothrow_move_constructible."); -- static_assert(is_nothrow_move_constructible::value, -- "Box::IntervalVector should be nothrow_move_constructible."); -- static_assert(is_nothrow_move_constructible::value, -- "Box should be nothrow_move_constructible."); -+ // static_assert(is_nothrow_move_constructible::value, -+ // "Box::Interval should be nothrow_move_constructible."); -+ // static_assert(is_nothrow_move_constructible::value, -+ // "Box::IntervalVector should be nothrow_move_constructible."); -+ // static_assert(is_nothrow_move_constructible::value, -+ // "Box should be nothrow_move_constructible."); - } - - } // namespace diff --git a/tools/workspace/ibex/package.BUILD.bazel b/tools/workspace/ibex/package.BUILD.bazel index e0ed741feb7d..653ab257fa45 100644 --- a/tools/workspace/ibex/package.BUILD.bazel +++ b/tools/workspace/ibex/package.BUILD.bazel @@ -23,7 +23,8 @@ cmake_configure_file( name = "rounding_control_config", src = "filibsrc-3.0.2.2/rounding_control/rounding_control_config.hpp.in", out = "filibsrc-3.0.2.2/rounding_control/rounding_control_config.hpp", - defines = ["define_have_sse=#define HAVE_SSE", "define_have_x87="], + # TODO(russt): Use "define_have_sse=#define HAVE_SSE" on linux. + defines = ["define_have_sse=", "define_have_x87="], ) # Note: We cannot glob the files since they are generated by the @@ -276,26 +277,48 @@ IBEX_CONFIG = [ ] ] -IBEX_HEADERS = glob([ +_IBEX_HEADERS = glob([ "src/**/*.h", "plugins/optim/src/**/*.h", ], exclude = [ "src/bin/*", ]) + [ - "src/ibex_Setting.h", - "src/symbolic/ibex_ExprOperators.h", + ":src/ibex_Setting.h", + ":src/symbolic/ibex_ExprOperators.h", "interval_lib_wrapper/filib/ibex_IntervalLibWrapper.h", "interval_lib_wrapper/filib/ibex_IntervalLibWrapper.inl", "lp_lib_wrapper/clp/ibex_LPLibWrapper.h", ] +_IBEX_INCLUDES = glob( + ["src/*", "plugins/optim/src/*"], + exclude = ["src/wscript", "src/*.*"], + exclude_directories = 0, +) + [ + "interval_lib_wrapper/filib", + "lp_lib_wrapper/clp", + "src", +] + drake_generate_include_header( name = "gen_ibex_h", out = "src/ibex.h", - hdrs = IBEX_HEADERS, + hdrs = _IBEX_HEADERS, strip_prefix = ["src/"], ) +cc_library( + name = "ibex_headers", + hdrs = _IBEX_HEADERS + _FILIB_HEADER_FILES + [ + ":src/ibex.h", + "src/parser/parser.tab.hh", + ], + includes = _IBEX_INCLUDES + [ + "filibsrc-3.0.2.2", + "", # For plugins + ], +) + # Note: We have committed the flex and yacc generated outputs to our fork of # ibex to avoid the unnecessary dependency here. If we need to revisit this # decision, the genrules needed are: @@ -308,8 +331,14 @@ drake_generate_include_header( # "@dreal//third_party/com_github_google_kythe/tools/build_rules:lexyacc.bzl" # is close to what we need to pull in flex and bison. -cc_library( - name = "ibex", +# We only build a shared-library flavor of libdrake_ibex.so, because it is +# LGPL-licensed and thus should never be linked statically. Building C++ +# shared libraries in Bazel is a bit arcane. This rule creates the runtime +# artifact -- a loadable shared library. The `name = "ibex"` rule below +# provides the compile-time artifact that combines the shared library with +# its headers. +cc_binary( + name = "libdrake_ibex.so", srcs = glob([ "src/**/*.cpp", "src/parser/*.cc", @@ -320,42 +349,49 @@ cc_library( # These files must be generated: "interval_lib_wrapper/filib/ibex_IntervalLibWrapper.cpp", "lp_lib_wrapper/clp/ibex_LPLibWrapper.cpp", - "src/symbolic/ibex_ExprOperators.cpp", - ], - hdrs = IBEX_HEADERS + [ - "src/ibex.h", - "src/parser/parser.tab.hh", - ], - includes = glob( - ["src/*", "plugins/optim/src/*"], - exclude = ["src/wscript", "src/*.*"], - exclude_directories = 0, - ) + [ - "src", - "interval_lib_wrapper/filib", - "lp_lib_wrapper/clp", - "", # For plugins + ":src/symbolic/ibex_ExprOperators.cpp", ], copts = ["-w -std=c++11"], # The linkopts= here are transcribed from the contents of the *.pc file. linkopts = [ "-lbz2", "-lm", - ], + ] + select({ + "@drake//tools/cc_toolchain:linux": [ + "-Wl,-soname,libdrake_ibex.so", + ], + "@//conditions:default": [], + }), # The deps= here are transcribed from the contents of the *.pc file. deps = [ ":filib", + ":ibex_headers", "@blas", "@clp", "@lapack", "@zlib", ], - visibility = ["//visibility:public"], linkstatic = True, + linkshared = True, +) + +# This is the compile-time target for libdrake_ibex. See above for details. +cc_library( + name = "ibex", + srcs = ["libdrake_ibex.so"], + deps = [":ibex_headers"], + visibility = ["//visibility:public"], ) install( name = "install", - docs = ["LICENSE"], + targets = [":libdrake_ibex.so"], + hdrs = _IBEX_HEADERS + [":src/ibex.h"], + hdr_dest = "include/ibex", + hdr_strip_prefix = _IBEX_INCLUDES, + docs = [ + "COPYING.LESSER", + "LICENSE", + ], visibility = ["//visibility:public"], )