-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
47 lines (42 loc) · 1.66 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
extern crate bindgen;
extern crate cmake;
use cmake::Config;
use std::env;
use std::path::PathBuf;
fn main() {
// tell cargo to build the sys interface to ffmpeg
// Note, this requires the 'pkg-config' and 'libav*-dev' packages on ubuntu
let dst = Config::new("sys")
.static_crt(true)
.very_verbose(true)
.cflag("-fPIC")
.cflag("-O3")
.cflag("-Ofast")
.cflag("-march=native")
.cflag("-funroll-loops")
.build();
// Link hodges, and the various ffmpeg libraries, once we've told it where to search foor hodges
println!("cargo:rustc-link-search={}", dst.display());
println!("cargo:rustc-link-lib=static=hodges");
println!("cargo:rustc-link-lib=avdevice");
println!("cargo:rustc-link-lib=avformat");
println!("cargo:rustc-link-lib=avfilter");
println!("cargo:rustc-link-lib=avcodec");
println!("cargo:rustc-link-lib=swresample");
println!("cargo:rustc-link-lib=swscale");
println!("cargo:rustc-link-lib=avutil");
// create bindings for the static c library
let header = dst.join("libhodges.h");
let bindings = bindgen::Builder::default()
// use the header from the dst, where cmake has writen the headers
.header(header.to_str().unwrap())
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}