|
1 | 1 | #![allow(unused)] |
2 | 2 |
|
| 3 | +use std::env; |
3 | 4 | use std::iter::FromIterator; |
4 | 5 | use std::collections::HashSet; |
5 | 6 | use std::convert::AsRef; |
@@ -239,15 +240,46 @@ fn build() { |
239 | 240 | "--disable-doc", |
240 | 241 | "--disable-autodetect", |
241 | 242 | ]; |
| 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 | + |
242 | 268 | // TRY TO SPEED THIS UP FOR DEV BUILDS |
243 | 269 | if is_debug_mode() && opt_level_eq(0) { |
244 | 270 | configure_flags.push("--disable-optimizations"); |
245 | | - configure_flags.push("--disable-debug"); |
| 271 | + configure_flags.push("--enable-debug"); |
246 | 272 | configure_flags.push("--disable-stripping"); |
247 | 273 | } |
248 | 274 |
|
249 | 275 | 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 |
251 | 283 | .current_dir(&source_path) |
252 | 284 | .args(flags) |
253 | 285 | .output() |
|
0 commit comments