# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

load("@rules_rust//rust:defs.bzl", "rust_test")
load("//rslib:rustfmt.bzl", "rustfmt_fix", "rustfmt_test")

rust_test(
    name = "linkchecker",
    srcs = ["tests/links.rs"],
    tags = [
        "ci",
        "manual",
    ],
    deps = [
        "//rslib:anki",
        "//rslib/linkchecker/cargo:futures",
        "//rslib/linkchecker/cargo:itertools",
        "//rslib/linkchecker/cargo:linkcheck",
        "//rslib/linkchecker/cargo:strum",
        "//rslib/linkchecker/cargo:tokio",
    ] + select({
        # rustls on Linux
        "//platforms:linux_x86_64": ["@reqwest_rustls//:reqwest"],
        "//platforms:linux_arm64": ["@reqwest_rustls//:reqwest"],
        # native tls on other platforms
        "//conditions:default": ["//rslib/linkchecker/cargo:reqwest"],
    }),
)

rustfmt_test(
    name = "format_check",
    srcs = glob([
        "src/**/*.rs",
    ]),
)

rustfmt_fix(
    name = "format",
    srcs = glob([
        "src/**/*.rs",
    ]),
)
