Wire realtime WebRTC native media into Bazel (#17145)

- Builds codex-realtime-webrtc through the normal Bazel Rust macro so
native macOS WebRTC sources are included.\n- Shares the macOS -ObjC link
flag with Bazel targets that can link libwebrtc.

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-04-08 15:15:55 -07:00
committed by GitHub
Unverified
parent 56dfe41605
commit 19bd018300
9 changed files with 137 additions and 18 deletions
+2 -1
View File
@@ -1,8 +1,9 @@
load("//:defs.bzl", "codex_rust_crate", "multiplatform_binaries")
load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate", "multiplatform_binaries")
codex_rust_crate(
name = "cli",
crate_name = "codex_cli",
rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS,
)
multiplatform_binaries(
+2 -1
View File
@@ -1,6 +1,7 @@
load("//:defs.bzl", "codex_rust_crate")
load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate")
codex_rust_crate(
name = "cloud-tasks",
crate_name = "codex_cloud_tasks",
rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS,
)
+3 -8
View File
@@ -1,12 +1,7 @@
load("@rules_rust//rust:defs.bzl", "rust_library")
load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate")
rust_library(
codex_rust_crate(
name = "realtime-webrtc",
crate_name = "codex_realtime_webrtc",
crate_root = "src/lib.rs",
srcs = ["src/lib.rs"],
edition = "2024",
rustc_flags = ["--cfg=codex_bazel"],
deps = ["@crates//:thiserror"],
visibility = ["//visibility:public"],
rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS,
)
+7 -7
View File
@@ -1,4 +1,4 @@
#[cfg(all(target_os = "macos", not(codex_bazel)))]
#[cfg(target_os = "macos")]
mod native;
use std::fmt;
@@ -31,7 +31,7 @@ pub struct StartedRealtimeWebrtcSession {
}
pub struct RealtimeWebrtcSessionHandle {
#[cfg(all(target_os = "macos", not(codex_bazel)))]
#[cfg(target_os = "macos")]
inner: native::SessionHandle,
local_audio_peak: Arc<AtomicU16>,
}
@@ -45,11 +45,11 @@ impl fmt::Debug for RealtimeWebrtcSessionHandle {
impl RealtimeWebrtcSessionHandle {
pub fn apply_answer_sdp(&self, answer_sdp: String) -> Result<()> {
#[cfg(all(target_os = "macos", not(codex_bazel)))]
#[cfg(target_os = "macos")]
{
self.inner.apply_answer_sdp(answer_sdp)
}
#[cfg(any(not(target_os = "macos"), codex_bazel))]
#[cfg(not(target_os = "macos"))]
{
let _ = answer_sdp;
Err(RealtimeWebrtcError::UnsupportedPlatform)
@@ -57,7 +57,7 @@ impl RealtimeWebrtcSessionHandle {
}
pub fn close(&self) {
#[cfg(all(target_os = "macos", not(codex_bazel)))]
#[cfg(target_os = "macos")]
self.inner.close();
}
@@ -70,7 +70,7 @@ pub struct RealtimeWebrtcSession;
impl RealtimeWebrtcSession {
pub fn start() -> Result<StartedRealtimeWebrtcSession> {
#[cfg(all(target_os = "macos", not(codex_bazel)))]
#[cfg(target_os = "macos")]
{
let started = native::start()?;
Ok(StartedRealtimeWebrtcSession {
@@ -82,7 +82,7 @@ impl RealtimeWebrtcSession {
events: started.events,
})
}
#[cfg(any(not(target_os = "macos"), codex_bazel))]
#[cfg(not(target_os = "macos"))]
{
Err(RealtimeWebrtcError::UnsupportedPlatform)
}
+2 -1
View File
@@ -1,4 +1,4 @@
load("//:defs.bzl", "codex_rust_crate")
load("//:defs.bzl", "MACOS_WEBRTC_RUSTC_LINK_FLAGS", "codex_rust_crate")
codex_rust_crate(
name = "tui",
@@ -23,4 +23,5 @@ codex_rust_crate(
extra_binaries = [
"//codex-rs/cli:codex",
],
rustc_flags_extra = MACOS_WEBRTC_RUSTC_LINK_FLAGS,
)