Skip to content

Commit

Permalink
fix: docs.rs builds (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Sep 23, 2023
1 parent 3e4669e commit 3573026
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<!--BEGIN_DESCRIPTION-->Use this SDK to add real-time video, audio and data features to your Rust app. By connecting to a self- or cloud-hosted <a href="https://livekit.io/">LiveKit</a> server, you can quickly build applications like interactive live streaming or video calls with just a few lines of code.<!--END_DESCRIPTION-->

[![crates.io](https://img.shields.io/crates/v/livekit.svg)](https://crates.io/crates/livekit)
[![livekit docs.rs](https://img.shields.io/docsrs/livekit)](https://docs.rs/livekit/latest/)
[![livekit-api docs.rs](https://img.shields.io/docsrs/livekit-api)](https://docs.rs/livekit-api/latest/)
[![livekit-webrtc docs.rs](https://img.shields.io/docsrs/livekit-webrtc)](https://docs.rs/livekit-webrtc/latest/)
[![Builds](https://github.com/livekit/client-sdk-native/actions/workflows/builds.yml/badge.svg?branch=main)](https://github.com/livekit/client-sdk-native/actions/workflows/builds.yml)
[![Tests](https://github.com/livekit/client-sdk-native/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/livekit/client-sdk-native/actions/workflows/tests.yml)

Expand Down
4 changes: 4 additions & 0 deletions livekit-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
use std::env;

fn main() {
if env::var("DOCS_RS").is_ok() {
return;
}

if env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" {
webrtc_sys_build::configure_jni_symbols().unwrap();
}
Expand Down
42 changes: 23 additions & 19 deletions webrtc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ use std::path;
use std::process::Command;

fn main() {
if env::var("DOCS_RS").is_ok() {
return;
}

println!("cargo:rerun-if-env-changed=LK_DEBUG_WEBRTC");
println!("cargo:rerun-if-env-changed=LK_CUSTOM_WEBRTC");

let webrtc_dir = webrtc_sys_build::webrtc_dir();
let webrtc_include = webrtc_dir.join("include");
let webrtc_lib = webrtc_dir.join("lib");

if !webrtc_dir.exists() {
webrtc_sys_build::download_webrtc().unwrap();
}

let mut builder = cxx_build::bridges([
"src/peer_connection.rs",
"src/peer_connection_factory.rs",
Expand All @@ -53,17 +49,6 @@ fn main() {
"src/android.rs",
]);

builder.includes(&[
path::PathBuf::from("./include"),
webrtc_include.clone(),
webrtc_include.join("third_party/abseil-cpp/"),
webrtc_include.join("third_party/libyuv/include/"),
webrtc_include.join("third_party/libc++/"),
// For mac & ios
webrtc_include.join("sdk/objc"),
webrtc_include.join("sdk/objc/base"),
]);

builder.files(&[
"src/peer_connection.cpp",
"src/peer_connection_factory.cpp",
Expand All @@ -89,6 +74,25 @@ fn main() {
"src/frame_cryptor.cpp",
]);

let webrtc_dir = webrtc_sys_build::webrtc_dir();
let webrtc_include = webrtc_dir.join("include");
let webrtc_lib = webrtc_dir.join("lib");

if !webrtc_dir.exists() {
webrtc_sys_build::download_webrtc().unwrap();
}

builder.includes(&[
path::PathBuf::from("./include"),
webrtc_include.clone(),
webrtc_include.join("third_party/abseil-cpp/"),
webrtc_include.join("third_party/libyuv/include/"),
webrtc_include.join("third_party/libc++/"),
// For mac & ios
webrtc_include.join("sdk/objc"),
webrtc_include.join("sdk/objc/base"),
]);

println!(
"cargo:rustc-link-search=native={}",
webrtc_lib.to_str().unwrap()
Expand Down

0 comments on commit 3573026

Please sign in to comment.