Skip to content

Commit 1f315aa

Browse files
author
Charlie Somerville
committed
add x264-dev as an optional dependency gated by 'x264' feature
1 parent ce15106 commit 1f315aa

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ repository = "https://github.com/imager-io/ffmpeg-dev-rs"
1111
readme = "README.md"
1212
exclude = ["assets", "examples"]
1313

14+
[features]
15+
default = []
16+
gpl = []
17+
x264 = ["x264-dev"]
18+
1419
[dependencies]
1520
libc = "^0.2"
1621
num_cpus = "1.11.1"
22+
x264-dev = { path = "../x264-dev", optional = true }
1723

1824
[build-dependencies]
1925
tar = "0.4.26"
2026
flate2 = "1.0.12"
2127
bindgen = "0.51"
2228
num_cpus = "1.11.1"
23-
cc = "1.0.46"
29+
cc = "1.0.46"

build.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![allow(unused)]
22

3+
use std::env;
34
use std::iter::FromIterator;
45
use std::collections::HashSet;
56
use std::convert::AsRef;
@@ -239,15 +240,46 @@ fn build() {
239240
"--disable-doc",
240241
"--disable-autodetect",
241242
];
243+
244+
let mut pkg_config_path = env::var_os("PKG_CONFIG_PATH");
245+
246+
if env::var_os("CARGO_FEATURE_GPL").is_some() {
247+
configure_flags.push("--enable-gpl");
248+
}
249+
250+
if env::var_os("CARGO_FEATURE_X264").is_some() {
251+
configure_flags.push("--enable-libx264");
252+
253+
let x264_libs = env::var_os("DEP_X264_LIBS").unwrap();
254+
println!("cargo:rustc-link-search=native={}", x264_libs.to_str().expect("PathBuf to str"));
255+
println!("cargo:rustc-link-lib=static=x264");
256+
257+
let mut x264_pkg_config = env::var_os("DEP_X264_PKGCONFIG").unwrap();
258+
259+
// append existing pkg_config path - make sure x264's pkgconfig has precedence:
260+
if let Some(path) = pkg_config_path {
261+
x264_pkg_config.push(":");
262+
x264_pkg_config.push(path);
263+
}
264+
265+
pkg_config_path = Some(x264_pkg_config);
266+
}
267+
242268
// TRY TO SPEED THIS UP FOR DEV BUILDS
243269
if is_debug_mode() && opt_level_eq(0) {
244270
configure_flags.push("--disable-optimizations");
245-
configure_flags.push("--disable-debug");
271+
configure_flags.push("--enable-debug");
246272
configure_flags.push("--disable-stripping");
247273
}
248274

249275
let eval_configure = |flags: &[&str]| {
250-
Command::new("./configure")
276+
let mut configure = Command::new("./configure");
277+
278+
if let Some(path) = &pkg_config_path {
279+
configure.env("PKG_CONFIG_PATH", path);
280+
}
281+
282+
configure
251283
.current_dir(&source_path)
252284
.args(flags)
253285
.output()

0 commit comments

Comments
 (0)