# Don't use bzlmod yet.
common --enable_bzlmod=false

# Default to an optimized build.
build -c opt

# Default build options.
build --strip=never
build --strict_system_includes

# Use C++20 by default.
build --cxxopt=-std=c++20
build --host_cxxopt=-std=c++20

# The legacy __init__.py causes runfiles test flakes with Bazel >= 7, and
# in any case we don't want this feature in the first place. We should
# create all __init__.py files ourselves by hand anywhere we need them.
build --incompatible_default_to_explicit_init_py

# Default test options.
build --test_output=errors
build --test_summary=terse

# By default, disable execution of tests that require proprietary software.
# Individual targets that use proprietary software are responsible for ensuring
# they can also build without it, typically by using a select statement.
# config_setting rules for proprietary software are provided in //tools.
build --test_tag_filters=-gurobi,-mosek,-snopt

# Allow user environment variables relating to host graphics configuration to
# flow through to tests that use X.
build --test_env=DISPLAY
build --test_env=XAUTHORITY

# Location of the Gurobi license key file, typically named "gurobi.lic".
# Setting this --test_env for all configurations is deliberate to improve
# remote caching performance.
build --test_env=GRB_LICENSE_FILE

# Location of the MOSEK license file, typically named "mosek.lic". Setting
# this --test_env for all configurations is deliberate to improve remote
# caching performance.
build --test_env=MOSEKLM_LICENSE_FILE

# Prevent LCM messages from leaking outside of tests.
# See documentation: https://lcm-proj.github.io/group__LcmC__lcm__t.html#gaf29963ef43edadf45296d5ad82c18d4b  # noqa
# WARNING: If your LCM test depends on communication between separate LCM
# instances (and you cannot easily mock the LCM instances), make sure that each
# instance has a consistent, but non-default, LCM URL.
build --test_env=LCM_DEFAULT_URL=memq://

# Prevent matplotlib from showing windows (#11029).
build --test_env=MPLBACKEND=Template

### A configuration that enables all optional dependencies. ###
build:everything --test_tag_filters=-no_everything

### A configuration that enables Gurobi. ###
# -- To use this config, the GRB_LICENSE_FILE environment variable must be set
# -- to the location of the Gurobi license key file. On Ubuntu, the GUROBI_HOME
# -- environment variable must be set to the linux64 directory of the extracted
# -- archive downloaded from gurobi.com when the installation was not at the
# -- default location of /opt/gurobi1002/linux64.
#
# -- To run tests where Gurobi is used, ensure that you include
# -- "gurobi_test_tags()" from //tools/skylark:test_tags.bzl.
# -- If Gurobi is optional, set gurobi_required=False.
build:gurobi --define=WITH_GUROBI=ON
build:everything --define=WITH_GUROBI=ON
# N.B. The build:packaging configuration does NOT use Gurobi (yet).
# See https://github.com/RobotLocomotion/drake/issues/10804.
build:packaging --test_tag_filters=-gurobi

### A configuration that enables MOSEK™. ###
# -- To use this config, the MOSEKLM_LICENSE_FILE environment variable must be
# -- set to the location of the MOSEK license file.
#
# -- To run tests where MOSEK™ is used, ensure that you include
# -- "mosek_test_tags()" from //tools/skylark:test_tags.bzl.
# -- If MOSEK™ is optional, set mosek_required=False.
build:mosek --define=WITH_MOSEK=ON
build:packaging --define=WITH_MOSEK=ON
build:everything --define=WITH_MOSEK=ON

### A configuration that enables SNOPT. ###
# -- To use this config, you must have access to the private repository
# -- RobotLocomotion/snopt on GitHub, and your local git must be configured
# -- with SSH keys as documented at https://drake.mit.edu/from_source.html.
#
# -- To run tests that require SNOPT, also specify a set of test_tag_filters
# -- that does not exclude the "snopt" tag.
build:snopt --define=WITH_SNOPT=ON
build:packaging --define=WITH_SNOPT=ON
build:everything --define=WITH_SNOPT=ON
