allow custom webrtc builds (#21)
This commit is contained in:
+20
-13
@@ -13,8 +13,8 @@ const WEBRTC_TAG: &str = "m104.5112.06";
|
|||||||
fn download_prebuilt(
|
fn download_prebuilt(
|
||||||
target_os: &str,
|
target_os: &str,
|
||||||
target_arch: &str,
|
target_arch: &str,
|
||||||
out_path: std::path::PathBuf,
|
out_path: path::PathBuf,
|
||||||
) -> Result<std::path::PathBuf, Box<dyn std::error::Error>> {
|
) -> Result<path::PathBuf, Box<dyn std::error::Error>> {
|
||||||
let target_arch = match target_arch {
|
let target_arch = match target_arch {
|
||||||
"aarch64" => "arm64",
|
"aarch64" => "arm64",
|
||||||
_ => target_arch,
|
_ => target_arch,
|
||||||
@@ -96,20 +96,27 @@ fn download_prebuilt(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Download the prebuilt WebRTC library.
|
|
||||||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||||
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
|
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||||
let install_directory = env::var("OUT_DIR").unwrap() + "/webrtc-sdk";
|
|
||||||
|
|
||||||
let webrtc_dir = download_prebuilt(
|
let use_custom_webrtc = {
|
||||||
&target_os,
|
let var = env::var("LK_CUSTOM_WEBRTC");
|
||||||
&target_arch,
|
var.is_ok() && var.unwrap() == "true"
|
||||||
path::PathBuf::from(install_directory),
|
};
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let webrtc_include = webrtc_dir.join("include");
|
let (webrtc_include, webrtc_lib) = if use_custom_webrtc {
|
||||||
let webrtc_lib = webrtc_dir.join("lib");
|
// Use a local WebRTC version (libwebrtc folder)
|
||||||
|
let webrtc_dir = path::PathBuf::from("./libwebrtc");
|
||||||
|
(webrtc_dir.join("src"), webrtc_dir.join("src/out/Dev/obj"))
|
||||||
|
} else {
|
||||||
|
// Download a prebuilt version of WebRTC
|
||||||
|
let download_dir = env::var("OUT_DIR").unwrap() + "/webrtc-sdk";
|
||||||
|
let webrtc_dir =
|
||||||
|
download_prebuilt(&target_os, &target_arch, path::PathBuf::from(download_dir)).unwrap();
|
||||||
|
|
||||||
|
(webrtc_dir.join("include"), webrtc_dir.join("lib"))
|
||||||
|
};
|
||||||
|
println!("cargo:rerun-if-env-changed=LK_CUSTOM_WEBRTC");
|
||||||
|
|
||||||
// Just required for the bridge build to succeed.
|
// Just required for the bridge build to succeed.
|
||||||
let includes = &[
|
let includes = &[
|
||||||
@@ -271,7 +278,7 @@ fn main() {
|
|||||||
println!("cargo:rustc-link-lib=OpenSLES");
|
println!("cargo:rustc-link-lib=OpenSLES");
|
||||||
|
|
||||||
// Find JNI symbols
|
// Find JNI symbols
|
||||||
let readelf_output = std::process::Command::new(toolchain.join("bin/llvm-readelf"))
|
let readelf_output = Command::new(toolchain.join("bin/llvm-readelf"))
|
||||||
.arg("-Ws")
|
.arg("-Ws")
|
||||||
.arg(webrtc_lib.join("/libwebrtc.a"))
|
.arg(webrtc_lib.join("/libwebrtc.a"))
|
||||||
.output()
|
.output()
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
GN_ARGS = [
|
GN_ARGS = [
|
||||||
"is_debug=false",
|
"is_debug=true",
|
||||||
"treat_warnings_as_errors=false",
|
"treat_warnings_as_errors=false",
|
||||||
'target_os="win"',
|
'target_os="mac"',
|
||||||
'target_cpu="x64"',
|
'target_cpu="arm64"',
|
||||||
"rtc_include_tests=false",
|
"rtc_include_tests=false",
|
||||||
"rtc_use_h264=false",
|
"rtc_use_h264=false",
|
||||||
"is_component_build=false",
|
"is_component_build=false",
|
||||||
@@ -12,8 +13,8 @@ GN_ARGS = [
|
|||||||
"use_rtti=true",
|
"use_rtti=true",
|
||||||
"rtc_build_tools=false",
|
"rtc_build_tools=false",
|
||||||
"use_custom_libcxx=false",
|
"use_custom_libcxx=false",
|
||||||
"strip_debug_info=true",
|
|
||||||
"symbol_level=0"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
subprocess.call(["gn", "gen", "out/Default", "--args=" + ' '.join(GN_ARGS)], shell=True)
|
cmd = ["gn", "gen", "out/Dev", "--args=" + ' '.join(GN_ARGS)]
|
||||||
|
print("Executing:", cmd)
|
||||||
|
subprocess.call(cmd, shell=platform.system() == "Windows")
|
||||||
Reference in New Issue
Block a user