load("//tools/install:install.bzl", "install")
load("//tools/lint:lint.bzl", "add_lint_tests")
load(
    "//tools/skylark:drake_cc.bzl",
    "drake_cc_binary",
    "drake_cc_googletest",
    "drake_cc_library",
    "drake_cc_package_library",
    "drake_cc_test",
)
load(
    "//tools/skylark:drake_py.bzl",
    "drake_py_binary",
    "drake_py_unittest",
)

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

drake_cc_package_library(
    name = "common",
    visibility = ["//visibility:public"],
    deps = [
        ":autodiff",
        ":bit_cast",
        ":cond",
        ":copyable_unique_ptr",
        ":default_scalars",
        ":diagnostic_policy",
        ":double",
        ":drake_bool",
        ":drake_export",
        ":drake_path",
        ":dummy_value",
        ":essential",
        ":extract_double",
        ":find_resource",
        ":find_runfiles",
        ":fmt",
        ":hash",
        ":identifier",
        ":is_approx_equal_abstol",
        ":is_cloneable",
        ":is_less_than_comparable",
        ":name_value",
        ":network_policy",
        ":nice_type_name",
        ":overloaded",
        ":parallelism",
        ":pointer_cast",
        ":polynomial",
        ":random",
        ":reset_after_move",
        ":reset_on_copy",
        ":scope_exit",
        ":scoped_singleton",
        ":sha256",
        ":sorted_pair",
        ":string_container",
        ":temp_directory",
        ":timer",
        ":type_safe_index",
        ":unused",
        ":value",
    ],
)

drake_cc_library(
    name = "fmt",
    srcs = [
        "fmt_eigen.cc",
    ],
    hdrs = [
        "fmt.h",
        "fmt_eigen.h",
        "fmt_ostream.h",
    ],
    visibility = ["//common/test_utilities:__pkg__"],
    deps = [
        "@eigen",
        "@fmt",
    ],
)

# A library of things that EVERYONE should want and MUST EAT.
# Be appropriately hesitant when adding new things here.
drake_cc_library(
    name = "essential",
    srcs = [
        "drake_assert_and_throw.cc",
        "drake_deprecated.cc",
        "text_logging.cc",
    ],
    hdrs = [
        "constants.h",
        "drake_assert.h",
        "drake_assertion_error.h",
        "drake_copyable.h",
        "drake_deprecated.h",
        "drake_throw.h",
        "eigen_types.h",
        "never_destroyed.h",
        "ssize.h",
        "text_logging.h",
    ],
    deps = [
        ":fmt",
        "@eigen",
        "@fmt",
        "@spdlog",
    ],
)

drake_cc_library(
    name = "bit_cast",
    hdrs = ["bit_cast.h"],
)

# Specific traits and operators that are relevant to all ScalarTypes.
drake_cc_library(
    name = "cond",
    srcs = ["cond.cc"],
    hdrs = ["cond.h"],
    deps = [
        ":double",
    ],
)

drake_cc_library(
    name = "drake_bool",
    hdrs = [
        "drake_bool.h",
    ],
    deps = [
        ":autodiff",
        ":cond",
        ":double",
        ":essential",
    ],
)

drake_cc_library(
    name = "dummy_value",
    hdrs = ["dummy_value.h"],
)

# Drake's specific ScalarType-providing libraries.
drake_cc_library(
    name = "double",
    srcs = ["double_overloads.cc"],
    hdrs = ["double_overloads.h"],
)

drake_cc_library(
    name = "autodiff",
    hdrs = [
        "autodiff.h",
        "autodiff_overloads.h",
        "autodiffxd.h",
        "eigen_autodiff_types.h",
    ],
    deps = [
        ":cond",
        ":dummy_value",
        ":essential",
    ],
)

