Skip to content

Commit 3d0e009

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

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-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: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,41 @@ fn build() {
239239
"--disable-doc",
240240
"--disable-autodetect",
241241
];
242+
243+
let mut pkg_config_path = env::var_os("PKG_CONFIG_PATH");
244+
245+
if env::var_os("CARGO_FEATURE_GPL").is_some() {
246+
configure_flags.push("--enable-gpl");
247+
}
248+
249+
if env::var_os("CARGO_FEATURE_X264").is_some() {
250+
configure_flags.push("--enable-libx264");
251+
let mut x264_pkg_config = env::var_os("DEP_X264_PKGCONFIG").unwrap();
252+
253+
// append existing pkg_config path - make sure x264's pkgconfig has precedence:
254+
if let Some(path) = pkg_config_path {
255+
x264_pkg_config.push(":");
256+
x264_pkg_config.push(path);
257+
}
258+
259+
pkg_config_path = Some(x264_pkg_config);
260+
}
261+
242262
// TRY TO SPEED THIS UP FOR DEV BUILDS
243263
if is_debug_mode() && opt_level_eq(0) {
244264
configure_flags.push("--disable-optimizations");
245-
configure_flags.push("--disable-debug");
265+
configure_flags.push("--enable-debug");
246266
configure_flags.push("--disable-stripping");
247267
}
248268

249269
let eval_configure = |flags: &[&str]| {
250-
Command::new("./configure")
270+
let mut configure = Command::new("./configure");
271+
272+
if let Some(path) = &pkg_config_path {
273+
configure.env("PKG_CONFIG_PATH", path);
274+
}
275+
276+
configure
251277
.current_dir(&source_path)
252278
.args(flags)
253279
.output()

0 commit comments

Comments
 (0)