Use pkg-config
							parent
							
								
									2b54b72054
								
							
						
					
					
						commit
						0444f7bd64
					
				| 
						 | 
					@ -20,3 +20,4 @@ libc = "0.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[build-dependencies]
 | 
					[build-dependencies]
 | 
				
			||||||
bindgen = "0.52"
 | 
					bindgen = "0.52"
 | 
				
			||||||
 | 
					pkg-config = "0.3"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,10 +4,9 @@ use std::env;
 | 
				
			||||||
use std::path::PathBuf;
 | 
					use std::path::PathBuf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn main() {
 | 
					fn main() {
 | 
				
			||||||
    println!("cargo:rustc-link-lib=vlc");
 | 
					 | 
				
			||||||
    println!("cargo:rerun-if-changed=wrapper.h");
 | 
					    println!("cargo:rerun-if-changed=wrapper.h");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let bindings = bindgen::Builder::default()
 | 
					    let mut bindings = bindgen::Builder::default()
 | 
				
			||||||
        .header("wrapper.h")
 | 
					        .header("wrapper.h")
 | 
				
			||||||
        // For no_std
 | 
					        // For no_std
 | 
				
			||||||
        .use_core()
 | 
					        .use_core()
 | 
				
			||||||
| 
						 | 
					@ -18,9 +17,15 @@ fn main() {
 | 
				
			||||||
        .whitelist_function(".*vlc.*")
 | 
					        .whitelist_function(".*vlc.*")
 | 
				
			||||||
        .whitelist_var(".*vlc.*")
 | 
					        .whitelist_var(".*vlc.*")
 | 
				
			||||||
        .whitelist_function("vsnprintf")
 | 
					        .whitelist_function("vsnprintf")
 | 
				
			||||||
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
 | 
					        .parse_callbacks(Box::new(bindgen::CargoCallbacks));
 | 
				
			||||||
        .generate()
 | 
					
 | 
				
			||||||
        .expect("Unable to generate bindings");
 | 
					    // Set header include paths
 | 
				
			||||||
 | 
					    let pkg_config_library = pkg_config::Config::new().probe("libvlc").unwrap();
 | 
				
			||||||
 | 
					    for include_path in &pkg_config_library.include_paths {
 | 
				
			||||||
 | 
					        bindings = bindings.clang_arg(format!("-I{}", include_path.display()));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let bindings = bindings.generate().expect("Unable to generate bindings");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
 | 
					    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
 | 
				
			||||||
    bindings
 | 
					    bindings
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue