-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Wire realtime WebRTC native media into Bazel #17145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c0c3e58
codex: wire WebRTC media into Bazel
aibrahim-oai a0d20ef
Merge branch 'main' into realtime-webrtc-bazel-native
aibrahim-oai ecf380b
Fix WebRTC Bazel CI setup
aibrahim-oai 1ebc9d1
Export WebRTC sys Bazel patch
aibrahim-oai a436e60
Fix WebRTC sys patch hunk header
aibrahim-oai 7fbbc4b
Retarget WebRTC sys patch to crate root
aibrahim-oai 62678ac
Use Bazel CC for WebRTC sys search dirs
aibrahim-oai 0268bc4
Minimize WebRTC sys build script patch context
aibrahim-oai 27fd108
Add macOS framework path for WebRTC sys
aibrahim-oai 1fc3029
hi
aibrahim-oai 8950b3d
Expose WebRTC Apple frameworks to Bazel
aibrahim-oai af46e10
Add WebRTC link flags to cloud tasks Bazel target
aibrahim-oai 8a52ff9
Expose nested AVFAudio framework to Bazel
aibrahim-oai a4df77a
Fix WebRTC sys hermetic macOS SDK build
aibrahim-oai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| diff --git a/build.rs b/build.rs | ||
| index 3b4a24a..6aa06ff 100644 | ||
| --- a/build.rs | ||
| +++ b/build.rs | ||
| @@ -15,1 +15,2 @@ | ||
| -use std::path::Path; | ||
| +use std::fs; | ||
| +use std::path::Path; | ||
| @@ -118,1 +119,9 @@ | ||
| - println!("cargo:rustc-link-search=native={}", webrtc_lib.to_str().unwrap()); | ||
| + let webrtc_link_lib = if env::var_os("WEBRTC_SYS_LINK_OUT_DIR").is_some() { | ||
| + let out_lib = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("lib"); | ||
| + fs::create_dir_all(&out_lib).unwrap(); | ||
| + fs::copy(webrtc_lib.join("libwebrtc.a"), out_lib.join("libwebrtc.a")).unwrap(); | ||
| + out_lib | ||
| + } else { | ||
| + webrtc_lib | ||
| + }; | ||
| + println!("cargo:rustc-link-search=native={}", webrtc_link_lib.to_str().unwrap()); | ||
| @@ -255,1 +264,1 @@ | ||
| - println!("cargo:rustc-link-lib=framework=Appkit"); | ||
| + println!("cargo:rustc-link-lib=framework=AppKit"); | ||
| @@ -320,1 +329,18 @@ | ||
| - builder.warnings(false).compile("webrtcsys-cxx"); | ||
| + builder.warnings(false).compile("webrtcsys-cxx"); | ||
| + let cxxbridge_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("cxxbridge"); | ||
| + let cxx_header = cxxbridge_dir.join("include/rust/cxx.h"); | ||
| + if fs::symlink_metadata(&cxx_header) | ||
| + .is_ok_and(|metadata| metadata.file_type().is_symlink()) | ||
| + { | ||
| + if let Ok(header) = fs::read(&cxx_header) { | ||
| + fs::remove_file(&cxx_header).unwrap(); | ||
| + fs::write(&cxx_header, header).unwrap(); | ||
| + } | ||
| + } | ||
| + let crate_link = cxxbridge_dir.join("crate/webrtc-sys"); | ||
| + if fs::symlink_metadata(&crate_link) | ||
| + .is_ok_and(|metadata| metadata.file_type().is_symlink()) | ||
| + { | ||
| + fs::remove_file(crate_link).unwrap(); | ||
| + } | ||
| + | ||
| @@ -375,1 +384,3 @@ | ||
| - println!("cargo:rustc-link-lib={}", clang_rt); | ||
| + if env::var_os("WEBRTC_SYS_LINK_OUT_DIR").is_none() { | ||
| + println!("cargo:rustc-link-lib={}", clang_rt); | ||
| + } | ||
| @@ -378,6 +389,21 @@ | ||
| - let sysroot = Command::new("xcrun").args(["--sdk", sdk, "--show-sdk-path"]).output().unwrap(); | ||
| - | ||
| - let sysroot = String::from_utf8_lossy(&sysroot.stdout); | ||
| - let sysroot = sysroot.trim(); | ||
| - | ||
| - let search_dirs = Command::new("cc").arg("--print-search-dirs").output().unwrap(); | ||
| + let sysroot = env::var("WEBRTC_SYS_DARWIN_SDK_PATH").unwrap_or_else(|_| { | ||
| + let output = Command::new("xcrun") | ||
| + .args(["--sdk", sdk, "--show-sdk-path"]) | ||
| + .output() | ||
| + .unwrap(); | ||
| + String::from_utf8_lossy(&output.stdout).into_owned() | ||
| + }); | ||
| + | ||
| + let sysroot = sysroot.as_str(); | ||
| + let sysroot = sysroot.trim(); | ||
| + builder.flag(format!("-F{sysroot}/System/Library/Frameworks")); | ||
| + builder.define("__APPLICATIONSERVICES__", None); | ||
| + builder.flag("-include"); | ||
| + builder.flag("CoreGraphics/CoreGraphics.h"); | ||
| + builder.include(format!("{sysroot}/usr/include")); | ||
| + | ||
| + let cc = env::var("CC").unwrap_or_else(|_| "cc".to_string()); | ||
| + let search_dirs = Command::new(cc) | ||
| + .arg("--print-search-dirs") | ||
| + .output() | ||
| + .unwrap(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.