[CI] Fix build (#3194)

- Upgraded the Bazel BuildTool to the latest version (8.2.1).
- Updated the `tflm-ci` Docker image and pushed the new tag (0.6.1) to the `ghcr.io/tflm-bot/tflm-ci registry`.
- Updated the WORKSPACE to load `rules_cc` and `rules_shell` explicitly
- Ran `buildifier` to ensure all BUILD files to have all the fixes.

BUG=Clean-up
This commit is contained in:
Esun Kim 2025-09-19 13:48:22 -07:00 committed by GitHub
parent aa6e625177
commit ba753cef3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 127 additions and 54 deletions

3
BUILD
View file

@ -1,3 +1,4 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
# `bazel run` this target to generate compile_commands.json, which can be used
@ -8,8 +9,6 @@ refresh_compile_commands(
targets = ["//..."],
)
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
bool_flag(
name = "with_compression",
build_setting_default = False,

View file

@ -19,6 +19,13 @@ load("//tensorflow:workspace.bzl", "workspace")
workspace()
# init for rules_shell
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
rules_shell_dependencies()
rules_shell_toolchains()
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# compile_commands.json generator

View file

@ -28,7 +28,7 @@ COPY ci/install_qemu.sh ./
RUN ./install_qemu.sh /tmp/qemu_install
# This stage is the final CI container.
FROM python:3.10-bullseye as tflm-ci
FROM python:3.10-bullseye AS tflm-ci
RUN apt-get update

View file

@ -16,13 +16,13 @@
set -e
# Download buildifier.
wget https://github.com/bazelbuild/buildtools/releases/download/4.2.3/buildifier-linux-amd64
wget https://github.com/bazelbuild/buildtools/releases/download/v8.2.1/buildifier-linux-amd64
mv buildifier-linux-amd64 buildifier
chmod +x buildifier
sudo mv buildifier /usr/local/bin/.
# Download buildozer.
wget https://github.com/bazelbuild/buildtools/releases/download/4.2.3/buildozer-linux-amd64
wget https://github.com/bazelbuild/buildtools/releases/download/v8.2.1/buildozer-linux-amd64
mv buildozer-linux-amd64 buildozer
chmod +x buildozer
sudo mv buildozer /usr/local/bin/.

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("//codegen:build_def.bzl", "tflm_inference_library")
package(default_visibility = ["//visibility:public"])

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_test.bzl", "cc_test")
cc_test(
name = "cc_deps_link_test",
size = "small",

View file

@ -1,18 +1,19 @@
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("//python:py_namespace.bzl", "py_namespace")
load("//tools:expand_stamp_vars.bzl", "expand_stamp_vars")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
)
load("//python:py_namespace.bzl", "py_namespace")
load(
"//tensorflow:extra_rules.bzl",
"tflm_python_op_resolver_friends",
)
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
)
load("//tools:expand_stamp_vars.bzl", "expand_stamp_vars")
package(
features = ["-layering_check"],

View file

@ -1,7 +1,8 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load("//python/tflite_micro/signal:tflm_signal.bzl", "py_tflm_signal_library")
load("//tensorflow:extra_rules.bzl", "tflm_signal_friends")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
package(
default_visibility = [":__subpackages__"],

View file

@ -1,5 +1,7 @@
"""Build rule for wrapping a custom TF OP from .cc to python."""
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_library")
# TODO(b/286890280): refactor to be more generic build target for any custom OP
@ -37,7 +39,7 @@ def py_tflm_signal_library(
if cc_op_defs:
binary_name = "ops/_" + name + ".so"
library_name = name + "_cc"
native.cc_library(
cc_library(
name = library_name,
copts = select({
"//conditions:default": ["-pthread"],
@ -49,8 +51,7 @@ def py_tflm_signal_library(
["@tensorflow_cc_deps//:cc_library"] +
select({"//conditions:default": []}),
)
native.cc_binary(
cc_binary(
name = binary_name,
copts = select({
"//conditions:default": ["-pthread"],
@ -80,7 +81,7 @@ def tflm_signal_kernel_library(
deps = [],
copts = [],
alwayslink = 1):
native.cc_library(
cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,

View file

@ -1,7 +1,8 @@
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
# Signal python utilities.
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
package(
default_visibility = [

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = ["//signal:__subpackages__"],
licenses = ["notice"],

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = ["//signal/src:__subpackages__"],
licenses = ["notice"],

View file

@ -1,5 +1,7 @@
# Test data for signal tests. This is used to store large arrays which would make tests less readable.
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = ["//signal/micro/kernels:__subpackages__"],
licenses = ["notice"],

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
package(

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],

View file

@ -1,4 +1,5 @@
load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = [

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load(
"//tensorflow/lite:build_def.bzl",
"tflite_copts",

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
cc_library(
name = "macros",
hdrs = ["macros.h"],

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load(
"//tensorflow/lite:build_def.bzl",
"tflite_copts",

View file

@ -1,3 +1,6 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
# Library for generating feature vectors from audio data
package(
default_visibility = ["//visibility:public"],

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
load(
"//tensorflow/lite/micro:build_def.bzl",

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
load(
"//tensorflow/lite/micro:build_def.bzl",

View file

@ -1,5 +1,9 @@
"""TfLite Micro BUILD options."""
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
def tflm_copts():
"""Returns the default copts for targets in TFLM.
@ -45,21 +49,21 @@ def tflm_defines():
return defines
def tflm_cc_binary(copts = tflm_copts(), defines = tflm_defines(), **kwargs):
native.cc_binary(
cc_binary(
copts = copts,
defines = defines,
**kwargs
)
def tflm_cc_library(copts = tflm_copts(), defines = tflm_defines(), **kwargs):
native.cc_library(
cc_library(
copts = copts,
defines = defines,
**kwargs
)
def tflm_cc_test(copts = tflm_copts(), defines = tflm_defines(), **kwargs):
native.cc_test(
cc_test(
copts = copts,
defines = defines,
**kwargs

View file

@ -1,15 +1,16 @@
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_cc_test",
)
load(
"@flatbuffers//:build_defs.bzl",
"flatbuffer_cc_library",
"flatbuffer_py_library",
)
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_cc_test",
)
load("view_tests.bzl", "generate_view_tests")
package(

View file

@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_test")
def generate_view_tests(targets):
"""Generates py_test targets for each target's path and a test_suite to
group them.
@ -10,8 +12,7 @@ def generate_view_tests(targets):
# Create a test name from the last component of the target name
short_name = target.split(":")[-1] if ":" in target else target.split("/")[-1]
test_name = "view_test_{}".format(short_name.replace(".", "_"))
native.py_test(
py_test(
name = test_name,
srcs = ["view_test.py"],
args = ["$(location {})".format(target)],

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load(
"//tensorflow/lite/micro:build_def.bzl",
"generate_cc_arrays",

View file

@ -1,5 +1,5 @@
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
package(
features = ["-layering_check"],

View file

@ -1,11 +1,4 @@
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_cc_test",
"tflm_copts",
"tflm_kernel_cc_library",
)
load(
"//tensorflow:extra_rules.bzl",
"tflm_kernel_friends",
@ -15,6 +8,13 @@ load(
"xtensa_hifi_5_config",
"xtensa_vision_p6_config",
)
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_cc_test",
"tflm_copts",
"tflm_kernel_cc_library",
)
package(
features = [

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
package(
# Disabling layering_check because of http://b/177257332
features = ["-layering_check"],

View file

@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",

View file

@ -1,11 +1,11 @@
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
)
load(
"//tensorflow:extra_rules.bzl",
"tflm_python_op_resolver_friends",
)
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
)
package(
features = ["-layering_check"],

View file

@ -1,5 +1,5 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension", "pybind_library")
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
package(
default_visibility = ["//visibility:public"],

View file

@ -1,14 +1,14 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load(
"//tensorflow:extra_rules.bzl",
"tflm_kernel_friends",
)
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_cc_test",
)
load(
"//tensorflow:extra_rules.bzl",
"tflm_kernel_friends",
)
package(
# Disabling layering_check because of http://b/177257332

View file

@ -1,7 +1,8 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load("//tensorflow:extra_rules.bzl", "tflm_application_friends")
package(

View file

@ -1,4 +1,5 @@
load("@flatbuffers//:build_defs.bzl", "flatbuffer_py_library")
load("@rules_python//python:defs.bzl", "py_library")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
package(

View file

@ -1,4 +1,5 @@
load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = [

View file

@ -1,3 +1,4 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
py_library(

View file

@ -1,7 +1,7 @@
load("//third_party:repo.bzl", "tf_http_archive")
load("//third_party/flatbuffers:workspace.bzl", flatbuffers = "repo")
load("//third_party/kissfft:workspace.bzl", kissfft = "repo")
load("//third_party/ruy:workspace.bzl", ruy = "repo")
load("//third_party:repo.bzl", "tf_http_archive")
def initialize_third_party():
""" Load third party repositories. See above load() statements. """
@ -27,6 +27,26 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
],
)
# https://github.com/bazelbuild/rules_cc
tf_http_archive(
name = "rules_cc",
sha256 = "b8b918a85f9144c01f6cfe0f45e4f2838c7413961a8ff23bc0c6cdf8bb07a3b6",
strip_prefix = "rules_cc-0.1.5",
urls = [
"https://github.com/bazelbuild/rules_cc/releases/download/0.1.5/rules_cc-0.1.5.tar.gz",
],
)
# https://github.com/bazelbuild/rules_shell
tf_http_archive(
name = "rules_shell",
sha256 = "e6b87c89bd0b27039e3af2c5da01147452f240f75d505f5b6880874f31036307",
strip_prefix = "rules_shell-0.6.1",
urls = [
"https://github.com/bazelbuild/rules_shell/releases/download/v0.6.1/rules_shell-v0.6.1.tar.gz",
],
)
tf_http_archive(
name = "gemmlowp",
sha256 = "43146e6f56cb5218a8caaab6b5d1601a083f1f31c06ff474a4378a7d35be9cfb", # SHARED_GEMMLOWP_SHA

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_python//python:defs.bzl", "py_library")
load(":build_defs.bzl", "flatbuffer_py_strip_prefix_srcs")
package(default_visibility = ["//visibility:public"])
@ -21,8 +23,6 @@ config_setting(
values = {"cpu": "x64_windows"},
)
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
# Public flatc library to compile flatbuffer files at runtime.
cc_library(
name = "flatbuffers",

View file

@ -1,5 +1,6 @@
"""BUILD rules for generating flatbuffer files."""
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_library")
flatc_path = "@flatbuffers//:flatc"
@ -108,7 +109,7 @@ def flatbuffer_library_public(
)
# TODO(b/114456773): Make bazel rules proper and supported by flatbuffer
# Have to comment this since FilesetEntry is not supported in bazel
# skylark.
# starlark.
# native.Fileset(
# name = reflection_name,
# out = "%s_out" % reflection_name,
@ -212,7 +213,7 @@ def flatbuffer_cc_library(
reflection_name = reflection_name,
reflection_visibility = visibility,
)
native.cc_library(
cc_library(
name = name,
hdrs = output_headers,
srcs = output_headers,

View file

@ -1,3 +1,5 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(
default_visibility = ["//visibility:public"],
)
@ -11,10 +13,10 @@ cc_library(
srcs = [
],
hdrs = [
"kiss_fft.c",
"tools/kiss_fftr.c",
"_kiss_fft_guts.h",
"kiss_fft.c",
"kiss_fft.h",
"tools/kiss_fftr.c",
"tools/kiss_fftr.h",
],
)