Lightweight coding agent that runs in your terminal
Rust
Supply Bazel-managed CMake and Ninja for the bundled Opus build (#43083)
Benjamin Carlsson068336858475
diff --git a/MODULE.bazel b/MODULE.bazelindex 2d94c88b87..0018fb347f 100644--- a/MODULE.bazel+++ b/MODULE.bazel@@ -146,6 +146,8 @@ single_version_override(bazel_dep(name = "rules_platform", version = "0.1.0")bazel_dep(name = "aws-lc", version = "5.1.0.bcr.1")bazel_dep(name = "rules_rs", version = "0.0.96")+bazel_dep(name = "rules_foreign_cc", version = "0.15.1")+single_version_override(module_name = "rules_rs",patch_strip = 1,@@ -548,6 +550,29 @@ crate.annotation(inject_repo(crate, "llvm", "llvm-project", "macos_sdk")+# The bundled Opus encoder uses CMake; supply executable tools and their data,+# rather than relying on a build worker's PATH. Versions are pinned by the module.+crate.annotation(+ build_script_data = ["//third_party/voice:opus-toolchain.cmake"],+ build_script_env = {+ "CMAKE": "$${pwd}/$(CMAKE)",+ "CMAKE_GENERATOR": "Ninja",+ "CMAKE_TOOLCHAIN_FILE": "$(execpath @@//third_party/voice:opus-toolchain.cmake)",+ "CODEX_VOICE_NINJA": "$${pwd}/$(NINJA)",+ },+ build_script_toolchains = [+ "@rules_foreign_cc//toolchains:current_cmake_toolchain",+ "@rules_foreign_cc//toolchains:current_ninja_toolchain",+ ],+ build_script_tools = [+ "@rules_foreign_cc//toolchains:current_cmake_toolchain",+ "@rules_foreign_cc//toolchains:current_ninja_toolchain",+ ],+ crate = "opusic-sys",+)++inject_repo(crate, "rules_foreign_cc")+crate.annotation(# Provide the hermetic SDK path so the build script doesn't try to invoke an unavailable `xcrun --show-sdk-path`.build_script_data = [diff --git a/MODULE.bazel.lock b/MODULE.bazel.lockindex b8550eb260..f785217ce1 100644--- a/MODULE.bazel.lock+++ b/MODULE.bazel.lock@@ -169,6 +169,8 @@"https://bcr.bazel.build/modules/rules_cc/0.2.20/source.json": "1155433dc6b8161bc339ce94095b337ed95feb1f048b014e10b62339d4b4239c","https://bcr.bazel.build/modules/rules_cc/0.2.4/MODULE.bazel": "1ff1223dfd24f3ecf8f028446d4a27608aa43c3f41e346d22838a4223980b8cc","https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642",+ "https://bcr.bazel.build/modules/rules_foreign_cc/0.15.1/MODULE.bazel": "c2c60d26c79fda484acb95cdbec46e89d6b28b4845cb277160ce1e0c8622bb88",+ "https://bcr.bazel.build/modules/rules_foreign_cc/0.15.1/source.json": "a161811a63ba8a859086da3b7ff3ad04f2e9c255d7727b41087103fc0eb22f55","https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6","https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8","https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74",@@ -221,6 +223,7 @@"https://bcr.bazel.build/modules/rules_python/0.34.0/MODULE.bazel": "1d623d026e075b78c9fde483a889cda7996f5da4f36dffb24c246ab30f06513a","https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c","https://bcr.bazel.build/modules/rules_python/1.0.0/MODULE.bazel": "898a3d999c22caa585eb062b600f88654bf92efb204fa346fb55f6f8edffca43",+ "https://bcr.bazel.build/modules/rules_python/1.2.0/MODULE.bazel": "5aeeb48b2a6c19d668b48adf2b8a2b209a6310c230db0ce77450f148a89846e4","https://bcr.bazel.build/modules/rules_python/1.3.0/MODULE.bazel": "8361d57eafb67c09b75bf4bbe6be360e1b8f4f18118ab48037f2bd50aa2ccb13","https://bcr.bazel.build/modules/rules_python/1.4.1/MODULE.bazel": "8991ad45bdc25018301d6b7e1d3626afc3c8af8aaf4bc04f23d0b99c938b73a6","https://bcr.bazel.build/modules/rules_python/1.5.1/MODULE.bazel": "acfe65880942d44a69129d4c5c3122d57baaf3edf58ae5a6bd4edea114906bf5",diff --git a/third_party/voice/BUILD.bazel b/third_party/voice/BUILD.bazelindex 345480c33b..1a6c678b8b 100644--- a/third_party/voice/BUILD.bazel+++ b/third_party/voice/BUILD.bazel@@ -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 = [diff --git a/third_party/voice/opus-toolchain.cmake b/third_party/voice/opus-toolchain.cmakenew file mode 100644index 0000000000..25fb567cd0--- /dev/null+++ b/third_party/voice/opus-toolchain.cmake@@ -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.