################################################################
# %toolchainName%
################################################################

cc_toolchain(
    name = "%toolchainName%",
    all_files = ":%toolchainName%-all_files",
    ar_files = ":%toolchainName%-all_files",
    as_files = ":%toolchainName%-all_files",
    compiler_files = ":%toolchainName%-all_files",
    dwp_files = ":%toolchainName%-all_files",
    dynamic_runtime_lib = ":%dynamicRuntimeLibs%",
    linker_files = ":%toolchainName%-all_files",
    objcopy_files = ":%toolchainName%-all_files",
    static_runtime_lib = ":%staticRuntimeLibs%",
    strip_files = ":%toolchainName%-all_files",
    supports_param_files = 1,
    toolchain_identifier = "%toolchainName%",
    toolchain_config = ":%toolchainName%-config",
)

cc_toolchain_config(
    name = "%toolchainName%-config",
    cpu = "%cpu%",
    compiler = "%compiler%",
    version = "%version%",
)

toolchain(
    name = "%toolchainName%_toolchain",
    target_compatible_with = [
        "@platforms//os:android",
        "@platforms//cpu:%platform_cpu%",
    ],
    toolchain = "@androidndk//:%toolchainName%",
    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

filegroup(
    name = "%toolchainName%-all_files",
    srcs = glob(["ndk/toolchains/%toolchainDirectory%/**"], allow_empty = True) + glob([
        %toolchainFileGlobs%
    ], allow_empty = True) + [
      ":%dynamicRuntimeLibs%",
      ":%staticRuntimeLibs%",
    ],
)

