load("@py_deps//:requirements.bzl", "requirement")

fluent_syntax = [
    requirement("fluent.syntax"),
    requirement("compare-locales"),
    # undeclared runtime dependency
    requirement("six"),
]

filegroup(
    name = "ftl",
    srcs = [
        "@rslib_ftl//:files",
        "@extra_ftl//:files",
    ] + glob(["**/*.ftl"]),
    visibility = ["//rslib:__subpackages__"],
)

py_binary(
    name = "format",
    srcs = ["format.py"],
    deps = fluent_syntax,
)

py_test(
    name = "format_check",
    srcs = [
        "format.py",
        "format_check.py",
    ],
    # so we can locate data files
    args = ["$(location BUILD.bazel)"],
    data = glob(["**/*.ftl"]) + ["BUILD.bazel"],
    deps = fluent_syntax,
)

py_binary(
    name = "sync",
    srcs = ["sync.py"],
    tags = ["manual"],
    deps = fluent_syntax + [requirement("requests")],
)

py_binary(
    name = "extract-strings",
    srcs = ["extract-strings.py"],
    tags = ["manual"],
    deps = fluent_syntax,
)

py_binary(
    name = "transform-string",
    srcs = ["transform-string.py"],
    tags = ["manual"],
    deps = fluent_syntax,
)

py_binary(
    name = "duplicate-string",
    srcs = ["duplicate-string.py"],
    tags = ["manual"],
    deps = fluent_syntax,
)

# export this file as a way of locating the top level folder in $(location ...)
exports_files(
    ["BUILD.bazel"],
    visibility = ["//rslib:__subpackages__"],
)
