package(default_visibility = ["//visibility:public"])

load(
    "@bazel_tools//tools/android:android_sdk_repository_template.bzl",
    "create_android_sdk_rules",
    "create_system_images_filegroups")

alias(
    name = "has_androidsdk",
    actual = "@bazel_tools//tools/android:always_true",
)

create_android_sdk_rules(
    name = "%repository_name%",
    build_tools_version = "%build_tools_version%",
    build_tools_directory = "%build_tools_directory%",
    api_levels = %api_levels%,
    default_api_level = %default_api_level%,
)

alias(
    name = "adb",
    actual = "platform-tools/adb",
)

alias(
    name = "emulator",
    actual = "emulator/emulator",
)

# emulator v29+ removed the arm and x86 specific binaries.
# Keeping these aliases around for backwards compatibility.
alias(
    name = "emulator_arm",
    actual = "emulator/emulator",
)

alias(
    name = "emulator_x86",
    actual = "emulator/emulator",
)

filegroup(
    name = "emulator_x86_bios",
    srcs = glob(
        ["emulator/lib/pc-bios/*"],
        allow_empty = True,
    ),
)

alias(
    name = "mksd",
    actual = "emulator/mksdcard",
)

filegroup(
    name = "emulator_shared_libs",
    srcs = glob(
        ["emulator/lib64/**"],
        allow_empty = True,
    ),
)

filegroup(
    name = "sdk_path",
    srcs = ["."],
)

filegroup(
    name = "qemu2_x86",
    srcs = ["emulator/emulator"] + select({
        "@bazel_tools//src/conditions:darwin_x86_64": ["emulator/qemu/darwin-x86_64/qemu-system-i386"],
        "@bazel_tools//src/conditions:darwin_arm64": ["emulator/qemu/darwin-aarch64/qemu-system-aarch64"],
        "//conditions:default": ["emulator/qemu/linux-x86_64/qemu-system-i386"],
    }),
)

create_system_images_filegroups(
    system_image_dirs = [
%system_image_dirs%    ],
)

exports_files([
%exported_files%] + glob(["system-images/**"], allow_empty = True))
