Skip to content

Commit

Permalink
add x264-dev as an optional dependency gated by 'x264' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Somerville committed May 1, 2020
1 parent ce15106 commit 3d0e009
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ repository = "https://github.com/imager-io/ffmpeg-dev-rs"
readme = "README.md"
exclude = ["assets", "examples"]

[features]
default = []
gpl = []
x264 = ["x264-dev"]

[dependencies]
libc = "^0.2"
num_cpus = "1.11.1"
x264-dev = { path = "../x264-dev", optional = true }

[build-dependencies]
tar = "0.4.26"
flate2 = "1.0.12"
bindgen = "0.51"
num_cpus = "1.11.1"
cc = "1.0.46"
cc = "1.0.46"
30 changes: 28 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,41 @@ fn build() {
"--disable-doc",
"--disable-autodetect",
];

let mut pkg_config_path = env::var_os("PKG_CONFIG_PATH");

if env::var_os("CARGO_FEATURE_GPL").is_some() {
configure_flags.push("--enable-gpl");
}

if env::var_os("CARGO_FEATURE_X264").is_some() {
configure_flags.push("--enable-libx264");
let mut x264_pkg_config = env::var_os("DEP_X264_PKGCONFIG").unwrap();

// append existing pkg_config path - make sure x264's pkgconfig has precedence:
if let Some(path) = pkg_config_path {
x264_pkg_config.push(":");
x264_pkg_config.push(path);
}

pkg_config_path = Some(x264_pkg_config);
}

// TRY TO SPEED THIS UP FOR DEV BUILDS
if is_debug_mode() && opt_level_eq(0) {
configure_flags.push("--disable-optimizations");
configure_flags.push("--disable-debug");
configure_flags.push("--enable-debug");
configure_flags.push("--disable-stripping");
}

let eval_configure = |flags: &[&str]| {
Command::new("./configure")
let mut configure = Command::new("./configure");

if let Some(path) = &pkg_config_path {
configure.env("PKG_CONFIG_PATH", path);
}

configure
.current_dir(&source_path)
.args(flags)
.output()
Expand Down

0 comments on commit 3d0e009

Please sign in to comment.