Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Fix builds on Rust 1.39 #80

Merged
merged 4 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ addons:
packages:
- build-essential
before_install:
# Without rustfmt, bindgen puts everything on one line and any warnings dump so many logs they break Travis
# See https://github.com/rust-lang/rust-bindgen/issues/1600
- rustup component add rustfmt
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then ./.travis/install_linux.sh; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew update; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install yasm; fi
Expand Down
12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ description = "FFI bindings to FFmpeg"
repository = "https://github.com/meh/rust-ffmpeg-sys"
keywords = ["audio", "video"]

[lib]
# Disable doctests as a workaround for https://github.com/rust-lang/rust-bindgen/issues/1313
doctest = false

[dependencies]
libc = "0.2"

[build-dependencies]
num_cpus = "1.0"
cc = "1.0"
num_cpus = "1.11"
cc = "1.0"
pkg-config = "0.3"
bindgen = "0.32"
regex = "0.2"
bindgen = "0.51.1"
regex = "1.3"

[features]
default = ["avcodec", "avdevice", "avfilter", "avformat", "swresample", "swscale"]
Expand Down
42 changes: 23 additions & 19 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::process::Command;
use std::str;

use regex::Regex;
use bindgen::callbacks::{IntKind, ParseCallbacks};
use bindgen::callbacks::{IntKind, ParseCallbacks, MacroParsingBehavior};

#[derive(Debug)]
struct Library {
Expand Down Expand Up @@ -71,6 +71,20 @@ impl ParseCallbacks for IntCallbacks {
None
}
}

// https://github.com/rust-lang/rust-bindgen/issues/687#issuecomment-388277405
fn will_parse_macro(&self, name: &str) -> MacroParsingBehavior {
use MacroParsingBehavior::*;

match name {
"FP_INFINITE" => Ignore,
"FP_NAN" => Ignore,
"FP_NORMAL" => Ignore,
"FP_SUBNORMAL" => Ignore,
"FP_ZERO" => Ignore,
_ => Default,
}
}
}

fn version() -> String {
Expand Down Expand Up @@ -103,16 +117,14 @@ fn search() -> PathBuf {
}

fn fetch() -> io::Result<()> {
let status = try!(
Command::new("git")
let status = Command::new("git")
.current_dir(&output())
.arg("clone")
.arg("-b")
.arg(format!("release/{}", version()))
.arg("https://github.com/FFmpeg/FFmpeg")
.arg(format!("ffmpeg-{}", version()))
.status()
);
.status()?;

if status.success() {
Ok(())
Expand Down Expand Up @@ -267,24 +279,22 @@ fn build() -> io::Result<()> {
}

// run make
if !try!(
Command::new("make")
if !Command::new("make")
.arg("-j")
.arg(num_cpus::get().to_string())
.current_dir(&source())
.status()
).success()
.status()?
.success()
{
return Err(io::Error::new(io::ErrorKind::Other, "make failed"));
}

// run make install
if !try!(
Command::new("make")
if !Command::new("make")
.current_dir(&source())
.arg("install")
.status()
).success()
.status()?
.success()
{
return Err(io::Error::new(io::ErrorKind::Other, "make install failed"));
}
Expand Down Expand Up @@ -902,12 +912,6 @@ fn main() {
let mut builder = bindgen::Builder::default()
.clang_args(clang_includes)
.ctypes_prefix("libc")
// https://github.com/servo/rust-bindgen/issues/687
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
// https://github.com/servo/rust-bindgen/issues/550
.blacklist_type("max_align_t")
.rustified_enum("*")
Expand Down