From 4400a15e5014f0a5f4ee1fc48522a2051b524d40 Mon Sep 17 00:00:00 2001 From: Polochon-street Date: Wed, 26 Feb 2020 17:47:34 +0100 Subject: [PATCH 1/3] Change the block extracting the extralib flags FFmpeg now uses `EXTRALIB-avcodec=...`, etc instead of `EXTRALIBS=...` that was used in 3.X, thus making the previous parsing foobar. This should fix it. --- build.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 45f7e463..0f1001e3 100644 --- a/build.rs +++ b/build.rs @@ -514,18 +514,25 @@ fn main() { } // Check additional required libraries. + // Flags are now of the type `EXTRALIBS-avcodec` { let config_mak = source().join("ffbuild/config.mak"); let file = File::open(config_mak).unwrap(); let reader = BufReader::new(file); let extra_libs = reader .lines() - .find(|ref line| line.as_ref().unwrap().starts_with("EXTRALIBS")) + .filter(|ref line| line.as_ref().unwrap().starts_with("EXTRALIBS")) .map(|line| line.unwrap()) - .unwrap(); - - let linker_args = extra_libs.split('=').last().unwrap().split(' '); + .collect::>(); + let mut linker_args = extra_libs + .iter() + .flat_map(|line| line.split('=').last().unwrap().split(' ')) + .collect::>(); + + linker_args.sort(); + linker_args.dedup(); let include_libs = linker_args + .iter() .filter(|v| v.starts_with("-l")) .map(|flag| &flag[2..]); From 4be44c98311f8b2edce2cd3d71888c3532a74156 Mon Sep 17 00:00:00 2001 From: Polochon-street Date: Wed, 26 Feb 2020 22:10:54 +0100 Subject: [PATCH 2/3] Fix Travis build --- .travis.yml | 8 ++------ .travis/install_linux.sh | 4 ++-- build.rs | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7e14d5a..3a673a14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,20 +14,16 @@ addons: apt: packages: - build-essential +dist: bionic before_install: - 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 + - rustup component add rustfmt script: | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - # Current Travis Ubuntu version uses libav which doesn't come with libswresample - cargo build --verbose --no-default-features --features "avcodec avfilter avformat avresample swscale" && - cargo test --verbose --no-default-features --features "avcodec avfilter avformat avresample swscale" - else travis_wait cargo build --verbose --features "build" cargo test --verbose --features "build" - fi after_failure: - find /usr -type f 2>/dev/null | grep -E 'lib(avcodec/version|avcodec/avcodec).h$' | xargs -I THEFILE -- sh -c 'echo "=== THEFILE ==="; cat THEFILE' diff --git a/.travis/install_linux.sh b/.travis/install_linux.sh index 96dc5ec3..32e2680b 100755 --- a/.travis/install_linux.sh +++ b/.travis/install_linux.sh @@ -7,10 +7,10 @@ sudo apt-get install yasm pushd ~ git clone https://github.com/FFmpeg/FFmpeg.git cd FFmpeg -git checkout release/3.2 +git checkout release/4.2 mkdir ~/FFmpeg-build cd ~/FFmpeg-build -../FFmpeg/configure --disable-ffprobe --disable-ffserver --disable-doc --enable-avresample +../FFmpeg/configure --disable-ffprobe --disable-ffserver --disable-doc make -j sudo make install make distclean diff --git a/build.rs b/build.rs index 0f1001e3..ac6357fe 100644 --- a/build.rs +++ b/build.rs @@ -947,6 +947,8 @@ fn main() { .rustified_enum("*") .prepend_enum_name(false) .derive_eq(true) + // Otherwise bindgen is confused with multiline comments + .generate_comments(false) .parse_callbacks(Box::new(IntCallbacks)); // The input headers we would like to generate From f66dc36afd5732231843b1bddbbd3c13b4bf0bc0 Mon Sep 17 00:00:00 2001 From: Polochon-street Date: Fri, 28 Feb 2020 11:33:14 +0100 Subject: [PATCH 3/3] Review fixes --- .travis.yml | 2 +- .travis/install_linux.sh | 17 ----------------- build.rs | 11 +++++------ 3 files changed, 6 insertions(+), 24 deletions(-) delete mode 100755 .travis/install_linux.sh diff --git a/.travis.yml b/.travis.yml index 3a673a14..884cdb03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ addons: - build-essential dist: bionic before_install: - - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then ./.travis/install_linux.sh; fi + - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get install yasm; fi - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew update; fi - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install yasm; fi - rustup component add rustfmt diff --git a/.travis/install_linux.sh b/.travis/install_linux.sh deleted file mode 100755 index 32e2680b..00000000 --- a/.travis/install_linux.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -sudo apt-get update -q -# From https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu -sudo apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev -sudo apt-get install yasm -pushd ~ -git clone https://github.com/FFmpeg/FFmpeg.git -cd FFmpeg -git checkout release/4.2 -mkdir ~/FFmpeg-build -cd ~/FFmpeg-build -../FFmpeg/configure --disable-ffprobe --disable-ffserver --disable-doc -make -j -sudo make install -make distclean -popd diff --git a/build.rs b/build.rs index ac6357fe..bee2303f 100644 --- a/build.rs +++ b/build.rs @@ -4,6 +4,7 @@ extern crate num_cpus; extern crate pkg_config; extern crate regex; +use std::collections::HashSet; use std::env; use std::fs::{self, File}; use std::io::{self, BufRead, BufReader, Write}; @@ -521,16 +522,14 @@ fn main() { let reader = BufReader::new(file); let extra_libs = reader .lines() - .filter(|ref line| line.as_ref().unwrap().starts_with("EXTRALIBS")) - .map(|line| line.unwrap()) + .filter_map(Result::ok) + .filter(|line| line.starts_with("EXTRALIBS")) .collect::>(); - let mut linker_args = extra_libs + let linker_args = extra_libs .iter() .flat_map(|line| line.split('=').last().unwrap().split(' ')) - .collect::>(); + .collect::>(); - linker_args.sort(); - linker_args.dedup(); let include_libs = linker_args .iter() .filter(|v| v.starts_with("-l"))