Skip to content

Commit

Permalink
update portaudio (#190)
Browse files Browse the repository at this point in the history
* update portaudio

can't use a modern static portaudio via pkg_config because of rust-lang/pkg-config-rs#102

* allow passing extra args to portaudio configure

---------

Co-authored-by: Dan <daniel@foresightanalytics.ca>
  • Loading branch information
dansgithubuser and Dan authored May 5, 2024
1 parent 9b7dfad commit b494038
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions rust-portaudio-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");

println!("cargo:rerun-if-env-changed=PORTAUDIO_ONLY_STATIC");
println!("cargo:rerun-if-env-changed=PORTAUDIO_CONFIGURE_EXTRA_ARGS");
if env::var("PORTAUDIO_ONLY_STATIC").is_err() {
// If pkg-config finds a library on the system, we are done
if pkg_config::Config::new().atleast_version("19").find("portaudio-2.0").is_ok() {
Expand Down Expand Up @@ -83,8 +84,8 @@ mod unix_platform {

use super::{err_to_panic, run};

pub const PORTAUDIO_URL: &'static str = "http://www.portaudio.com/archives/pa_stable_v19_20140130.tgz";
pub const PORTAUDIO_TAR: &'static str = "pa_stable_v19_20140130.tgz";
pub const PORTAUDIO_URL: &'static str = "https://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz";
pub const PORTAUDIO_TAR: &'static str = "pa_stable_v190700_20210406.tgz";
pub const PORTAUDIO_FOLDER: &'static str = "portaudio";

pub fn download() {
Expand All @@ -99,10 +100,15 @@ mod unix_platform {
err_to_panic(env::set_current_dir(PORTAUDIO_FOLDER));

// run portaudio autoconf
run(Command::new("./configure")
let mut cmd = Command::new("./configure");
cmd
.args(&["--disable-shared", "--enable-static"]) // Only build static lib
.args(&["--prefix", out_dir.to_str().unwrap()]) // Install on the outdir
.arg("--with-pic")); // Build position-independent code (required by Rust)
.arg("--with-pic"); // Build position-independent code (required by Rust)
if let Ok(extra_args) = env::var("PORTAUDIO_CONFIGURE_EXTRA_ARGS") {
cmd.args(extra_args.split(" "));
}
run(&mut cmd);

// then make
run(&mut Command::new("make"));
Expand Down

0 comments on commit b494038

Please sign in to comment.