Skip to content

Commit

Permalink
[build] Use modern spelling for Bazel config options (#22393)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri authored Jan 7, 2025
1 parent 5b0f643 commit 8df4db9
Show file tree
Hide file tree
Showing 22 changed files with 388 additions and 241 deletions.
28 changes: 14 additions & 14 deletions bindings/pydrake/solvers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ drake_py_unittest(
drake_py_unittest(
name = "clarabel_solver_test",
args = select({
"//tools:no_clarabel": ["TestClarabelSolver.unavailable"],
"//conditions:default": [],
"//tools/workspace/clarabel_cpp_internal:enabled": [],
"//conditions:default": ["TestClarabelSolver.unavailable"],
}),
deps = [
":solvers",
Expand All @@ -115,8 +115,8 @@ drake_py_unittest(
drake_py_unittest(
name = "clp_solver_test",
args = select({
"//tools:no_clp": ["TestClpSolver.unavailable"],
"//conditions:default": [],
"//tools/workspace/clp_internal:enabled": [],
"//conditions:default": ["TestClpSolver.unavailable"],
}),
deps = [
":solvers",
Expand All @@ -127,8 +127,8 @@ drake_py_unittest(
drake_py_unittest(
name = "csdp_solver_test",
args = select({
"//tools:no_csdp": ["TestCsdptSolver.unavailable"],
"//conditions:default": [],
"//tools/workspace/csdp_internal:enabled": [],
"//conditions:default": ["TestCsdptSolver.unavailable"],
}),
deps = [
":solvers",
Expand All @@ -148,8 +148,8 @@ drake_py_unittest(
drake_py_unittest(
name = "ipopt_solver_test",
args = select({
"//tools:no_ipopt": ["TestIpoptSolver.unavailable"],
"//conditions:default": [],
"//tools/workspace/ipopt_internal:enabled": [],
"//conditions:default": ["TestIpoptSolver.unavailable"],
}),
deps = [
":solvers",
Expand Down Expand Up @@ -184,8 +184,8 @@ drake_py_unittest(
drake_py_unittest(
name = "nlopt_solver_test",
args = select({
"//tools:no_nlopt": ["TestNloptSolver.unavailable"],
"//conditions:default": [],
"//tools/workspace/nlopt_internal:enabled": [],
"//conditions:default": ["TestNloptSolver.unavailable"],
}),
deps = [
":solvers",
Expand All @@ -196,8 +196,8 @@ drake_py_unittest(
drake_py_unittest(
name = "osqp_solver_test",
args = select({
"//tools:no_osqp": ["TestOsqpSolver.unavailable"],
"//conditions:default": [],
"//tools/workspace/osqp_internal:enabled": [],
"//conditions:default": ["TestOsqpSolver.unavailable"],
}),
deps = [
":solvers",
Expand All @@ -207,8 +207,8 @@ drake_py_unittest(
drake_py_unittest(
name = "scs_solver_test",
args = select({
"//tools:no_scs": ["TestScsSolver.unavailable"],
"//conditions:default": [],
"//tools/workspace/scs_internal:enabled": [],
"//conditions:default": ["TestScsSolver.unavailable"],
}),
deps = [
":solvers",
Expand Down
3 changes: 3 additions & 0 deletions doc/_pages/stable.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ part of the "Stable API":
<a href="https://docs.bazel.build/versions/main/build-ref.html#load">loading</a>
Drake's bzl macros (e.g., `load("@drake//foo:bar.bzl", "bar_macro")`.

Additionally, Drake's Bazel configuration flags at `@drake//tools/flags:*` are
part of the Stable API.

For Drake's dependencies:

* The `add_default_...` macros defined in `@drake//tools/workspace:default.bzl`
Expand Down
81 changes: 49 additions & 32 deletions solvers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ drake_cc_library(
# code that fails at runtime.
drake_cc_variant_library(
name = "gurobi_solver",
opt_in_condition = "//tools:with_gurobi",
opt_in_condition = "//tools/workspace/gurobi:enabled",
srcs_always = ["gurobi_solver_common.cc"],
srcs_enabled = ["gurobi_solver.cc"],
srcs_disabled = ["no_gurobi.cc"],
Expand All @@ -844,7 +844,7 @@ drake_cc_variant_library(

drake_cc_optional_library(
name = "gurobi_solver_internal",
opt_in_condition = "//tools:with_gurobi",
opt_in_condition = "//tools/workspace/gurobi:enabled",
srcs = ["gurobi_solver_internal.cc"],
hdrs = ["gurobi_solver_internal.h"],
deps = [":mathematical_program_result"],
Expand All @@ -861,7 +861,7 @@ drake_cc_optional_library(
# code that fails at runtime.
drake_cc_variant_library(
name = "mosek_solver",
opt_in_condition = "//tools:with_mosek",
opt_in_condition = "//tools/workspace/mosek:enabled",
srcs_always = ["mosek_solver_common.cc"],
srcs_enabled = ["mosek_solver.cc"],
srcs_disabled = ["no_mosek.cc"],
Expand All @@ -884,7 +884,7 @@ drake_cc_variant_library(

drake_cc_optional_library(
name = "mosek_solver_internal",
opt_in_condition = "//tools:with_mosek",
opt_in_condition = "//tools/workspace/mosek:enabled",
srcs = ["mosek_solver_internal.cc"],
hdrs = ["mosek_solver_internal.h"],
deps = [":mathematical_program_result"],
Expand All @@ -903,7 +903,7 @@ drake_cc_optional_library(
# code that fails at runtime.
drake_cc_variant_library(
name = "snopt_solver",
opt_in_condition = "//tools:with_snopt",
opt_in_condition = "//tools/workspace/snopt:enabled",
srcs_always = ["snopt_solver_common.cc"],
srcs_enabled = ["snopt_solver.cc"],
srcs_disabled = ["no_snopt.cc"],
Expand All @@ -923,7 +923,7 @@ drake_cc_variant_library(

drake_cc_variant_library(
name = "clp_solver",
opt_out_condition = "//tools:no_clp",
opt_in_condition = "//tools/workspace/clp_internal:enabled",
srcs_always = ["clp_solver_common.cc"],
srcs_enabled = ["clp_solver.cc"],
srcs_disabled = ["no_clp.cc"],
Expand All @@ -944,7 +944,7 @@ drake_cc_variant_library(

drake_cc_optional_library(
name = "ipopt_solver_internal",
opt_out_condition = "//tools:no_ipopt",
opt_in_condition = "//tools/workspace/ipopt_internal:enabled",
srcs = ["ipopt_solver_internal.cc"],
hdrs = ["ipopt_solver_internal.h"],
deps = [
Expand All @@ -957,7 +957,7 @@ drake_cc_optional_library(

drake_cc_variant_library(
name = "ipopt_solver",
opt_out_condition = "//tools:no_ipopt",
opt_in_condition = "//tools/workspace/ipopt_internal:enabled",
srcs_always = ["ipopt_solver_common.cc"],
srcs_enabled = [
"ipopt_solver.cc",
Expand All @@ -982,7 +982,7 @@ drake_cc_variant_library(

drake_cc_variant_library(
name = "nlopt_solver",
opt_out_condition = "//tools:no_nlopt",
opt_in_condition = "//tools/workspace/nlopt_internal:enabled",
srcs_always = ["nlopt_solver_common.cc"],
srcs_enabled = ["nlopt_solver.cc"],
srcs_disabled = ["no_nlopt.cc"],
Expand All @@ -1001,7 +1001,7 @@ drake_cc_variant_library(

drake_cc_variant_library(
name = "osqp_solver",
opt_out_condition = "//tools:no_osqp",
opt_in_condition = "//tools/workspace/osqp_internal:enabled",
srcs_always = ["osqp_solver_common.cc"],
srcs_enabled = ["osqp_solver.cc"],
srcs_disabled = ["no_osqp.cc"],
Expand All @@ -1021,7 +1021,7 @@ drake_cc_variant_library(

drake_cc_variant_library(
name = "clarabel_solver",
opt_out_condition = "//tools:no_clarabel",
opt_in_condition = "//tools/workspace/clarabel_cpp_internal:enabled",
srcs_always = ["clarabel_solver_common.cc"],
srcs_enabled = ["clarabel_solver.cc"],
srcs_disabled = ["no_clarabel.cc"],
Expand Down Expand Up @@ -1056,7 +1056,7 @@ drake_cc_library(

drake_cc_variant_library(
name = "scs_solver",
opt_out_condition = "//tools:no_scs",
opt_in_condition = "//tools/workspace/scs_internal:enabled",
srcs_always = ["scs_solver_common.cc"],
srcs_enabled = ["scs_solver.cc"],
srcs_disabled = ["no_scs.cc"],
Expand Down Expand Up @@ -1113,7 +1113,7 @@ drake_cc_library(

drake_cc_optional_library(
name = "csdp_solver_error_handling",
opt_out_condition = "//tools:no_csdp",
opt_in_condition = "//tools/workspace/csdp_internal:enabled",
srcs = ["csdp_solver_error_handling.cc"],
hdrs = ["csdp_solver_error_handling.h"],
copts = ["-fvisibility=hidden"],
Expand All @@ -1125,7 +1125,7 @@ drake_cc_optional_library(

drake_cc_optional_library(
name = "csdp_cpp_wrapper",
opt_out_condition = "//tools:no_csdp",
opt_in_condition = "//tools/workspace/csdp_internal:enabled",
srcs = ["csdp_cpp_wrapper.cc"],
hdrs = ["csdp_cpp_wrapper.h"],
deps = [
Expand All @@ -1138,7 +1138,7 @@ drake_cc_optional_library(

drake_cc_optional_library(
name = "csdp_solver_internal",
opt_out_condition = "//tools:no_csdp",
opt_in_condition = "//tools/workspace/csdp_internal:enabled",
srcs = ["csdp_solver_internal.cc"],
hdrs = ["csdp_solver_internal.h"],
deps = [
Expand All @@ -1149,7 +1149,7 @@ drake_cc_optional_library(

drake_cc_variant_library(
name = "csdp_solver",
opt_out_condition = "//tools:no_csdp",
opt_in_condition = "//tools/workspace/csdp_internal:enabled",
srcs_always = ["csdp_solver_common.cc"],
srcs_enabled = ["csdp_solver.cc"],
srcs_disabled = ["no_csdp.cc"],
Expand Down Expand Up @@ -1330,7 +1330,7 @@ drake_cc_googletest(

drake_cc_optional_googletest(
name = "csdp_solver_internal_test",
opt_out_condition = "//tools:no_csdp",
opt_in_condition = "//tools/workspace/csdp_internal:enabled",
deps = [
":csdp_solver_internal",
":csdp_test_examples",
Expand All @@ -1340,7 +1340,7 @@ drake_cc_optional_googletest(

drake_cc_optional_googletest(
name = "csdp_cpp_wrapper_test",
opt_out_condition = "//tools:no_csdp",
opt_in_condition = "//tools/workspace/csdp_internal:enabled",
tags = [
# The longjmp handling definitely leaks memory, and we've decided to
# just live with that. If we see the longjmp handler triggering when
Expand Down Expand Up @@ -1378,6 +1378,27 @@ drake_cc_googletest(
],
)

drake_cc_googletest(
name = "disabled_solvers_test",
deps = [
# The ":foo_disabled" targets are magic secondary outputs of the
# drake_cc_variant_library(...) stanzas above, e.g., the
# `drake_cc_variant_library(name = "clarabel_solver", ...)`
# creates both ":clarabel_solver" and ":clarabel_solver_disabled".
":clarabel_solver_disabled",
":clp_solver_disabled",
":csdp_solver_disabled",
":gurobi_solver_disabled",
":ipopt_solver_disabled",
":mosek_solver_disabled",
":nlopt_solver_disabled",
":osqp_solver_disabled",
":scs_solver_disabled",
":snopt_solver_disabled",
"//common/test_utilities:expect_throws_message",
],
)

drake_cc_googletest(
name = "equality_constrained_qp_solver_test",
deps = [
Expand All @@ -1400,7 +1421,7 @@ drake_cc_googletest(

drake_cc_optional_googletest(
name = "gurobi_solver_internal_test",
opt_in_condition = "//tools:with_gurobi",
opt_in_condition = "//tools/workspace/gurobi:enabled",
use_default_main = False,
deps = [
":gurobi_solver",
Expand Down Expand Up @@ -1476,33 +1497,30 @@ drake_cc_googletest(
drake_cc_googletest(
name = "ipopt_solver_internal_test",
copts = select({
"//conditions:default": [
"//tools/workspace/ipopt_internal:enabled": [
"-DDRAKE_IPOPT_SOLVER_INTERNAL_TEST_HAS_IPOPT=1",
],
"//tools:no_ipopt": [
],
"//conditions:default": [],
}),
deps = [
":mathematical_program",
"//common/test_utilities:eigen_matrix_compare",
] + select({
"//conditions:default": [
"//tools/workspace/ipopt_internal:enabled": [
":ipopt_solver_internal",
"@ipopt_internal//:ipopt",
],
"//tools:no_ipopt": [
],
"//conditions:default": [],
}),
)

drake_cc_googletest(
name = "ipopt_solver_test",
copts = select({
"//conditions:default": [
"//tools/workspace/ipopt_internal:enabled": [
"-DDRAKE_IPOPT_SOLVER_TEST_HAS_IPOPT=1",
],
"//tools:no_ipopt": [
],
"//conditions:default": [],
}),
deps = [
":linear_program_examples",
Expand All @@ -1515,11 +1533,10 @@ drake_cc_googletest(
"//common/test_utilities:eigen_matrix_compare",
"//common/test_utilities:expect_throws_message",
] + select({
"//conditions:default": [
"//tools/workspace/ipopt_internal:enabled": [
"@ipopt_internal//:ipopt",
],
"//tools:no_ipopt": [
],
"//conditions:default": [],
}),
)

Expand Down Expand Up @@ -1618,7 +1635,7 @@ drake_cc_googletest(

drake_cc_optional_googletest(
name = "mosek_solver_internal_test",
opt_in_condition = "//tools:with_mosek",
opt_in_condition = "//tools/workspace/mosek:enabled",
use_default_main = False,
deps = [
":mosek_solver",
Expand Down
Loading

0 comments on commit 8df4db9

Please sign in to comment.