From 4240b126411cf0bab25129b31dd96ed0d6b97856 Mon Sep 17 00:00:00 2001 From: Ryo Kawaguchi Date: Fri, 5 Jun 2020 22:27:42 +0900 Subject: [PATCH 1/2] Set --host flag for autotools to support cross compilation. --- webrtc-audio-processing-sys/build.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/webrtc-audio-processing-sys/build.rs b/webrtc-audio-processing-sys/build.rs index 734aa1a..c5c2094 100644 --- a/webrtc-audio-processing-sys/build.rs +++ b/webrtc-audio-processing-sys/build.rs @@ -63,6 +63,16 @@ mod webrtc { Ok((include_path, lib_path)) } + fn get_target() -> String { + let target = std::env::var("TARGET").unwrap(); + let mut target_tuple = target.split("-").collect::>(); + // Remove the vendor component. + target_tuple.remove(1); + + assert_eq!(3, target_tuple.len()); + target_tuple.join("-") + } + fn copy_source_to_out_dir() -> Result { use fs_extra::dir::CopyOptions; @@ -93,6 +103,7 @@ mod webrtc { .cxxflag("-fPIC") .disable_shared() .enable_static() + .host(&get_target()) .build(); Ok(()) From 3700d721d50604d3127de2bf2b3ccaad1924401b Mon Sep 17 00:00:00 2001 From: Jen Tak Date: Wed, 6 Dec 2023 11:11:06 +0100 Subject: [PATCH 2/2] Document cross compilation --- webrtc-audio-processing-sys/README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/webrtc-audio-processing-sys/README.md b/webrtc-audio-processing-sys/README.md index dc80864..4db8ac6 100644 --- a/webrtc-audio-processing-sys/README.md +++ b/webrtc-audio-processing-sys/README.md @@ -1,4 +1,5 @@ # webrtc-audio-processing-sys + [![Crates.io](https://img.shields.io/crates/v/webrtc-audio-processing-sys.svg)](https://crates.io/crates/webrtc-audio-processing-sys) [![Docs.rs](https://docs.rs/webrtc-audio-processing-sys/badge.svg)](https://docs.rs/webrtc-audio-processing-sys) [![Build Status](https://travis-ci.org/tonarino/webrtc-audio-processing.svg?branch=master)](https://travis-ci.org/tonarino/webrtc-audio-processing) @@ -21,11 +22,20 @@ sudo apt install webrtc-audio-processing-dev # Ubuntu/Debian sudo pacman -S webrtc-audio-processing # Arch ``` +### Cross compilation + +When cross-compiling make sure you have the corresponding rust toolchain installed +with `rustup target add ` and then run + +```sh +PKG_CONFIG_SYSROOT_DIR=/ cargo build --target +``` + ### Static linking Static linking can be enabled with the `bundled` feature flag. The following tools are needed in order to use the `bundled` feature flag: -* libtool (`$ sudo apt install libtool`) -* autotools (`$ sudo apt install autotools-dev`) +- libtool (`$ sudo apt install libtool`) +- autotools (`$ sudo apt install autotools-dev`)