load("//cuttlefish/bazel:rules.bzl", "cf_cc_library", "cf_cc_test")

package(
    default_visibility = ["//:android_cuttlefish"],
)

cf_cc_library(
    name = "command_request",
    srcs = ["command_request.cpp"],
    hdrs = ["command_request.h"],
    clang_format_enabled = False,
    deps = [
        ":types",
        "//cuttlefish/flag_parser",
        "//cuttlefish/host/commands/cvd/cli/selector:selector_common_parser",
        "//cuttlefish/result",
        "//libbase",
    ],
)

cf_cc_library(
    name = "frontline_parser",
    srcs = ["frontline_parser.cpp"],
    hdrs = ["frontline_parser.h"],
    deps = [
        ":types",
        "//cuttlefish/flag_parser",
        "//cuttlefish/host/commands/cvd/cli/selector:selector_common_parser",
        "//cuttlefish/result",
        "//libbase",
    ],
)

cf_cc_test(
    name = "frontline_parser_test",
    srcs = ["frontline_parser_test.cpp"],
    deps = [
        "//cuttlefish/host/commands/cvd/cli:frontline_parser",
        "//cuttlefish/host/commands/cvd/cli/selector:selector_common_parser",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "help_format",
    srcs = ["help_format.cpp"],
    hdrs = ["help_format.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/flag_parser",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/strings",
    ],
)

cf_cc_library(
    name = "interruptible_terminal",
    srcs = ["interruptible_terminal.cpp"],
    hdrs = ["interruptible_terminal.h"],
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/posix:strerror",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/cleanup",
    ],
)

cf_cc_library(
    name = "log_files",
    srcs = ["log_files.cpp"],
    hdrs = ["log_files.h"],
    deps = [
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/host/commands/cvd/utils",
        "//cuttlefish/result",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/strings",
    ],
)

cf_cc_test(
    name = "log_files_test",
    srcs = ["log_files_test.cpp"],
    deps = [
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/host/commands/cvd/cli:log_files",
        "//cuttlefish/host/commands/cvd/utils",
        "//cuttlefish/result:result_matchers",
        "@abseil-cpp//absl/cleanup",
    ],
)

# Commands that may invoke other commands
cf_cc_library(
    name = "nesting_commands",
    srcs = [
        "request_context.cpp",
        "//cuttlefish/host/commands/cvd/cli/commands:create.cpp",
        "//cuttlefish/host/commands/cvd/cli/commands:help.cpp",
        "//cuttlefish/host/commands/cvd/cli/commands:load_configs.cpp",
    ],
    hdrs = [
        "request_context.h",
        "//cuttlefish/host/commands/cvd/cli/commands:create.h",
        "//cuttlefish/host/commands/cvd/cli/commands:help.h",
        "//cuttlefish/host/commands/cvd/cli/commands:load_configs.h",
    ],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/utils:contains",
        "//cuttlefish/common/libs/utils:environment",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:subprocess",
        "//cuttlefish/common/libs/utils:users",
        "//cuttlefish/flag_parser",
        "//cuttlefish/host/commands/cvd/cli:command_request",
        "//cuttlefish/host/commands/cvd/cli:help_format",
        "//cuttlefish/host/commands/cvd/cli:types",
        "//cuttlefish/host/commands/cvd/cli/commands:bugreport",
        "//cuttlefish/host/commands/cvd/cli/commands:cache",
        "//cuttlefish/host/commands/cvd/cli/commands:clear",
        "//cuttlefish/host/commands/cvd/cli/commands:command_handler",
        "//cuttlefish/host/commands/cvd/cli/commands:display",
        "//cuttlefish/host/commands/cvd/cli/commands:env",
        "//cuttlefish/host/commands/cvd/cli/commands:fetch",
        "//cuttlefish/host/commands/cvd/cli/commands:fleet",
        "//cuttlefish/host/commands/cvd/cli/commands:host_tool_target",
        "//cuttlefish/host/commands/cvd/cli/commands:lint",
        "//cuttlefish/host/commands/cvd/cli/commands:login",
        "//cuttlefish/host/commands/cvd/cli/commands:logs",
        "//cuttlefish/host/commands/cvd/cli/commands:power_btn",
        "//cuttlefish/host/commands/cvd/cli/commands:powerwash",
        "//cuttlefish/host/commands/cvd/cli/commands:remove",
        "//cuttlefish/host/commands/cvd/cli/commands:reset",
        "//cuttlefish/host/commands/cvd/cli/commands:restart",
        "//cuttlefish/host/commands/cvd/cli/commands:screen_recording",
        "//cuttlefish/host/commands/cvd/cli/commands:setup",
        "//cuttlefish/host/commands/cvd/cli/commands:snapshot",
        "//cuttlefish/host/commands/cvd/cli/commands:start",
        "//cuttlefish/host/commands/cvd/cli/commands:status",
        "//cuttlefish/host/commands/cvd/cli/commands:stop",
        "//cuttlefish/host/commands/cvd/cli/commands:version",
        "//cuttlefish/host/commands/cvd/cli/commands/monitor:command_handler",
        "//cuttlefish/host/commands/cvd/cli/parser:load_config_cc_proto",
        "//cuttlefish/host/commands/cvd/cli/parser:load_configs_parser",
        "//cuttlefish/host/commands/cvd/cli/selector:creation_analyzer",
        "//cuttlefish/host/commands/cvd/cli/selector:num_instances_parser",
        "//cuttlefish/host/commands/cvd/cli/selector:selector_common_parser",
        "//cuttlefish/host/commands/cvd/cli/selector:selector_constants",
        "//cuttlefish/host/commands/cvd/fetch:fetch_cvd",
        "//cuttlefish/host/commands/cvd/instances",
        "//cuttlefish/host/commands/cvd/instances:cvd_persistent_data",
        "//cuttlefish/host/commands/cvd/instances:instance_manager",
        "//cuttlefish/host/commands/cvd/instances/lock",
        "//cuttlefish/host/commands/cvd/utils",
        "//cuttlefish/host/libs/metrics:device_metrics_orchestration",
        "//cuttlefish/posix:strerror",
        "//cuttlefish/posix:symlink",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "types",
    hdrs = ["types.h"],
)

cf_cc_library(
    name = "utils",
    srcs = ["utils.cpp"],
    hdrs = ["utils.h"],
    clang_format_enabled = False,
    deps = [
        ":command_request",
        ":types",
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/utils:contains",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:gflags_xml_parser",
        "//cuttlefish/common/libs/utils:in_sandbox",
        "//cuttlefish/common/libs/utils:subprocess",
        "//cuttlefish/common/libs/utils:subprocess_managed_stdio",
        "//cuttlefish/common/libs/utils:users",
        "//cuttlefish/flag_parser",
        "//cuttlefish/host/commands/cvd/instances:config_path",
        "//cuttlefish/host/commands/cvd/utils",
        "//cuttlefish/host/libs/config:config_constants",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/strings",
        "@fmt",
    ],
)
