Browse Source

Merge branch 'circle-ci'

fixes
Andreas Linz 5 years ago
parent
commit
42abfd00ef
7 changed files with 80 additions and 32 deletions
  1. +0
    -12
      .travis.yml
  2. +3
    -0
      Cargo.toml
  3. +2
    -0
      README.md
  4. +47
    -18
      build.rs
  5. +16
    -0
      circle.yml
  6. +6
    -1
      tests/basic.rs
  7. +6
    -1
      tests/stream.rs

+ 0
- 12
.travis.yml View File

@ -1,12 +0,0 @@
language: rust
matrix:
include:
- env: CC_X=gcc-4.8 CXX_X=g++-4.8
os: linux
rust: stable
addons:
apt:
packages:
- gcc-4.8
allow_failures:
- rust: nightly

+ 3
- 0
Cargo.toml View File

@ -15,3 +15,6 @@ build = "build.rs"
[build-dependencies]
pkg-config = "0.3.7"
[dev-dependencies]
rci = "0.1.*"

+ 2
- 0
README.md View File

@ -1,5 +1,7 @@
# A Rusty Wrapper for [libsoundio](http://libsound.io)
[![Circle CI](https://circleci.com/gh/klingtnet/rsoundio.svg?style=svg)](https://circleci.com/gh/klingtnet/rsoundio)
Rsoundio is a wrapper for [libsoundio](https://github.com/andrewrk/libsoundio), a cross-platform realtime audio in- and output library.
The following backens are supported:

+ 47
- 18
build.rs View File

@ -4,6 +4,24 @@ use std::path::PathBuf;
use std::env;
use std::fs;
macro_rules! sio {
($expr:expr) => { format!("libsoundio-{}", $expr) }
}
macro_rules! err_exists {
($expr:expr, $msg:expr) => {
match $expr {
Ok(val) => val,
Err(err) => {
match err.kind() {
::std::io::ErrorKind::AlreadyExists => (),
_ => panic!(format!("{}: {}", $msg, err)),
}
}
}
}
}
fn lib_available(name: &str) -> bool {
match pkg_config::find_library(name) {
Ok(_) => true,
@ -49,49 +67,60 @@ fn main() {
}
}
const LIBSOUNDIO_TAR: &'static str = "http://libsound.io/release/libsoundio-1.1.0.tar.gz";
const LIBSOUNDIO_WIN: &'static str = "http://libsound.io/release/libsoundio-1.1.0.zip";
fn sio_url(ext: &'static str) -> String {
match ext {
"tar.gz" | "zip" => format!("http://libsound.io/release/{}.{}", sio!("1.1.0"), ext),
_ => panic!(format!("No release for format: {}", ext)),
}
}
fn build(target: String) {
let host = env::var("HOST").unwrap();
let dst_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let dst_root = format!("{}", &dst_dir.display());
let lib_dir = dst_dir.join("lib");
let include_dir = dst_dir.join("include");
err_exists!(fs::create_dir(&lib_dir), &lib_dir.display());
err_exists!(fs::create_dir(&include_dir), &include_dir.display());
// set cargo flags
println!("cargo:rustc-link-search={}/lib", &dst_root);
println!("cargo:rustc-link-lib=static={}", "soundio");
println!("cargo:include={}/include", &dst_root);
println!("cargo:root={}", &dst_root);
println!("cargo:rustc-link-lib=dylib={}", "soundio"); // -l
println!("cargo:rustc-link-search=native={}", &lib_dir.display()); // -L
println!("cargo:include={}", &include_dir.display());
println!("cargo:root={}", &dst_dir.display());
// download and extract libsoundio source
Command::new("curl")
.current_dir(&dst_dir)
.args(&["--location", "--remote-name"])
.arg(LIBSOUNDIO_TAR)
.arg(sio_url("tar.gz"))
.output()
.unwrap();
Command::new("tar")
.current_dir(&dst_dir)
.arg("-xvzf")
.arg("libsoundio-1.1.0.tar.gz")
.arg(format!("{}.{}", sio!("1.1.0"), "tar.gz"))
.output()
.unwrap();
// create build dir
let soundio_root = dst_dir.join("libsoundio-1.1.0");
let soundio_root = dst_dir.join(sio!("1.1.0"));
let build_dir = soundio_root.join("build");
fs::create_dir(&build_dir).unwrap();
err_exists!(fs::create_dir(&build_dir), &build_dir.display());
// TODO:set build type to release for env var PROFILE={release,bench}
// run cmake
Command::new("cmake")
.current_dir(&build_dir)
.env("CMAKE_BUILD_TYPE", "Release")
.env("CMAKE_INSTALL_LIBDIR", "lib")
.env("CMAKE_INSTALL_PREFIX", format!("{}", &dst_root))
.env("BUILD_EXAMPLE_PROGRAMS", "OFF")
.env("BUILD_TESTS", "OFF")
.env("BUILD_STATIC_LIBS", "ON")
.env("ENABLE_JACK", "OFF")
.arg("-DCMAKE_BUILD_TYPE=Debug")
.arg("-DCMAKE_INSTALL_LIBDIR:PATH=lib")
.arg(format!("-DCMAKE_INSTALL_PREFIX:PATH={}", &dst_dir.display()))
.arg("-DBUILD_EXAMPLE_PROGRAMS:BOOL=OFF")
.arg("-DBUILD_TESTS:BOOL=OFF")
.arg("-DBUILD_STATIC_LIBS:BOOL=OFF")
.arg("-DBUILD_SHARED_LIBS:BOOL=ON")
.arg("-DENABLE_JACK:BOOL=OFF")
.arg("-DENABLE_PULSEAUDIO:BOOL=OFF")
.arg("-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON")
.arg("..")
.output()
.unwrap();

+ 16
- 0
circle.yml View File

@ -0,0 +1,16 @@
dependencies:
post:
- sudo apt-get install -y alsa-base
- curl -Lsf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes
- multirust default stable
test:
pre:
- >
eval $(ssh-agent) &&
ssh-add /home/ubuntu/.ssh/id_circleci_github &&
cargo build
override:
- >
eval $(ssh-agent) &&
ssh-add /home/ubuntu/.ssh/id_circleci_github &&
LD_LIBRARY_PATH="$(dirname $(find -iname libsoundio.so.1))" cargo test

+ 6
- 1
tests/basic.rs View File

@ -1,11 +1,16 @@
extern crate rsoundio;
extern crate rci;
use rci::Ci;
#[test]
fn test_soundio() {
if Ci::new().is_some() {
return
}
let sio = rsoundio::SoundIo::new();
assert!(sio.backend_count() > 0);
assert!(sio.backend(0).is_some());
assert!(sio.backend(-1).is_none());
sio.connect().unwrap();
sio.disconnect();
if sio.have_backend(rsoundio::SioBackend::Alsa) {

+ 6
- 1
tests/stream.rs View File

@ -1,10 +1,16 @@
extern crate rsoundio;
extern crate rci;
use rci::Ci;
use std::thread;
use std::time::Duration;
#[test]
fn test_outstream() {
if Ci::new().is_some() {
return
}
let sio = rsoundio::SoundIo::new();
sio.connect_backend(rsoundio::SioBackend::Dummy).unwrap();
let current_backend = sio.current_backend().unwrap();
@ -45,5 +51,4 @@ fn test_outstream() {
assert!(stream.clear_buffer().is_none());
thread::sleep(Duration::new(1, 0));
stream.destroy();
dev.dec_ref();
}

Loading…
Cancel
Save