LiteRT-LM / android_ndk_env.bzl
SeaWolf-AI's picture
Upload full LiteRT-LM codebase
5f923cd verified
"""A workaround to check if ANDROID_NDK_HOME is set."""
def _check_android_ndk_env_impl(ctx):
ndk_home = ctx.getenv("ANDROID_NDK_HOME")
ndk_home_is_set = bool(ndk_home) and len(ndk_home.strip()) > 0
# .bzl file contains ANDROID_NDK_HOME_IS_SET = True if ANDROID_NDK_HOME is set.
content = "# Generated by check_android_ndk_env.bzl\n"
content += "ANDROID_NDK_HOME_IS_SET = "
content += "True" if ndk_home_is_set else "False"
content += "\n"
ctx.file("current_android_ndk_env.bzl", content = content)
# Dummy BUILD file to make the repository is valid.
ctx.file("BUILD", content = "")
check_android_ndk_env = repository_rule(
implementation = _check_android_ndk_env_impl,
local = True,
environ = ["ANDROID_NDK_HOME"],
)