# -*- mode: python -*-
# vi: set ft=python :

load(
    "@drake//tools/skylark:drake_cc.bzl",
    "drake_cc_googletest",
    "drake_cc_library",
    "drake_cc_package_library",
)
load("//tools/lint:lint.bzl", "add_lint_tests")

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

drake_cc_package_library(
    name = "yaml",
    visibility = ["//visibility:public"],
    deps = [
        ":yaml_node",
        ":yaml_read_archive",
        ":yaml_write_archive",
    ],
)

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

drake_cc_library(
    name = "yaml_read_archive",
    srcs = ["yaml_read_archive.cc"],
    hdrs = ["yaml_read_archive.h"],
    deps = [
        "//common:essential",
        "//common:name_value",
        "//common:nice_type_name",
        "@yaml_cpp",
    ],
)

drake_cc_library(
    name = "yaml_write_archive",
    srcs = ["yaml_write_archive.cc"],
    hdrs = ["yaml_write_archive.h"],
    deps = [
        "//common:essential",
        "//common:name_value",
        "//common:nice_type_name",
        "//third_party/com_github_jbeder_yaml_cpp:emitfromevents",
        "@yaml_cpp",
    ],
)

# === test/ ===

drake_cc_library(
    name = "example_structs",
    testonly = True,
    hdrs = ["test/example_structs.h"],
    visibility = ["//visibility:private"],
    deps = [
        "//common:name_value",
    ],
)

drake_cc_googletest(
    name = "yaml_node_test",
    deps = [
        ":yaml_node",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "yaml_performance_test",
    deps = [
        ":yaml_read_archive",
        ":yaml_write_archive",
        "//common:autodiff",
        "//common:name_value",
        "//common/test_utilities:limit_malloc",
    ],
)

drake_cc_googletest(
    name = "yaml_read_archive_test",
    deps = [
        ":example_structs",
        ":yaml_read_archive",
        "//common:name_value",
        "//common/test_utilities:eigen_matrix_compare",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "yaml_write_archive_test",
    deps = [
        ":example_structs",
        ":yaml_write_archive",
        "//common:name_value",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "yaml_write_archive_defaults_test",
    deps = [
        ":example_structs",
        ":yaml_write_archive",
    ],
)

add_lint_tests()
