tflite-micro/BUILD
Ryan Kuester 068c6a59b6
build(bazel): inject tflite_micro shim via tflm_py_* wrappers (#3573)
Python targets in this repository import one another under the
"tflite_micro" package namespace, which //:tflite_micro_shim synthesizes
at import time. The shim is required under Bzlmod, where the main
repository's runfiles root is the fixed name "_main" rather than the
module name, so the "tflite_micro" prefix no longer resolves on its own.
Every such target therefore had to list //:tflite_micro_shim in its
deps, which was repetitive and easy to forget.

Add tflm_py_library, tflm_py_test, and tflm_py_binary wrappers in a new
//python:py_rules.bzl that inject the shim dependency automatically,
following the naming convention of the existing tflm_cc_* wrappers, and
document the shim's rationale there. Convert every target that
previously listed the shim to the corresponding wrapper and drop the
explicit dependency. The dependency graph is unchanged; only the means
by which the shim is attached differs.
2026-05-26 19:51:58 +00:00

33 lines
1.2 KiB
Text

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@rules_python//python:defs.bzl", "py_library")
# `bazel run` this target to generate compile_commands.json, which can be used
# by various tools like editors and LSPs to provide features like intelligent
# navigation and autocompletion based on the source graph and compiler commands.
alias(
name = "refresh_compile_commands",
actual = "@wolfd_bazel_compile_commands//:generate_compile_commands",
)
bool_flag(
name = "with_compression",
build_setting_default = False,
)
config_setting(
name = "with_compression_enabled",
flag_values = {
":with_compression": "True",
},
)
# Synthesizes the "tflite_micro" top-level package namespace at import time, so
# that `from tflite_micro...` imports resolve (see tflite_micro.py). Necessary
# because Bzlmod fixes the main repo's runfiles root to "_main" rather than the
# module name. Targets should generally not depend on this directly: use the
# tflm_py_* wrappers in //python:py_rules.bzl, which add it automatically.
py_library(
name = "tflite_micro_shim",
srcs = ["tflite_micro.py"],
visibility = ["//visibility:public"],
)