load("//bazel:defs.bzl", "compatible_with_rp2")
load("//bazel/util:transition.bzl", "kitchen_sink_test_binary")

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

cc_library(
    name = "btstack_config",
    hdrs = ["btstack_config.h"],
    defines = [
        "ENABLE_CLASSIC=1",
        "ENABLE_BLE=1",
    ],
    includes = ["."],
)

cc_library(
    name = "lwip_config",
    hdrs = ["lwipopts.h"],
    includes = ["."],
)

cc_library(
    name = "mbedtls_config",
    hdrs = ["mbedtls_config.h"],
    includes = ["."],
)

cc_library(
    name = "kitchen_sink_common",
    testonly = True,
    # So that the cpp one can see the c file.
    hdrs = ["kitchen_sink.c"],
    target_compatible_with = compatible_with_rp2(),
    deps = [
        "//src/common/hardware_claim",
        "//src/common/pico_binary_info",
        "//src/common/pico_bit_ops_headers",
        "//src/common/pico_sync",
        "//src/common/pico_time",
        "//src/common/pico_util",
        "//src/rp2_common:hardware_structs",
        "//src/rp2_common:pico_platform",
        "//src/rp2_common/hardware_adc",
        "//src/rp2_common/hardware_clocks",
        "//src/rp2_common/hardware_divider",
        "//src/rp2_common/hardware_dma",
        "//src/rp2_common/hardware_exception",
        "//src/rp2_common/hardware_flash",
        "//src/rp2_common/hardware_gpio",
        "//src/rp2_common/hardware_i2c",
        "//src/rp2_common/hardware_interp",
        "//src/rp2_common/hardware_irq",
        "//src/rp2_common/hardware_pio",
        "//src/rp2_common/hardware_pll",
        "//src/rp2_common/hardware_pwm",
        "//src/rp2_common/hardware_resets",
        "//src/rp2_common/hardware_spi",
        "//src/rp2_common/hardware_sync",
        "//src/rp2_common/hardware_timer",
        "//src/rp2_common/hardware_uart",
        "//src/rp2_common/hardware_vreg",
        "//src/rp2_common/hardware_watchdog",
        "//src/rp2_common/hardware_xosc",
        "//src/rp2_common/pico_aon_timer",
        "//src/rp2_common/pico_bootrom",
        "//src/rp2_common/pico_divider",
        "//src/rp2_common/pico_double",
        "//src/rp2_common/pico_fix/rp2040_usb_device_enumeration",
        "//src/rp2_common/pico_flash",
        "//src/rp2_common/pico_float",
        "//src/rp2_common/pico_i2c_slave",
        "//src/rp2_common/pico_int64_ops",
        "//src/rp2_common/pico_malloc",
        "//src/rp2_common/pico_mem_ops",
        "//src/rp2_common/pico_multicore",
        "//src/rp2_common/pico_printf",
        "//src/rp2_common/pico_rand",
        "//src/rp2_common/pico_runtime",
        "//src/rp2_common/pico_stdio",
        "//src/rp2_common/pico_stdlib",
        "//src/rp2_common/pico_unique_id",
        "//test/pico_test",
    ] + select({
        "//bazel/constraint:rp2350": [
            "//src/rp2_common/hardware_sha256",
        ],
        "//conditions:default": [
            "//src/rp2_common/hardware_rtc",
        ],
    }),
)

cc_binary(
    name = "kitchen_sink",
    testonly = True,
    srcs = ["kitchen_sink.c"],
    deps = [":kitchen_sink_common"],
)

cc_binary(
    name = "kitchen_sink_cpp",
    testonly = True,
    srcs = ["kitchen_sink_cpp.cpp"],
    deps = [":kitchen_sink_common"],
)

cc_binary(
    name = "kitchen_sink_lwip_poll_actual",
    testonly = True,
    srcs = ["kitchen_sink.c"],
    tags = ["manual"],  # Built via kitchen_sink_lwip_poll
    deps = [
        ":kitchen_sink_common",
        "//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_lwip_poll",
    ],
)

cc_binary(
    name = "kitchen_sink_lwip_background_actual",
    testonly = True,
    srcs = ["kitchen_sink.c"],
    tags = ["manual"],  # Built via kitchen_sink_lwip_background
    deps = [
        ":kitchen_sink_common",
        "//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_lwip_threadsafe_background",
    ],
)

kitchen_sink_test_binary(
    name = "kitchen_sink_lwip_poll",
    testonly = True,
    src = ":kitchen_sink_lwip_poll_actual",
    bt_stack_config = ":btstack_config",
    lwip_config = ":lwip_config",
    target_compatible_with = compatible_with_rp2(),
)

kitchen_sink_test_binary(
    name = "kitchen_sink_lwip_background",
    testonly = True,
    src = ":kitchen_sink_lwip_background_actual",
    bt_stack_config = ":btstack_config",
    lwip_config = ":lwip_config",
    target_compatible_with = compatible_with_rp2(),
)
