# 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_binary", "rust_library", "rust_test")
load("//rslib:rustfmt.bzl", "rustfmt_fix", "rustfmt_test")

# Library
#######################

rust_library(
    name = "anki_i18n_helpers",
    srcs = glob(
        [
            "src/**/*.rs",
        ],
        exclude = ["src/bin/**"],
    ),
    visibility = ["//rslib:__subpackages__"],
    deps = [
        "//rslib/i18n_helpers/cargo:fluent_syntax",
        "//rslib/i18n_helpers/cargo:lazy_static",
        "//rslib/i18n_helpers/cargo:regex",
        "//rslib/i18n_helpers/cargo:serde_json",
        "//rslib/i18n_helpers/cargo:walkdir",
    ],
)

rust_binary(
    name = "write_ftl_json",
    srcs = ["src/bin/write_ftl_json.rs"],
    deps = [":anki_i18n_helpers"],
)

rust_binary(
    name = "garbage_collect_ftl_entries",
    srcs = ["src/bin/garbage_collect_ftl_entries.rs"],
    deps = [":anki_i18n_helpers"],
)

# Tests
#######################

rust_test(
    name = "i18n_helpers_tests",
    crate = ":anki_i18n_helpers",
)

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

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