Skip to content

Commit

Permalink
Support linking an external build (#11)
Browse files Browse the repository at this point in the history
* Support linking an external build
  • Loading branch information
Ralith authored Oct 19, 2021
1 parent 49001f0 commit 6c8dfba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Bindings to [libopus](https://github.com/xiph/opus)

Target version [1.3.1](https://github.com/xiph/opus/releases/tag/v1.3.1)

## Setup

If the `OPUS_LIB_DIR` environment variable is set, it will be searched for the opus
library. Otherwise, a static library will be built automatically.

## Android build

When building for android, library requires presence of env variable `ANDROID_NDK_HOME` in order to supply
Expand Down
9 changes: 8 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,14 @@ fn build() {
fn run() {
generate_lib();

build();
println!("cargo:rerun-if-env-changed=OPUS_LIB_DIR");
if let Ok(dir) = std::env::var("OPUS_LIB_DIR") {
assert!(std::path::Path::new(&dir).exists(), "OPUS_LIB_DIR ({}) does not exist!", dir);
println!("cargo:rustc-link-search={}", dir);
println!("cargo:rustc-link-lib=opus");
} else {
build();
}
}

fn main() {
Expand Down

0 comments on commit 6c8dfba

Please sign in to comment.