drake_cc_library(
    name = "diagnostic_policy",
    srcs = ["diagnostic_policy.cc"],
    hdrs = ["diagnostic_policy.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "extract_double",
    hdrs = ["extract_double.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "hash",
    srcs = ["hash.cc"],
    hdrs = ["hash.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "polynomial",
    srcs = ["polynomial.cc"],
    hdrs = ["polynomial.h"],
    deps = [
        ":autodiff",
        ":default_scalars",
        ":essential",
        "//common/symbolic:expression",
    ],
)

drake_cc_library(
    name = "default_scalars",
    hdrs = ["default_scalars.h"],
    deps = [
        ":autodiff",
        ":essential",
        "//common/symbolic:expression",
    ],
)

# Miscellaneous utilities.

drake_cc_library(
    name = "drake_export",
    hdrs = ["drake_export.h"],
)

drake_cc_library(
    name = "identifier",
    srcs = ["identifier.cc"],
    hdrs = ["identifier.h"],
    deps = [
        ":essential",
        ":hash",
    ],
)

DRAKE_RESOURCE_SENTINEL = "//:.drake-find_resource-sentinel"

drake_cc_library(
    name = "is_less_than_comparable",
    hdrs = [
        "is_less_than_comparable.h",
    ],
    deps = [
        ":unused",
    ],
)

drake_cc_library(
    name = "sorted_pair",
    srcs = [
        "sorted_pair.cc",
    ],
    hdrs = [
        "sorted_pair.h",
    ],
    deps = [
        ":hash",
        ":is_less_than_comparable",
    ],
)

# Provides an anchor for finding resources.
drake_cc_binary(
    name = "libdrake_marker.so",
    srcs = [
        "drake_marker.cc",
        "drake_marker.h",
    ],
    linkopts = select({
        "//tools/cc_toolchain:linux": ["-Wl,-soname,libdrake_marker.so"],
        "//conditions:default": [],
    }),
    linkshared = 1,
    linkstatic = 1,
    visibility = ["//visibility:private"],
)

drake_cc_library(
    name = "drake_marker_shared_library",
    srcs = ["libdrake_marker.so"],
    hdrs = ["drake_marker.h"],
    install_hdrs_exclude = ["drake_marker.h"],
    tags = ["exclude_from_package"],
    visibility = ["//tools/install/libdrake:__pkg__"],
)

drake_cc_library(
    name = "find_cache",
    srcs = ["find_cache.cc"],
    hdrs = ["find_cache.h"],
    internal = True,
    visibility = ["//:__subpackages__"],
    interface_deps = [],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "find_runfiles",
    srcs = ["find_runfiles.cc"],
    hdrs = ["find_runfiles.h"],
    interface_deps = [],
    deps = [
        ":essential",
        "@bazel_tools//tools/cpp/runfiles",
    ],
)

drake_cc_library(
    name = "find_resource",
    srcs = [
        "find_loaded_library.cc",
        "find_resource.cc",
    ],
    hdrs = [
        "find_loaded_library.h",
        "find_resource.h",
    ],
    data = [
        DRAKE_RESOURCE_SENTINEL,
    ],
    # for libdrake.so path on linux
    linkopts = select({
        "//tools/cc_toolchain:linux": ["-ldl"],
        "//conditions:default": [],
    }),
    interface_deps = [
        ":essential",
    ],
    deps = [
        ":drake_marker_shared_library",
        ":find_runfiles",
    ],
)

drake_cc_library(
    name = "drake_path",
    srcs = ["drake_path.cc"],
    hdrs = ["drake_path.h"],
    data = [
        DRAKE_RESOURCE_SENTINEL,
    ],
    visibility = ["//tools/install/libdrake:__pkg__"],
    interface_deps = [],
    deps = [
        ":find_resource",
    ],
)

drake_cc_library(
    name = "is_approx_equal_abstol",
    hdrs = ["is_approx_equal_abstol.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "name_value",
    hdrs = ["name_value.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "network_policy",
    srcs = ["network_policy.cc"],
    hdrs = ["network_policy.h"],
    deps = [
        ":essential",
    ],
)

# N.B. This library does not have all of its dependencies declared. Instead,
# it defines only the headers such that it can be used by `pydrake` without
# installing the file. (If we just used `install_hdrs_exclude`, the header
# would not make it into `//:drake_shared_library`.)
drake_cc_library(
    name = "nice_type_name_override_header",
    hdrs = ["nice_type_name_override.h"],
    install_hdrs_exclude = ["nice_type_name_override.h"],
    tags = ["exclude_from_package"],
    visibility = ["//bindings/pydrake/common:__pkg__"],
)

drake_cc_library(
    name = "nice_type_name",
    srcs = [
        "nice_type_name.cc",
        "nice_type_name_override.cc",
    ],
    hdrs = [
        "nice_type_name.h",
    ],
    interface_deps = [
        ":essential",
    ],
    deps = [
        ":nice_type_name_override_header",
    ],
)

drake_cc_library(
    name = "overloaded",
    hdrs = ["overloaded.h"],
)

drake_cc_library(
    name = "parallelism",
    srcs = ["parallelism.cc"],
    hdrs = ["parallelism.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "is_cloneable",
    hdrs = ["is_cloneable.h"],
)

drake_cc_library(
    name = "copyable_unique_ptr",
    hdrs = ["copyable_unique_ptr.h"],
    deps = [":is_cloneable"],
)

drake_cc_library(
    name = "random",
    srcs = ["random.cc"],
    hdrs = ["random.h"],
    interface_deps = [
        ":copyable_unique_ptr",
        ":essential",
        ":extract_double",
    ],
    deps = [
        ":autodiff",
    ],
)

drake_cc_library(
    name = "reset_after_move",
    hdrs = ["reset_after_move.h"],
)

drake_cc_library(
    name = "reset_on_copy",
    hdrs = ["reset_on_copy.h"],
)

drake_cc_library(
    name = "sha256",
    srcs = ["sha256.cc"],
    hdrs = ["sha256.h"],
    interface_deps = [
        ":essential",
    ],
    deps = [
        "@picosha2_internal//:picosha2",
    ],
)

drake_cc_library(
    name = "pointer_cast",
    srcs = ["pointer_cast.cc"],
    hdrs = ["pointer_cast.h"],
    deps = [
        ":nice_type_name",
    ],
)

drake_cc_library(
    name = "temp_directory",
    srcs = ["temp_directory.cc"],
    hdrs = ["temp_directory.h"],
    interface_deps = [
        ":essential",
    ],
    deps = [],
)

# This is a Drake-internal utility for use only as a direct dependency
# of executable (drake_cc_binary) targets.  Thus, we exclude it from
# the ":common" package library and from libdrake.
drake_cc_library(
    name = "add_text_logging_gflags",
    srcs = ["add_text_logging_gflags.cc"],
    tags = [
        "exclude_from_libdrake",
        "exclude_from_package",
    ],
    visibility = ["//:__subpackages__"],
    deps = [
        ":essential",
        ":unused",
        "@gflags",
    ],
    alwayslink = 1,
)

drake_cc_library(
    name = "type_safe_index",
    srcs = ["type_safe_index.cc"],
    hdrs = ["type_safe_index.h"],
    deps = [
        ":essential",
        ":hash",
        ":nice_type_name",
    ],
)

drake_cc_library(
    name = "unused",
    hdrs = ["unused.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "scope_exit",
    hdrs = ["scope_exit.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "scoped_singleton",
    hdrs = ["scoped_singleton.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "string_container",
    hdrs = [
        "string_hash.h",
        "string_map.h",
        "string_set.h",
        "string_unordered_map.h",
        "string_unordered_set.h",
    ],
)

drake_cc_library(
    name = "timer",
    srcs = ["timer.cc"],
    hdrs = ["timer.h"],
    deps = [
        ":essential",
    ],
)

drake_cc_library(
    name = "value",
    srcs = ["value.cc"],
    hdrs = ["value.h"],
    deps = [
        ":copyable_unique_ptr",
        ":essential",
        ":hash",
        ":is_cloneable",
        ":nice_type_name",
    ],
)

drake_cc_binary(
    name = "resource_tool",
    srcs = ["resource_tool.cc"],
    deps = [
        ":add_text_logging_gflags",
        ":essential",
        ":find_resource",
    ],
)

install(
    name = "install_drake_marker",
    targets = [":libdrake_marker.so"],
)

install(
    name = "install",
    install_tests = [":test/resource_tool_installed_test.py"],
    targets = [
        ":libdrake_marker.so",
        ":resource_tool",
    ],
    runtime_dest = "share/drake/common",
    data_dest = "share/drake",
    guess_data = "WORKSPACE",
    allowed_externals = [DRAKE_RESOURCE_SENTINEL],
    deps = [
        ":install_drake_marker",
    ],
)

# === test/ ===

drake_cc_googletest(
    name = "autodiffxd_test",
    # The following `autodiffxd_*_test.cc` files were in a single
    # `autodiffxd_test.cc`. We found that it takes more than 150 sec to build
    # this test. So we split it into multiple .cc files. We observed about
    # 8x speed-up.
    srcs = [
        "test/autodiffxd_abs2_test.cc",
        "test/autodiffxd_abs_test.cc",
        "test/autodiffxd_acos_test.cc",
        "test/autodiffxd_addition_test.cc",
        "test/autodiffxd_asin_test.cc",
        "test/autodiffxd_atan2_test.cc",
        "test/autodiffxd_atan_test.cc",
        "test/autodiffxd_cos_test.cc",
        "test/autodiffxd_cosh_test.cc",
        "test/autodiffxd_division_test.cc",
        "test/autodiffxd_exp_test.cc",
        "test/autodiffxd_log_test.cc",
        "test/autodiffxd_max_test.cc",
        "test/autodiffxd_min_test.cc",
        "test/autodiffxd_multiplication_test.cc",
        "test/autodiffxd_pow_test.cc",
        "test/autodiffxd_sin_test.cc",
        "test/autodiffxd_sinh_test.cc",
        "test/autodiffxd_sqrt_test.cc",
        "test/autodiffxd_subtraction_test.cc",
        "test/autodiffxd_tan_test.cc",
        "test/autodiffxd_tanh_test.cc",
    ],
    copts = [
        # The test fixture at //common/ad:standard_operations_test_h requires
        # some configuration for the specific autodiff class to be tested.
        "-DDRAKE_AUTODIFFXD_DUT=drake::AutoDiffXd",
        "-DStandardOperationsTest=AutoDiffXdTest",
    ],
    deps = [
        ":autodiff",
        "//common/ad:standard_operations_test_h",
        "//common/test_utilities:eigen_matrix_compare",
    ],
)

drake_cc_googletest(
    name = "autodiffxd_heap_test",
    deps = [
        ":autodiff",
        "//common/test_utilities:limit_malloc",
    ],
)

drake_cc_googletest(
    name = "autodiff_overloads_test",
    deps = [
        ":autodiff",
        ":essential",
        ":extract_double",
        "//common/test_utilities:eigen_matrix_compare",
    ],
)

drake_cc_googletest(
    name = "bit_cast_test",
    deps = [
        ":bit_cast",
    ],
)

drake_cc_googletest(
    name = "ssize_test",
    deps = [
        ":essential",
    ],
)

drake_cc_googletest(
    name = "drake_bool_test",
    deps = [
        ":drake_bool",
        "//common/symbolic:expression",
        "//common/test_utilities:symbolic_test_util",
    ],
)

drake_cc_googletest(
    name = "random_test",
    deps = [
        ":autodiff",
        ":random",
        "//common/test_utilities:limit_malloc",
    ],
)

drake_cc_googletest(
    name = "reset_after_move_test",
    deps = [
        ":reset_after_move",
    ],
)

drake_cc_googletest(
    name = "reset_on_copy_test",
    deps = [
        ":reset_on_copy",
    ],
)

drake_cc_googletest(
    name = "sha256_test",
    deps = [
        ":sha256",
        ":temp_directory",
    ],
)

drake_cc_googletest(
    name = "pointer_cast_test",
    deps = [
        ":pointer_cast",
        "//common/test_utilities",
    ],
)

drake_cc_googletest(
    name = "cond_test",
    deps = [
        ":cond",
    ],
)

drake_cc_googletest(
    name = "double_overloads_test",
    deps = [
        ":cond",
        ":double",
        ":essential",
    ],
)

# Functional test of DRAKE_ASSERT at runtime.
drake_cc_googletest(
    name = "drake_assert_test",
    deps = [
        ":essential",
    ],
)

# Same, but with assertions forced enabled.
drake_cc_googletest(
    name = "drake_assert_test_enabled",
    srcs = ["test/drake_assert_test.cc"],
    copts = [
        "-DDRAKE_ENABLE_ASSERTS",
        "-UDRAKE_DISABLE_ASSERTS",
    ],
    deps = [
        ":essential",
    ],
)

# Same, but with assertions forced disabled.
drake_cc_googletest(
    name = "drake_assert_test_disabled",
    srcs = ["test/drake_assert_test.cc"],
    copts = [
        "-UDRAKE_ENABLE_ASSERTS",
        "-DDRAKE_DISABLE_ASSERTS",
    ],
    deps = [
        ":essential",
    ],
)

drake_cc_googletest(
    name = "drake_copyable_test",
    deps = [
        ":essential",
    ],
)

drake_cc_googletest(
    name = "is_cloneable_test",
    deps = [
        ":is_cloneable",
    ],
)

drake_cc_googletest(
    name = "copyable_unique_ptr_test",
    deps = [
        ":copyable_unique_ptr",
        "//common:unused",
        "//common/test_utilities:is_dynamic_castable",
    ],
)

drake_cc_googletest(
    name = "diagnostic_policy_test",
    deps = [
        ":diagnostic_policy",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "drake_deprecated_test",
    # Remove spurious warnings from the default build output.
    copts = ["-Wno-deprecated-declarations"],
    deps = [
        ":essential",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "drake_throw_test",
    deps = [
        ":essential",
        "//common/test_utilities:expect_no_throw",
    ],
)

drake_cc_googletest(
    name = "dummy_value_test",
    deps = [
        ":dummy_value",
    ],
)

drake_cc_googletest(
    name = "eigen_types_test",
    deps = [
        ":essential",
        ":nice_type_name",
        "//common/test_utilities:expect_no_throw",
    ],
)

drake_cc_googletest(
    name = "hash_test",
    deps = [
        ":hash",
    ],
)

drake_cc_googletest(
    name = "identifier_test",
    deps = [
        ":identifier",
        ":sorted_pair",
        "//common/test_utilities:expect_no_throw",
        "//common/test_utilities:expect_throws_message",
        "@abseil_cpp_internal//absl/container:flat_hash_set",
    ],
)

drake_cc_googletest(
    name = "is_less_than_comparable_test",
    deps = [
        ":is_less_than_comparable",
    ],
)

drake_cc_googletest(
    name = "sorted_pair_test",
    deps = [
        ":sorted_pair",
    ],
)

drake_cc_googletest(
    name = "extract_double_test",
    deps = [
        ":essential",
        ":extract_double",
        "//common/test_utilities:eigen_matrix_compare",
    ],
)

drake_cc_googletest(
    name = "find_cache_test",
    deps = [
        ":find_cache",
        ":temp_directory",
    ],
)

drake_cc_googletest(
    name = "find_resource_test",
    data = [
        "test/find_resource_test_data.txt",
    ],
    deps = [
        ":drake_path",
        ":find_resource",
        "//common/test_utilities:expect_no_throw",
        "//common/test_utilities:expect_throws_message",
    ],
)

# Test library for `find_loaded_library_test`.
drake_cc_binary(
    name = "lib_is_real.so",
    testonly = 1,
    srcs = [
        "test/lib_is_real.cc",
    ],
    linkshared = 1,
    visibility = ["//visibility:private"],
)

drake_cc_googletest(
    name = "find_loaded_library_test",
    srcs = [
        "test/find_loaded_library_test.cc",
        ":lib_is_real.so",
    ],
    deps = [
        ":find_resource",
    ],
)

drake_cc_googletest(
    name = "find_runfiles_test",
    data = [
        "test/find_resource_test_data.txt",
    ],
    deps = [
        ":find_runfiles",
        ":temp_directory",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "find_runfiles_fail_test",
    deps = [
        ":find_runfiles",
    ],
)

drake_py_unittest(
    name = "find_runfiles_subprocess_test",
    data = [
        ":find_runfiles_test",
    ],
)

drake_cc_googletest(
    name = "find_runfiles_stub_test",
    srcs = [
        "find_runfiles.h",
        "find_runfiles_stub.cc",
        "test/find_runfiles_stub_test.cc",
    ],
)

drake_cc_googletest(
    name = "fmt_test",
    deps = [
        ":essential",
    ],
)

drake_cc_googletest(
    name = "fmt_eigen_test",
    deps = [
        ":essential",
    ],
)

drake_cc_googletest(
    name = "fmt_ostream_test",
    deps = [
        ":essential",
    ],
)

drake_cc_googletest(
    name = "is_approx_equal_abstol_test",
    deps = [
        ":essential",
        ":is_approx_equal_abstol",
    ],
)

drake_cc_googletest(
    name = "name_value_test",
    deps = [
        ":name_value",
    ],
)

drake_cc_googletest(
    name = "network_policy_test",
    deps = [
        ":network_policy",
    ],
)

drake_cc_googletest(
    name = "never_destroyed_test",
    deps = [
        ":essential",
    ],
)

drake_cc_googletest(
    name = "nice_type_name_test",
    deps = [
        ":autodiff",
        ":essential",
        ":identifier",
        ":nice_type_name",
        ":nice_type_name_override_header",
    ],
)

drake_cc_googletest(
    name = "openmp_test",
    num_threads = 2,
    deps = [
        "//common:essential",
    ],
)

drake_cc_googletest(
    name = "overloaded_test",
    deps = [
        "//common:overloaded",
    ],
)

drake_cc_googletest(
    name = "parallelism_test",
    num_threads = 2,
    deps = [
        ":parallelism",
    ],
)

drake_cc_googletest(
    name = "polynomial_test",
    deps = [
        ":essential",
        "//common/test_utilities:eigen_matrix_compare",
        "//common/test_utilities:expect_no_throw",
        "//common/test_utilities:random_polynomial_matrix",
    ],
)

drake_cc_googletest(
    name = "string_container_test",
    deps = [
        ":string_container",
        "//common/test_utilities:limit_malloc",
    ],
)

drake_cc_googletest(
    name = "temp_directory_test",
    # Run each test case in a different process, to avoid environment variable
    # changes from one accidentally polluting the others.
    shard_count = 3,
    deps = [
        ":temp_directory",
    ],
)

# This version of text_logging_test is compiled with HAVE_SPDLOG enabled,
# because that is what Drake's WORKSPACE provides for the @spdlog external.
drake_cc_googletest(
    name = "text_logging_test",
    defines = [
        "TEXT_LOGGING_TEST_SPDLOG=1",
    ],
    use_default_main = False,
    deps = [
        ":essential",
    ],
)

# Likewise (to the above test) for the ostream variation.
drake_cc_googletest(
    name = "text_logging_ostream_test",
    defines = [
        "TEXT_LOGGING_TEST_SPDLOG=1",
    ],
    use_default_main = False,
    deps = [
        ":essential",
    ],
)

# This version of text_logging_test re-compiles all source files without
# defining HAVE_SPDLOG, to ensure that the no-op stubs behave as desired.
drake_cc_googletest(
    name = "text_logging_no_spdlog_test",
    srcs = [
        "drake_copyable.h",
        "fmt.h",
        "never_destroyed.h",
        "test/text_logging_test.cc",
        "text_logging.cc",
        "text_logging.h",
    ],
    defines = [
        "TEXT_LOGGING_TEST_SPDLOG=0",
    ],
    use_default_main = False,
    deps = [
        "@fmt",
    ],
)

# Likewise (to the above test) for the ostream variation.
drake_cc_googletest(
    name = "text_logging_ostream_no_spdlog_test",
    srcs = [
        "drake_copyable.h",
        "fmt.h",
        "never_destroyed.h",
        "test/text_logging_ostream_test.cc",
        "text_logging.cc",
        "text_logging.h",
    ],
    defines = [
        "TEXT_LOGGING_TEST_SPDLOG=0",
    ],
    use_default_main = False,
    deps = [
        "@fmt",
    ],
)

drake_cc_googletest(
    name = "type_safe_index_test",
    deps = [
        ":type_safe_index",
        "//common:sorted_pair",
        "//common/test_utilities:expect_no_throw",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "eigen_autodiff_types_test",
    deps = [":autodiff"],
)

drake_cc_googletest(
    name = "scope_exit_test",
    deps = [
        ":scope_exit",
    ],
)

drake_cc_googletest(
    name = "scoped_singleton_test",
    deps = [
        ":scoped_singleton",
    ],
)

drake_cc_googletest(
    name = "timer_test",
    flaky = True,
    deps = [
        ":timer",
    ],
)

drake_cc_googletest(
    name = "drake_cc_googletest_main_test_device",
    args = ["--magic_number=1.0"],
)

# Run test/drake_cc_googletest_main_test.py, a unit test written in Python that
# covers the test/drake_cc_googletest_main.cc software.
drake_py_unittest(
    name = "drake_cc_googletest_main_test",
    args = ["$(location :drake_cc_googletest_main_test_device)"],
    data = [":drake_cc_googletest_main_test_device"],
)

drake_py_unittest(
    name = "resource_tool_test",
    args = [
        "$(location :resource_tool)",
    ],
    data = [
        "test/resource_tool_test_data.txt",
        ":resource_tool",
        "//examples/pendulum:models",
    ],
)

drake_cc_googletest(
    name = "value_test",
    deps = [
        ":value",
        "//common:essential",
        "//common/test_utilities:expect_no_throw",
        "//common/test_utilities:expect_throws_message",
        "//systems/framework/test_utilities:my_vector",
    ],
)

drake_cc_googletest(
    name = "scalar_casting_test",
    deps = [
        ":autodiff",
        ":extract_double",
        "//common/symbolic:expression",
    ],
)

add_lint_tests(
    enable_clang_format_lint = False,
    python_lint_extra_srcs = [
        ":test/resource_tool_installed_test.py",
    ],
)
