Files
codex/third_party/voice/extensions.bzl
T
Benjamin Carlsson 379d50be35 Add pinned native voice source preparation (#41884)
## What changed

- Pin the GStreamer, codec, native library, and build-tool archives needed by
  the native voice runtime, including their SHA-256 digests.
- Add lazy Bazel repositories and a manual `//third_party/voice:sources` target
  for fetching and unpacking the pinned archives.
- Add an offline Python adapter that verifies archive identity and extraction
  bounds, refuses existing output directories, cleans up failed preparations,
  and records a completion receipt.
- Document that this stage prepares source inputs only; it does not compile or
  link the libraries or enable voice.

## Testing

- Add unit coverage for digest failures, unsafe links, expansion limits,
  cleanup after extraction failures, existing-output preservation, and systems
  where archive links cannot be created.

GitOrigin-RevId: 42a71d7b6b91d49b3954a40932033c44f9861f04
2026-08-31 17:25:50 +00:00

28 lines
975 B
Python

"""Use standard Bazel archives for the standalone builder's pinned sources."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
_BUILD_FILE = """
filegroup(
name = "sources",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
"""
def _voice_sources_impl(module_ctx):
manifest = json.decode(module_ctx.read(Label("//third_party/voice:sources.json")))
for source in manifest["sources"]:
http_archive(
name = "voice_" + source["name"].replace("-", "_"),
urls = [source["url"]],
sha256 = source["sha256"],
strip_prefix = source["root"],
# Ninja's pinned codeload URL has no archive filename extension.
type = "tar.gz" if source["name"] == "ninja" else "",
build_file_content = _BUILD_FILE,
)
return module_ctx.extension_metadata(reproducible = True)
voice_sources = module_extension(implementation = _voice_sources_impl)