# BUILD file for use with https://github.com/dejwk/roo_testing.

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

cc_library(
    name = "roo_scheduler",
    srcs = glob(
        [
            "src/**/*.cpp",
            "src/**/*.h",
        ],
        exclude = ["test/**"],
    ),
    includes = [
        "src",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "@roo_collections",
        "@roo_threads",
        "@roo_time",
    ],
)

cc_test(
    name = "roo_scheduler_test",
    srcs = [
        "test/roo_scheduler_test.cpp",
    ],
    copts = ["-Iexternal/gtest/include"],
    includes = ["src"],
    linkstatic = 1,
    deps = [
        ":roo_scheduler",
        "@googletest//:gtest",
        "@roo_testing//:arduino_gtest_main",
        "@roo_testing//roo_testing/system:manual_time_mode",
    ],
)

cc_test(
    name = "roo_scheduler_auto_time_test",
    srcs = [
        "test/roo_scheduler_auto_time_test.cpp",
    ],
    copts = ["-Iexternal/gtest/include"],
    includes = ["src"],
    linkstatic = 1,
    deps = [
        ":roo_scheduler",
        "@googletest//:gtest",
        "@roo_testing//:arduino_gtest_main",
    ],
)

cc_test(
    name = "roo_scheduler_concurrency_test",
    srcs = ["test/roo_scheduler_concurrency_test.cpp"],
    size = "small",
    linkstatic = 1,
    deps = [
        ":roo_scheduler",
        "@googletest//:gtest",
        "@roo_testing//:arduino_gtest_main",
    ],
)

cc_test(
    name = "roo_scheduler_allocation_test",
    srcs = ["test/roo_scheduler_allocation_test.cpp"],
    size = "small",
    linkstatic = 1,
    deps = [
        ":roo_scheduler",
        "@googletest//:gtest",
        "@roo_testing//:arduino_gtest_main",
        "@roo_testing//roo_testing/system:manual_time_mode",
    ],
)

cc_library(
    name = "roo_scheduler_without_priority",
    srcs = ["src/roo_scheduler.cpp", "src/roo_scheduler.h"],
    includes = ["src"],
    defines = ["ROO_SCHEDULER_IGNORE_PRIORITY=1"],
    deps = ["@roo_collections", "@roo_threads", "@roo_time"],
)

cc_test(
    name = "roo_scheduler_without_priority_test",
    srcs = ["test/roo_scheduler_allocation_test.cpp"],
    size = "small",
    linkstatic = 1,
    deps = [
        ":roo_scheduler_without_priority",
        "@googletest//:gtest",
        "@roo_testing//:arduino_gtest_main",
        "@roo_testing//roo_testing/system:manual_time_mode",
    ],
)
