Supply Bazel-managed CMake and Ninja for the bundled Opus build (#43083)

## Why

The bundled Opus encoder uses CMake and should not depend on tools available on a build worker's `PATH`.

## What changed

- Add `rules_foreign_cc` and provide its pinned CMake and Ninja tools and data to the `opusic-sys` build script.
- Add a CMake toolchain file that selects the declared Ninja executable, resolves the archiver path, and sets the target system and processor from `TARGET`, while retaining Bazel's compiler, SDK, and linker inputs.

GitOrigin-RevId: 48580c506d088d8c76cce958589ff94da458bd79
This commit is contained in:
Benjamin Carlsson
2026-09-05 19:31:24 +00:00
committed by copyberry
parent 19b62211d9
commit 0683368584
4 changed files with 44 additions and 0 deletions
+2
View File
@@ -1,4 +1,6 @@
# All native build consumers must receive the same pinned source manifest.
exports_files(["opus-toolchain.cmake"])
filegroup(
name = "source_inputs",
srcs = [
+14
View File
@@ -0,0 +1,14 @@
# CMake's generator must use the Ninja declared in the Bazel action.
set(CMAKE_MAKE_PROGRAM "$ENV{CODEX_VOICE_NINJA}" CACHE FILEPATH "" FORCE)
# Archiver paths from Bazel are relative to the execution root.
get_filename_component(CMAKE_AR "$ENV{AR}" ABSOLUTE
BASE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..")
if("$ENV{TARGET}" MATCHES "apple-darwin$")
set(CMAKE_SYSTEM_NAME Darwin)
elseif("$ENV{TARGET}" MATCHES "windows")
set(CMAKE_SYSTEM_NAME Windows)
else()
set(CMAKE_SYSTEM_NAME Linux)
endif()
string(REGEX REPLACE "-.*" "" CMAKE_SYSTEM_PROCESSOR "$ENV{TARGET}")
# Compiler, SDK and linker inputs remain supplied by Bazel's target toolchain.