load("@rules_erlang//:erlang_bytecode2.bzl", "erlang_bytecode", "erlc_opts")
load("@rules_erlang//:erlang_app.bzl", "erlang_app")

erlc_opts(
    name = "erlc_opts",
    values = select({
        "@rules_erlang//:debug_build": [
            "+debug_info",
            "+recv_opt_info",
            "+warn_export_vars",
            "+warn_obsolete_guard",
            "+warn_shadow_vars",
        ],
        "//conditions:default": [
            "+debug_info",
            "+deterministic",
            "+recv_opt_info",
            "+warn_export_vars",
            "+warn_obsolete_guard",
            "+warn_shadow_vars",
        ],
    }),
    visibility = [":__subpackages__"],
)

erlang_bytecode(
    name = "other_beam",
    srcs = ["src/gen_batch_server.erl"],
    outs = ["ebin/gen_batch_server.beam"],
    hdrs = [],
    app_name = "gen_batch_server",
    beam = [],
    erlc_opts = "//:erlc_opts",
)

filegroup(
    name = "beam_files",
    srcs = [":other_beam"],
)

filegroup(
    name = "srcs",
    srcs = [
        "src/gen_batch_server.app.src",
        "src/gen_batch_server.erl",
    ],
)

filegroup(
    name = "private_hdrs",
    srcs = [],
)

filegroup(
    name = "public_hdrs",
    srcs = [],
)

filegroup(
    name = "priv",
    srcs = [],
)

filegroup(
    name = "licenses",
    srcs = [
        "LICENSE",
        "LICENSE-APACHE2",
        "LICENSE-MPL-RabbitMQ",
    ],
)

filegroup(
    name = "public_and_private_hdrs",
    srcs = [
        ":private_hdrs",
        ":public_hdrs",
    ],
)

filegroup(
    name = "all_srcs",
    srcs = [
        ":public_and_private_hdrs",
        ":srcs",
    ],
)

erlang_app(
    name = "erlang_app",
    srcs = [":all_srcs"],
    app_name = "gen_batch_server",
    beam_files = [":beam_files"],
)

alias(
    name = "gen_batch_server",
    actual = ":erlang_app",
    visibility = ["//visibility:public"],
)
