mirror of
https://github.com/encounter/rust-ffmpeg.git
synced 2026-07-10 21:18:39 -07:00
cargo: update build
This commit is contained in:
+54
-1
@@ -17,12 +17,65 @@ libc = "*"
|
||||
default = ["avcodec", "avdevice", "avfilter", "avformat", "avresample", "swresample", "swscale"]
|
||||
|
||||
static = []
|
||||
build = ["static"]
|
||||
|
||||
build = ["static"]
|
||||
# licensing
|
||||
build-gpl = ["build"]
|
||||
build-nonfree = ["build"]
|
||||
build-version3 = ["build"]
|
||||
|
||||
# ssl
|
||||
build-lib-gnutls = ["build"]
|
||||
build-lib-openssl = ["build"]
|
||||
|
||||
# filters
|
||||
build-lib-fontconfig = ["build"]
|
||||
build-lib-frei0r = ["build"]
|
||||
build-lib-ladspa = ["build"]
|
||||
build-lib-ass = ["build"]
|
||||
build-lib-freetype = ["build"]
|
||||
build-lib-freebidi = ["build"]
|
||||
build-lib-opencv = ["build"]
|
||||
|
||||
# encoders/decoders
|
||||
build-lib-aacplus = ["build"]
|
||||
build-lib-celt = ["build"]
|
||||
build-lib-dcadec = ["build"]
|
||||
build-lib-faac = ["build"]
|
||||
build-lib-fdk-aac = ["build"]
|
||||
build-lib-gsm = ["build"]
|
||||
build-lib-ilbc = ["build"]
|
||||
build-lib-kvazaar = ["build"]
|
||||
build-lib-mp3lame = ["build"]
|
||||
build-lib-opencore-amrnb = ["build"]
|
||||
build-lib-opencore-amrwb = ["build"]
|
||||
build-lib-openh264 = ["build"]
|
||||
build-lib-openjpeg = ["build"]
|
||||
build-lib-opus = ["build"]
|
||||
build-lib-schroedinger = ["build"]
|
||||
build-lib-shine = ["build"]
|
||||
build-lib-snappy = ["build"]
|
||||
build-lib-speex = ["build"]
|
||||
build-lib-stagefright-h264 = ["build"]
|
||||
build-lib-theora = ["build"]
|
||||
build-lib-twolame = ["build"]
|
||||
build-lib-utvideo = ["build"]
|
||||
build-lib-vo-aacenc = ["build"]
|
||||
build-lib-vo-amrwbenc = ["build"]
|
||||
build-lib-vorbis = ["build"]
|
||||
build-lib-vpx = ["build"]
|
||||
build-lib-wavpack = ["build"]
|
||||
build-lib-webp = ["build"]
|
||||
build-lib-x264 = ["build"]
|
||||
build-lib-x265 = ["build"]
|
||||
build-lib-avs = ["build"]
|
||||
build-lib-xvid = ["build"]
|
||||
|
||||
# protocols
|
||||
build-lib-smbclient = ["build"]
|
||||
build-lib-ssh = ["build"]
|
||||
|
||||
# components
|
||||
avcodec = []
|
||||
avdevice = ["avformat"]
|
||||
avfilter = []
|
||||
|
||||
+88
-100
@@ -99,132 +99,120 @@ fn build() -> io::Result<()> {
|
||||
configure.arg("--enable-static");
|
||||
configure.arg("--disable-shared");
|
||||
|
||||
// the binary using ffmpeg-sys must comply with GPL
|
||||
if env::var("CARGO_FEATURE_BUILD_GPL").is_ok() {
|
||||
configure.arg("--enable-gpl");
|
||||
}
|
||||
|
||||
// the binary using ffmpeg-sys must comply with (L)GPLv3
|
||||
if env::var("CARGO_FEATURE_BUILD_VERSION3").is_ok() {
|
||||
configure.arg("--enable-version3");
|
||||
}
|
||||
|
||||
// the binary using ffmpeg-sys cannot be redistributed
|
||||
if env::var("CARGO_FEATURE_BUILD_NONFREE").is_ok() {
|
||||
configure.arg("--enable-nonfree");
|
||||
}
|
||||
|
||||
// do not build programs since we don't need them
|
||||
configure.arg("--disable-programs");
|
||||
|
||||
// disable/enable building libraries based on features
|
||||
if env::var("CARGO_FEATURE_AVCODEC").is_ok() {
|
||||
configure.arg("--enable-avcodec");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-avcodec");
|
||||
macro_rules! switch {
|
||||
($conf:expr, $feat:expr, $name:expr) => (
|
||||
if env::var(concat!("CARGO_FEATURE_", $feat)).is_ok() {
|
||||
$conf.arg(concat!("--enable-", $name));
|
||||
}
|
||||
else {
|
||||
$conf.arg(concat!("--disable-", $name));
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if env::var("CARGO_FEATURE_AVDEVICE").is_ok() {
|
||||
configure.arg("--enable-avdevice");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-avdevice");
|
||||
macro_rules! enable {
|
||||
($conf:expr, $feat:expr, $name:expr) => (
|
||||
if env::var(concat!("CARGO_FEATURE_", $feat)).is_ok() {
|
||||
$conf.arg(concat!("--enable-", $name));
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if env::var("CARGO_FEATURE_AVFILTER").is_ok() {
|
||||
configure.arg("--enable-avfilter");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-avfilter");
|
||||
macro_rules! disable {
|
||||
($conf:expr, $feat:expr, $name:expr) => (
|
||||
if env::var(concat!("CARGO_FEATURE_", $feat)).is_err() {
|
||||
$conf.arg(concat!("--disable-", $name));
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if env::var("CARGO_FEATURE_AVFORMAT").is_ok() {
|
||||
configure.arg("--enable-avformat");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-avformat");
|
||||
}
|
||||
// the binary using ffmpeg-sys must comply with GPL
|
||||
switch!(configure, "BUILD_GPL", "gpl");
|
||||
|
||||
if env::var("CARGO_FEATURE_AVRESAMPLE").is_ok() {
|
||||
configure.arg("--enable-avresample");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-avresample");
|
||||
}
|
||||
// the binary using ffmpeg-sys must comply with (L)GPLv3
|
||||
switch!(configure, "BUILD_VERSION3", "version3");
|
||||
|
||||
if env::var("CARGO_FEATURE_POSTPROC").is_ok() {
|
||||
if env::var("CARGO_FEATURE_BUILD_GPL").is_err() {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "postproc is GPL"));
|
||||
}
|
||||
// the binary using ffmpeg-sys cannot be redistributed
|
||||
switch!(configure, "BUILD_NONFREE", "nonfree");
|
||||
|
||||
configure.arg("--enable-postproc");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-postproc");
|
||||
}
|
||||
// configure building libraries based on features
|
||||
switch!(configure, "AVCODEC", "avcodec");
|
||||
switch!(configure, "AVDEVICE", "avdevice");
|
||||
switch!(configure, "AVFILTER", "avfilter");
|
||||
switch!(configure, "AVFORMAT", "avformat");
|
||||
switch!(configure, "AVRESAMPLE", "avresample");
|
||||
switch!(configure, "POSTPROC", "postproc");
|
||||
switch!(configure, "SWRESAMPLE", "swresample");
|
||||
switch!(configure, "SWSCALE", "swscale");
|
||||
|
||||
if env::var("CARGO_FEATURE_SWRESAMPLE").is_ok() {
|
||||
configure.arg("--enable-swresample");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-swresample");
|
||||
}
|
||||
// configure external SSL libraries
|
||||
enable!(configure, "BUILD_LIB_GNUTLS", "gnutls");
|
||||
enable!(configure, "BUILD_LIB_OPENSSL", "openssl");
|
||||
|
||||
if env::var("CARGO_FEATURE_SWSCALE").is_ok() {
|
||||
configure.arg("--enable-swscale");
|
||||
}
|
||||
else {
|
||||
configure.arg("--disable-swscale");
|
||||
}
|
||||
// configure external filters
|
||||
enable!(configure, "BUILD_LIB_FONTCONFIG", "fontconfig");
|
||||
enable!(configure, "BUILD_LIB_FREI0R", "frei0r");
|
||||
enable!(configure, "BUILD_LIB_LADSPA", "ladspa");
|
||||
enable!(configure, "BUILD_LIB_ASS", "libass");
|
||||
enable!(configure, "BUILD_LIB_FREETYPE", "libfreetype");
|
||||
enable!(configure, "BUILD_LIB_FRIBIDI", "libfribidi");
|
||||
enable!(configure, "BUILD_LIB_OPENCV", "libopencv");
|
||||
|
||||
// enable external codecs
|
||||
configure.arg("--enable-avisynth");
|
||||
configure.arg("--enable-avresample");
|
||||
configure.arg("--enable-fontconfig");
|
||||
configure.arg("--enable-gnutls");
|
||||
configure.arg("--enable-ladspa");
|
||||
configure.arg("--enable-libass");
|
||||
configure.arg("--enable-libbluray");
|
||||
configure.arg("--enable-libfreetype");
|
||||
configure.arg("--enable-libfribidi");
|
||||
configure.arg("--enable-libgsm");
|
||||
configure.arg("--enable-libmodplug");
|
||||
configure.arg("--enable-libmp3lame");
|
||||
configure.arg("--enable-libopenjpeg");
|
||||
configure.arg("--enable-libopus");
|
||||
configure.arg("--enable-libpulse");
|
||||
configure.arg("--enable-libschroedinger");
|
||||
configure.arg("--enable-libsoxr");
|
||||
configure.arg("--enable-libspeex");
|
||||
configure.arg("--enable-libssh");
|
||||
configure.arg("--enable-libtheora");
|
||||
configure.arg("--enable-libv4l2");
|
||||
configure.arg("--enable-libvorbis");
|
||||
configure.arg("--enable-libvpx");
|
||||
configure.arg("--enable-libwebp");
|
||||
// configure external encoders/decoders
|
||||
enable!(configure, "BUILD_LIB_AACPLUS", "libaacplus");
|
||||
enable!(configure, "BUILD_LIB_CELT", "libcelt");
|
||||
enable!(configure, "BUILD_LIB_DCADEC", "libdcadec");
|
||||
enable!(configure, "BUILD_LIB_FAAC", "libfaac");
|
||||
enable!(configure, "BUILD_LIB_FDK_AAC", "libfdk-aac");
|
||||
enable!(configure, "BUILD_LIB_GSM", "libgsm");
|
||||
enable!(configure, "BUILD_LIB_ILBC", "libilbc");
|
||||
enable!(configure, "BUILD_LIB_VAZAAR", "libvazaar");
|
||||
enable!(configure, "BUILD_LIB_MP3LAME", "libmp3lame");
|
||||
enable!(configure, "BUILD_LIB_OPENCORE_AMRNB", "libopencore-amrnb");
|
||||
enable!(configure, "BUILD_LIB_OPENCORE_AMRWB", "libopencore-amrwrb");
|
||||
enable!(configure, "BUILD_LIB_OPENH264", "libopenh264");
|
||||
enable!(configure, "BUILD_LIB_OPENH265", "libopenh265");
|
||||
enable!(configure, "BUILD_LIB_OPENJPEG", "libopenjpeg");
|
||||
enable!(configure, "BUILD_LIB_OPUS", "libopus");
|
||||
enable!(configure, "BUILD_LIB_SCHROEDINGER", "libschroedinger");
|
||||
enable!(configure, "BUILD_LIB_SHINE", "libshine");
|
||||
enable!(configure, "BUILD_LIB_SNAPPY", "libsnappy");
|
||||
enable!(configure, "BUILD_LIB_SPEEX", "libspeex");
|
||||
enable!(configure, "BUILD_LIB_STAGEFRIGHT_H264", "libstagefright-h264");
|
||||
enable!(configure, "BUILD_LIB_THEORA", "libtheora");
|
||||
enable!(configure, "BUILD_LIB_TWOLAME", "libtwolame");
|
||||
enable!(configure, "BUILD_LIB_UTVIDEO", "libutvideo");
|
||||
enable!(configure, "BUILD_LIB_VO_AACENC", "libvo-aacenc");
|
||||
enable!(configure, "BUILD_LIB_VO_AMRWBENC", "libvo-amrwbenc");
|
||||
enable!(configure, "BUILD_LIB_VORBIS", "libvorbis");
|
||||
enable!(configure, "BUILD_LIB_VPX", "libvpx");
|
||||
enable!(configure, "BUILD_LIB_WAVPACK", "libwavpack");
|
||||
enable!(configure, "BUILD_LIB_WEBP", "libwebp");
|
||||
enable!(configure, "BUILD_LIB_X264", "libx264");
|
||||
enable!(configure, "BUILD_LIB_X265", "libx265");
|
||||
enable!(configure, "BUILD_LIB_AVS", "libavs");
|
||||
enable!(configure, "BUILD_LIB_XVID", "libxvid");
|
||||
|
||||
if env::var("CARGO_FEATURE_BUILD_GPL").is_ok() {
|
||||
configure.arg("--enable-libx264");
|
||||
configure.arg("--enable-libx265");
|
||||
configure.arg("--enable-libxvid");
|
||||
}
|
||||
|
||||
if env::var("CARGO_FEATURE_BUILD_VERSION3").is_ok() {
|
||||
configure.arg("--enable-libopencore_amrnb");
|
||||
configure.arg("--enable-libopencore_amrwb");
|
||||
}
|
||||
// configure external protocols
|
||||
enable!(configure, "BUILD_LIB_SMBCLIENT", "libsmbclient");
|
||||
enable!(configure, "BUILD_LIB_SSH", "libssh");
|
||||
|
||||
// run ./configure
|
||||
if !try!(configure.status()).success() {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "configure failed"));
|
||||
}
|
||||
|
||||
// run make
|
||||
if !try!(Command::new("make").current_dir(&source()).status()).success() {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "make failed"));
|
||||
}
|
||||
|
||||
// run make install
|
||||
if !try!(Command::new("make").current_dir(&source()).arg("install").status()).success() {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "install failed"));
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "make install failed"));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user