load("@fbcode//quic:defs.bzl", "mvfst_cpp_library")

oncall("traffic_protocols")

mvfst_cpp_library(
    # @autodeps-skip
    name = "mvfst_check",
    headers = select({
        "DEFAULT": {"MvfstCheck.h": "MvfstCheck.h"},
        "ovr_config//os/constraints:android": {"MvfstCheck.h": "facebook/MvfstCheck-mobile.h"},  # @fb-only
        "ovr_config//os/constraints:iphoneos": {"MvfstCheck.h": "facebook/MvfstCheck-mobile.h"},  # @fb-only
        "ovr_config//os/constraints:macos": {"MvfstCheck.h": "facebook/MvfstCheck-mobile.h"},  # @fb-only
        "ovr_config//os/constraints:windows": {"MvfstCheck.h": "facebook/MvfstCheck-mobile.h"},  # @fb-only
    }),
    exported_deps = [
        "//quic:logging_config",
    ] + select({
        "DEFAULT": ["fbsource//third-party/glog:glog"],
        "ovr_config//os/constraints:android": [],
        "ovr_config//os/constraints:iphoneos": [],
        "ovr_config//os/constraints:macos": [],
        "ovr_config//os/constraints:windows": [],
    }),
)

mvfst_cpp_library(
    name = "function_ref",
    headers = [
        "FunctionRef.h",
    ],
    exported_deps = [
        ":mvfst_check",
    ],
)

mvfst_cpp_library(
    name = "mvfst_logging",
    headers = select({
        "DEFAULT": select({
            "DEFAULT": {"MvfstLogging.h": "MvfstLogging.h"},
            "ovr_config//os/constraints:android": {"MvfstLogging.h": "facebook/MvfstLogging-mobile.h"},  # @fb-only
            "ovr_config//os/constraints:iphoneos": {"MvfstLogging.h": "facebook/MvfstLogging-mobile.h"},  # @fb-only
            "ovr_config//os/constraints:macos": {"MvfstLogging.h": "facebook/MvfstLogging-mobile.h"},  # @fb-only
        }),
    }),
    exported_deps = [
        "fbsource//third-party/glog:glog",
        ":mvfst_check",
        "//quic:logging_config",
    ] + select({
        "DEFAULT": ["//folly/logging:logging"],
        "ovr_config//os/constraints:android": [],
        "ovr_config//os/constraints:iphoneos": [],
        "ovr_config//os/constraints:macos": [],
        "ovr_config//os/constraints:windows": [],
    }),
)

mvfst_cpp_library(
    name = "interval_set",
    headers = [
        "IntervalSet.h",
        "IntervalSet-inl.h",
    ],
    exported_deps = [
        ":circular_deque",
        ":expected",
        ":mvfst_logging",
    ],
)

mvfst_cpp_library(
    name = "quic_buffer",
    srcs = [
        "QuicBuffer.cpp",
    ],
    headers = [
        "QuicBuffer.h",
        "QuicRange.h",
    ],
    deps = [
        ":mvfst_logging",
        "//quic/logging/oops_logger:oops_logger",
    ],
    exported_deps = [
        "//folly/portability:sys_uio",
    ],
)

mvfst_cpp_library(
    name = "variant",
    headers = [
        "Variant.h",
    ],
    exported_deps = [],
)

mvfst_cpp_library(
    name = "buf_accessor",
    srcs = [
        "BufAccessor.cpp",
    ],
    headers = [
        "BufAccessor.h",
    ],
    deps = [":mvfst_logging"],
    exported_deps = [
        "//folly/io:iobuf",
        "//folly/lang:align",
        "//quic:constants",
    ],
)

mvfst_cpp_library(
    name = "buf_util",
    srcs = [
        "BufUtil.cpp",
        "ChainedByteRange.cpp",
    ],
    headers = [
        "BufUtil.h",
        "ChainedByteRange.h",
    ],
    exported_deps = [
        ":mvfst_logging",
        "//folly:range",
        "//folly/io:iobuf",
        "//quic:constants",
    ],
)

mvfst_cpp_library(
    name = "enum_array",
    headers = [
        "EnumArray.h",
    ],
    exported_deps = [
        "fbsource//third-party/glog:glog",
        "//folly:portability",
    ],
)

mvfst_cpp_library(
    name = "socket_util",
    headers = [
        "SocketUtil.h",
    ],
    exported_deps = [
        ":expected",
        "//folly/io:socket_option_map",
        "//folly/net:net_ops",
        "//quic:exception",
    ],
)

mvfst_cpp_library(
    name = "string_utils",
    srcs = [
        "StringUtils.cpp",
    ],
    headers = [
        "StringUtils.h",
    ],
    deps = [
        "fbsource//third-party/fmt:fmt",
        "//quic:constants",
    ],
    exported_deps = [
        ":expected",
        "//quic:exception",
    ],
)

mvfst_cpp_library(
    name = "linux_kernel_version",
    srcs = [
        "LinuxKernelVersion.cpp",
    ],
    headers = [
        "LinuxKernelVersion.h",
    ],
    deps = [
        "//folly/synchronization:call_once",
    ],
    exported_deps = [
        ":optional",
    ],
)

mvfst_cpp_library(
    # @autodeps-skip
    name = "circular_deque",
    headers = [
        "CircularDeque.h",
        "CircularDeque-inl.h",
    ],
    exported_deps = [
        "fbsource//third-party/glog:glog",
        ":mvfst_logging",
    ],
)

mvfst_cpp_library(
    name = "network_data",
    headers = [
        "NetworkData.h",
    ],
    exported_deps = [
        ":buf_util",
        ":optional",
        ":time_points",
        "//folly/portability:sockets",
        "//quic:config",
        "//quic:constants",
    ],
)

mvfst_cpp_library(
    name = "time_points",
    headers = [
        "TimePoints.h",
    ],
    exported_deps = [
        ":optional",
        "//quic:constants",
    ],
)

mvfst_cpp_library(
    name = "time_util",
    headers = [
        "TimeUtil.h",
    ],
    exported_deps = [
        "//quic:constants",
    ],
)

mvfst_cpp_library(
    name = "transport_knobs",
    srcs = [
        "TransportKnobs.cpp",
    ],
    headers = [
        "TransportKnobs.h",
    ],
    deps = [
        ":mvfst_logging",
        "//folly:dynamic",
        "//quic:constants",
    ],
    exported_deps = [
        ":optional",
    ],
)

mvfst_cpp_library(
    name = "optional",
    headers = [
        "Optional.h",
    ],
    exported_deps = [
        "//quic:config",
    ],
)

mvfst_cpp_library(
    name = "contiguous_cursor",
    srcs = ["ContiguousCursor.cpp"],
    headers = [
        "ContiguousCursor.h",
    ],
    deps = [
        "//folly:likely",
    ],
    exported_deps = [
        "//folly:utility",
        "//folly/lang:bits",
        "//quic:constants",
    ],
)

mvfst_cpp_library(
    name = "expected",
    headers = [
        "Expected.h",
    ],
    exported_deps = [
        "//quic/common/third-party:expected",
    ],
)

mvfst_cpp_library(
    name = "quic_iobuf_queue",
    srcs = [
        "QuicIOBufQueue.cpp",
    ],
    headers = [
        "QuicIOBufQueue.h",
    ],
    exported_deps = [
        ":quic_buffer",
    ],
)
