load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("//cuttlefish/bazel:rules.bzl", "cf_cc_library", "cf_cc_test")

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

exports_files([".clang-tidy"])

cf_cc_library(
    name = "chroot",
    srcs = ["chroot.cc"],
    hdrs = ["chroot.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:filesystem",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
        "@abseil-cpp//absl/strings",
    ],
)

cf_cc_test(
    name = "chroot_test",
    srcs = ["chroot_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:chroot",
        "//cuttlefish/io:copy",
        "//cuttlefish/io:filesystem",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/io:string",
        "//cuttlefish/result",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "concat",
    srcs = ["concat.cc"],
    hdrs = ["concat.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:fake_seek",
        "//cuttlefish/io:length",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_test(
    name = "concat_test",
    srcs = ["concat_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:concat",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/io:string",
        "//cuttlefish/result",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "copy",
    srcs = ["copy.cc"],
    hdrs = ["copy.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_test(
    name = "copy_test",
    srcs = ["copy_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:copy",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/io:read_exact",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "cpio",
    srcs = ["cpio.cc"],
    hdrs = ["cpio.h"],
    deps = [
        "//cuttlefish/common/libs/utils:size_utils",
        "//cuttlefish/io",
        "//cuttlefish/io:filesystem",
        "//cuttlefish/io:read_exact",
        "//cuttlefish/io:read_window_view",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_test(
    name = "cpio_test",
    srcs = ["cpio_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:cpio",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/io:read_exact",
        "//cuttlefish/io:string",
        "//cuttlefish/result",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "default_visitor",
    srcs = ["default_visitor.cc"],
    hdrs = ["default_visitor.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:concat",
        "//cuttlefish/io:read_window_view",
        "//cuttlefish/io:shared_fd",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "disjoint_range_set",
    srcs = ["disjoint_range_set.cc"],
    hdrs = ["disjoint_range_set.h"],
    deps = [
        "//libbase",
        "@abseil-cpp//absl/log:check",
    ],
)

cc_proto_library(
    name = "disjoint_range_set_cc_proto",
    deps = ["//cuttlefish/io:disjoint_range_set_proto"],
)

proto_library(
    name = "disjoint_range_set_proto",
    srcs = ["disjoint_range_set.proto"],
)

cf_cc_test(
    name = "disjoint_range_set_test",
    srcs = ["disjoint_range_set_test.cc"],
    deps = ["//cuttlefish/io:disjoint_range_set"],
)

cf_cc_library(
    name = "fake_pread_pwrite",
    srcs = ["fake_pread_pwrite.cc"],
    hdrs = ["fake_pread_pwrite.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "fake_seek",
    srcs = ["fake_seek.cc"],
    hdrs = ["fake_seek.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_test(
    name = "fake_seek_test",
    srcs = ["fake_seek_test.cc"],
    deps = [
        "//cuttlefish/io:fake_seek",
        "//cuttlefish/result:result_matchers",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "filesystem",
    hdrs = ["filesystem.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "in_memory",
    srcs = ["in_memory.cc"],
    hdrs = ["in_memory.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:filesystem",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_test(
    name = "in_memory_test",
    srcs = ["in_memory_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/result:result_matchers",
        "//cuttlefish/result:result_type",
        "@abseil-cpp//absl/strings",
    ],
)

cf_cc_library(
    name = "io",
    srcs = ["io.cc"],
    hdrs = ["io.h"],
    deps = [
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "lazily_loaded_file",
    srcs = ["lazily_loaded_file.cc"],
    hdrs = ["lazily_loaded_file.h"],
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/io",
        "//cuttlefish/io:disjoint_range_set",
        "//cuttlefish/io:serialize_disjoint_range_set",
        "//cuttlefish/result",
        "@abseil-cpp//absl/log",
    ],
)

cf_cc_library(
    name = "length",
    srcs = ["length.cc"],
    hdrs = ["length.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_test(
    name = "length_test",
    srcs = ["length_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/io:length",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "lz4_legacy",
    srcs = ["lz4_legacy.cc"],
    hdrs = ["lz4_legacy.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:read_exact",
        "//cuttlefish/io:write_exact",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
        "@lz4",
    ],
)

cf_cc_test(
    name = "lz4_legacy_test",
    srcs = ["lz4_legacy_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:filesystem",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/io:lz4_legacy",
        "//cuttlefish/io:read_exact",
        "//cuttlefish/io:string",
        "//cuttlefish/io:write_exact",
        "//cuttlefish/result",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "native_filesystem",
    srcs = ["native_filesystem.cc"],
    hdrs = ["native_filesystem.h"],
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/io",
        "//cuttlefish/io:filesystem",
        "//cuttlefish/io:shared_fd",
        "//cuttlefish/posix:strerror",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "read_exact",
    srcs = ["read_exact.cc"],
    hdrs = ["read_exact.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "read_window_view",
    srcs = ["read_window_view.cc"],
    hdrs = ["read_window_view.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:fake_seek",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_test(
    name = "read_window_view_test",
    srcs = ["read_window_view_test.cc"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/io:in_memory",
        "//cuttlefish/io:read_window_view",
        "//cuttlefish/io:string",
        "//cuttlefish/result:result_matchers",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "serialize_disjoint_range_set",
    srcs = ["serialize_disjoint_range_set.cc"],
    hdrs = ["serialize_disjoint_range_set.h"],
    deps = [
        "//cuttlefish/io:disjoint_range_set",
        "//cuttlefish/io:disjoint_range_set_cc_proto",
        "//cuttlefish/result",
    ],
)

cf_cc_test(
    name = "serialize_disjoint_range_set_test",
    srcs = ["serialize_disjoint_range_set_test.cc"],
    deps = [
        "//cuttlefish/io:disjoint_range_set",
        "//cuttlefish/io:serialize_disjoint_range_set",
        "//cuttlefish/result",
        "//cuttlefish/result:result_matchers",
    ],
)

cf_cc_library(
    name = "shared_fd",
    srcs = ["shared_fd.cc"],
    hdrs = ["shared_fd.h"],
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "string",
    srcs = ["string.cc"],
    hdrs = ["string.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)

cf_cc_library(
    name = "write_exact",
    srcs = ["write_exact.cc"],
    hdrs = ["write_exact.h"],
    deps = [
        "//cuttlefish/io",
        "//cuttlefish/result:expect",
        "//cuttlefish/result:result_type",
    ],
)
